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

未关闭 适合新手
#3,052 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
react-native, typescript, vscode
领域
devtools

调研方向

先阅读 LaunchJsonCompletionHelper.isCommaImmediatelyBeforeCursor() 和 issue 中提到的现有 JSONC 扫描器;检查附近有关在注释周围插入补全内容的测试。使用提供的 launch.json 重现这些步骤,然后确认新配置插入时没有多余的逗号,并且文档仍是有效的 JSONC。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
TypeScript
星标
2.7k
派生
303
平均合并
20 小时 33 分钟
30 天内合并 PR
33

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/vscode-react-native 的其他 Issue

查看 microsoft/vscode-react-native 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。