vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Enable an insert mode that never replaces (like TypeScript instead of VS)

Open sean-mcmanus opened this issue 1 year ago • 19 comments

          This issue prevails, even with `"editor.suggest.insertMode": "insert", "[cpp]": { "editor.suggest.insertMode": "insert" }`:

actual

I would expect the editor with the above settings to never ever ever delete characters, e. g. expect the following outcome:

expected

Originally posted by @Longhanks in https://github.com/microsoft/vscode-cpptools/issues/10553#issuecomment-1448365253

sean-mcmanus avatar Feb 28 '23 16:02 sean-mcmanus

It looks likes this would be fixed by switching to returning https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#insertReplaceEdit (instead of the textEdit that is currently returned).

sean-mcmanus avatar Apr 03 '23 21:04 sean-mcmanus

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.

github-actions[bot] avatar Jun 03 '23 11:06 github-actions[bot]

I think this goes against the spirit of the setting and should be considered a bug, rather than a feature request. Maybe the VS Code devs can chime in to clarify the proper idea of "insertMode": "insert".

Longhanks avatar Jun 03 '23 12:06 Longhanks

@sean-mcmanus Sure, we can consider it a bug, but I'm not sure when we'll get around to fixing it (although the issue is closed, it could still get fixed if we decide to prioritize it later on).

sean-mcmanus avatar Jun 10 '23 01:06 sean-mcmanus

This is how the issue replicates in the "folder" settings: Screencast from 16 08 2023 10 21 12

When one selects the non-default mode (insert), it swaps back to the default (replace) as soon as the focused UI element is changed. To me this makes it seem like a bug even further.

I find it extremely annoying that the "insert" mode is not working.

loikkant avatar Aug 16 '23 07:08 loikkant

I'm joining from #11353, is there anything we can do to help prioritize this issue?

Adnn avatar Aug 24 '23 08:08 Adnn

By the way, as there existed previous comments discussing the intent of this settings, and whether it was a bug:

// Controls whether words are overwritten when accepting completions. Note that this depends on extensions opting into this feature. // - insert: Insert suggestion without overwriting text right of the cursor. // - replace: Insert suggestion and overwrite text right of the cursor.

(from the documentation of the default settings)

Adnn avatar Aug 24 '23 09:08 Adnn

@Adnn It's already been prioritized.

sean-mcmanus avatar Aug 24 '23 20:08 sean-mcmanus

Hi, I've been always finding pretty annoying that either pressing tab/enter the autosuggestion feature always replace the text on the right of the cursor, I always want to "insert". The cpp extension ignores the insertmode setting from vscode and overwrites it. Is it going to be fixed? Thanks!

albertcaldas84 avatar Sep 16 '23 07:09 albertcaldas84

Trying to figure out how to fix this annoying behavior. Why is the setting "editor.suggest.insertMode": "insert", ignored? It was "replace" but I changed the global and all languages, yet it deletes the next word when I am inserting auto-completed code.

n808 avatar Oct 04 '23 12:10 n808

Hi, chiming in on this! I personally find it very annoying, and there must be quite a lot of us. How this is not the behavior everyone expects is beyond me, but at least respect the setting. It did use to work at some point, of this I'm certain, so it's not a feature request imho. Thanks in advance!

phogy avatar Oct 26 '23 14:10 phogy

Yes, this definitely worked as intended at some point.

Adnn avatar Oct 26 '23 14:10 Adnn

This is actively being worked on and you won't have to wait too much longer.

bobbrow avatar Oct 26 '23 18:10 bobbrow

Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.19.0 (pre-release)

sean-mcmanus avatar Nov 17 '23 10:11 sean-mcmanus

I'm still experiencing the same issue with pre-release 1.19.2. I have "Editor › Suggest: Insert Mode" set to Insert.

albertcaldas84 avatar Feb 06 '24 09:02 albertcaldas84

@albertcaldas84 I just checked back on this issue, and it works for me with pre-release 1.19.2. Did you make sure to set the cpp insertMode to insert? For some reason, the default for Cpp is replace (by opposition to the "general" default, which is insert, and the language specific value takes precedence).

To set the value for Cpp, I added the following entry to my settings.json:

{
    ...
    "[cpp]": {
        "editor.suggest.insertMode": "insert"
    }
}

Adnn avatar Feb 06 '24 15:02 Adnn

If I add this to the settings.json it works. I didn't have any entry, which should assume that "insert" was the default value.

albertcaldas84 avatar Feb 07 '24 07:02 albertcaldas84

I didn't have any entry, which should assume that "insert" was the default value.

The default value for cpp language is replace (unlike the "general" default, but the cpp value takes precedence when you edit cpp). This is why it has to be set explicitly to get inset behaviour.

Adnn avatar Feb 08 '24 10:02 Adnn

For some reason, the default for Cpp is replace (by opposition to the "general" default, which is insert, and the language specific value takes precedence).

I apologize in advance for the history lesson, but we chose "replace" even before the VS Code setting existed. This aligned better (though not exactly) with how C++ in Visual Studio behaves. When VS Code introduced the setting they reached out to us and there was a vote about what the default value for the setting would be. We narrowly lost the vote but were given a way to keep our behavior by overriding the default for c and cpp files. We recently suggested a new value "languageDefined" for the insert mode so that we could keep our default and also not require the weird language setting syntax to change it, but it didn't clear the triage bar.

bobbrow avatar Feb 08 '24 21:02 bobbrow