microsoft / microsoft/vscode-cpptools

Accepting a code completion suggestion erases symbol to the right of the cursor

Aperta
#13,440 9 commenti 4 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

enhancement Language Service
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

Environment
  • OS and Version: macOS Sequoia 15.2
  • VS Code Version: 1.98.2 (Universal)
  • C/C++ Extension Version: 1.23.6
Bug Summary and Steps to Reproduce

Bug Summary: If a code completion suggestion based on the symbol to the left of the cursor is accepted when there is a symbol to the right of the cursor, the symbol to the right is deleted.

Steps to reproduce:
In an empty folder, add a C file with the following code:

#include <stdio.h>

int main(void) {
    int first_number = 3;
    int second_number = 4;

    add_nums(second_number);
}

int add_nums(int a, int b) {
    return a + b;
}

On the line add_nums(second_number), place your cursor before second_number and start typing first_number. When the code completion suggestion for first_number appears, accept it. The full first_number will appear, but second_number will disappear.

Expected behavior:
The full first_number should appear to the left of the cursor, but second_number should remain intact to the right of the cursor.

Configuration and Logs
No `c_cpp_properties.json` file is set up.
No output appears in the language server logs ("C/C++ Diagnostics"; there is no "C/C++" option) when performing this code completion.

Output of `C/C++: Log Diagnostics`:
-------- Diagnostics - 3/29/2025, 6:47:25 PM
Version: 1.23.6
Current Configuration:
{
    "name": "Mac",
    "includePath": [
        "/Users/malcolmanderson/Documents/Repositories/CPlayground/**"
    ],
    "defines": [],
    "macFrameworkPath": [
        "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
    ],
    "compilerPath": "/usr/bin/clang",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "macos-clang-x64",
    "compilerPathInCppPropertiesJson": "/usr/bin/clang",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "browse": {
        "path": [
            "/Users/malcolmanderson/Documents/Repositories/CPlayground/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {},
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": false,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.23.6.0
Current database path: /Users/malcolmanderson/Library/Caches/vscode-cpptools/25144edad9b12697367efc1e18c0bf36/.browse.VC.db
Translation Unit Mappings:
[ /Users/malcolmanderson/Documents/Repositories/CPlayground/main.c - source TU]:
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types/_va_list.h
Translation Unit Configurations:
[ /Users/malcolmanderson/Documents/Repositories/CPlayground/main.c ]
    Process ID: 12660
    Memory Usage: 27 MB
    Compiler Path: /usr/bin/clang
    Includes:
    System Includes:
        /usr/local/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/16/include
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
    Frameworks:
        /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
    Standard Version: c17
    IntelliSense Mode: macos-clang-x64
    Other Flags:
        --clang
        --clang_version=170006
Total Memory Usage: 27 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 23244
Other Extensions

No response

Additional context

https://github.com/user-attachments/assets/93a00258-d3e8-406b-a904-de881d1826ee

Guida per i contributori

Apri la guida per i contributori

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.

Direzione di ricerca

Riproduci il problema segnalato nell’estensione C/C++ di VS Code usando l’esempio main.c fornito, posiziona il cursore prima di second_number e accetta first_number. Traccia la gestione della modifica del completamento e aggiungi un test di regressione; il lavoro è concluso quando l’accettazione del suggerimento lascia invariato il simbolo a destra.

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

Valutazione

Stack tecnologico
c, cpp, vscode
Ambito
developer-experience, tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.