[Feature] React Native debug configuration completion inserts an extra comma after comments in launch.json

Aperta Adatta ai principianti
#3,052 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react-native, typescript, vscode
Ambito
devtools

Direzione di ricerca

Inizia leggendo LaunchJsonCompletionHelper.isCommaImmediatelyBeforeCursor() e lo scanner JSONC esistente menzionato nell’issue; controlla i test vicini relativi all’inserimento dei completamenti in prossimità dei commenti. Riproduci i passaggi con il file launch.json fornito, quindi verifica che la nuova configurazione venga inserita senza una virgola aggiuntiva e che il documento rimanga JSONC valido.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Description

Accepting the React Native completion item in launch.json and completing the configuration wizard can insert an extra comma when a comment separates the cursor from an existing comma.

This turns an otherwise valid launch.json into invalid JSONC.

Steps to Reproduce

  1. Open a React Native project in VS Code with React Native Tools enabled.

  2. Set .vscode/launch.json to the following:

    {
      "version": "0.2.0",
      "configurations": [
        {
          "name": "Debug Android Hermes",
          "request": "launch",
          "type": "reactnativedirect",
          "cwd": "${workspaceFolder}",
          "platform": "android"
        },
        // Add another debug configuration here
    
      ]
    }
    
  3. Place the cursor on the blank line immediately below the comment, inside the configurations array.

  4. Open the Command Palette and run Trigger Suggest.

  5. Select the React Native completion item.

  6. Complete the extension's configuration wizard.

  7. Inspect the inserted configuration.

Note: Use Trigger Suggest → React Native, not the Add Configuration… button. In the tested case, the button relocates the insertion point and does not reproduce this issue.

Expected Behavior

The extension should recognize the existing comma after the preceding configuration and insert the new configuration without adding another comma.

    },
    // Add another debug configuration here
    {
      "name": "..."
    }

The document should remain valid JSONC.

Actual Behavior

An additional comma is inserted before the new configuration:

    },
    // Add another debug configuration here
    ,{
      "name": "..."
    }

There are now two commas between the configuration objects, separated by a comment, making the document invalid.

Possible Cause

LaunchJsonCompletionHelper.isCommaImmediatelyBeforeCursor() checks preceding lines using trim().endsWith(",") and stops at the first non-empty line.

It does not skip comments to identify the preceding significant JSON token. It also treats a comma at the end of a comment as an actual JSON comma.

Using the existing JSONC scanner to ignore comments and whitespace when identifying the preceding token may address both cases.

Lingua principale
TypeScript
Stelle
2.7k
Fork
303
Merge medio
20h 33m
PR unite (30g)
33

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/vscode-react-native

Tutte le issue di microsoft/vscode-react-native

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.