[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
分支
304
平均合併
23 小時 28 分鐘
30 天內合併 PR
35

環境準備

  • 沒有 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 摘要。