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

Aberta Para iniciantes
#3,052 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
75/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
react-native, typescript, vscode
Domínio
devtools

Direção de pesquisa

Comece lendo LaunchJsonCompletionHelper.isCommaImmediatelyBeforeCursor() e o scanner JSONC existente mencionado na issue; confira os testes próximos sobre a inserção de conclusões em torno de comentários. Reproduza as etapas com o launch.json fornecido e, em seguida, verifique se a nova configuração é inserida sem uma vírgula extra e se o documento continua sendo JSONC válido.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
TypeScript
Estrelas
2.7k
Forks
303
Merge médio
22h 52min
PRs com merge (30d)
36

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de microsoft/vscode-react-native

Todas as issues de microsoft/vscode-react-native

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.