You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Accepting a code completion suggestion erases symbol to the right of the cursor #13440
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:
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
According to VS Code, normally "insert" is the default, but for the C and C++ languages, "replace" is the default (and what was causing this). Is there a reason why C/C++ changes the default behavior to be this way? I'm struggling right now to think of a case where the "replace" behavior is especially desirable, but I have run into countless instances where it's erased things I wanted to keep.
Malcolm Anderson (@Meorge) I wanted to change it back to insert but others on my team disagreed. See #10567 . We can use this issue to track it. I think we need more people to upvote this. We filed a related issue on VS Code at microsoft/vscode#176324 but it got closed. I think our current behavior matches VS 2017 and using "insert" matches VS 2022.
Reacted by Malcolm Anderson, Gábor Csorvási, Yiming Huang and Nagy-Egri Máté Ferenc
I'm not sure if this is related, but if I start typing an include: #include "someHead then press tab, the insert mode will finish with the quoutes, but since the editor already added a closing quoute, it will become this: #include "someHeader.h"".
Does anyone know how to change this?
Gábor Csorvási (@csorvagep) can you please open a new issue for what you're seeing? We should be checking the setting for auto-closing quotes to determine when we need to add it or not, but I know the VS Code team has changed that setting a few times over the years and it's possible we need to take another look at it.
This feature request is being closed due to insufficient upvotes. Please leave a 👍-upvote or 👎-downvote reaction on the issue to help us prioritize it. When enough upvotes are received, this issue will be eligible for our backlog.
Activity
mehlian commentedon Mar 30, 2025
Try this vscode option:
"editor.suggest.insertMode": "insert",Meorge commentedon Mar 30, 2025
Thanks, it looks like that worked!
According to VS Code, normally
"insert"is the default, but for the C and C++ languages,"replace"is the default (and what was causing this). Is there a reason why C/C++ changes the default behavior to be this way? I'm struggling right now to think of a case where the"replace"behavior is especially desirable, but I have run into countless instances where it's erased things I wanted to keep.sean-mcmanus commentedon Mar 31, 2025
Malcolm Anderson (@Meorge) I wanted to change it back to insert but others on my team disagreed. See #10567 . We can use this issue to track it. I think we need more people to upvote this. We filed a related issue on VS Code at microsoft/vscode#176324 but it got closed. I think our current behavior matches VS 2017 and using "insert" matches VS 2022.
csorvagep commentedon May 19, 2025
I'm not sure if this is related, but if I start typing an include:
#include "someHeadthen press tab, the insert mode will finish with the quoutes, but since the editor already added a closing quoute, it will become this:#include "someHeader.h"".Does anyone know how to change this?
bobbrow commentedon May 19, 2025
Gábor Csorvási (@csorvagep) can you please open a new issue for what you're seeing? We should be checking the setting for auto-closing quotes to determine when we need to add it or not, but I know the VS Code team has changed that setting a few times over the years and it's possible we need to take another look at it.
sean-mcmanus commentedon May 19, 2025
Gábor Csorvási (@csorvagep) Yeah, what Bob said, also I don't repro the issue (i.e. we need more info), and it's not related to this issue.
github-actions commentedon Jul 19, 2025
This feature request is being closed due to insufficient upvotes. Please leave a 👍-upvote or 👎-downvote reaction on the issue to help us prioritize it. When enough upvotes are received, this issue will be eligible for our backlog.
ryancu7 commentedon Apr 9, 2026
I have this setting but it is still doing replace.
github-actions commentedon Apr 9, 2026
This feature request has received enough votes to be added to our backlog.