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
Support editor.suggest.insertMode to control insert/replace behaviour #1991
But slightly different. My case is that if I insert a new word directly in front of another and select auto-complete the whole following word is deleted.
Maybe I'm the only one who has the problem but I regularly delete worde because I forget to add a space first.
This is especially annoying if you have moved a variaable to anotehr clas and now have to prefix everywhere the new class instance. When you use autocomplete for the instances name you delete the property name after it if you haven't included a space, that you have to delete again before you can type '.'
Also when you are inside a word and trigger autocomplete '.' as completion trigger doesn't work
I don't think so - that issue was about TypeScript doing bad things, and the Dart server generally does good things here :-)
My case is that if I insert a new word directly in front of another and select auto-complete the whole following word is deleted.
This is intended (and what I'm asking for in the TS issue above). I do sometimes have the same issue as you and insert a space to avoid this, but having worked with TypeScript doing it the opposite way, I'm not sure having that default behaviour would be better. For example, if you typo a function:
someFuntcionCall(1);
To fix it, you can just put the cursor somewhere in there and hit Ctrl+Space, which brings up the completion:
Selecting the right item will correctly replace the whole thing. Doing it "the TypeScript way" you'd end up with someFunctionCallmeFuntcionCall depending on where you put the cursor. I see this a lot in TS and it's quite infuriating as there's no quick way to select the bit to delete.
It's true that sometimes I'm trying to completion a function call before some other code (eg. wrap it around a variable), but I think that's less frequent than fixing simple typos. Most of the time, the completion includes the exact symbol name you want, so completing the whole thing is good.
This is especially annoying if you have moved a variaable to anotehr clas and now have to prefix everywhere the new class instance. When you use autocomplete for the instances name you delete the property name after it if you haven't included a space, that you have to delete again before you can type '.'
Would typing the . first (instead of a space) work? I think in this situation I'd probably put newProperty. in the clipboard and paste it in front of them, so maybe I don't think I've seen this enough to know how annoying it is.
Also when you are inside a word and trigger autocomplete '.' as completion trigger doesn't work
I can't repro this - pressing . in the middle of a word seems to open completion for me. If you can make a small repro, file a separate bug and I can look into it :-)
I'm with you that the behavior that if you trigger autocomplete inside the word it should replace. But could we avoid that when standing at the first character of the next word?
Sorry if I was unclear. I meant if the cursor is directly in front of the next word, could we in this case not delete the following word when triggering completion.
I'm not sure how you would make this distinction. For example, given this code:
myClass.myMethod();
If I want to change the myMethod call to myOtherMethod() because I selected the wrong one, I might put my cursor before the m in myMethod and invoke completion, expecting to select myOtherMethod and have it replace the text.
I think with the change you're suggesting, it would end up with myClass.myOtherMethodmyMethod()?
Yes, that would be the consequence. But if I want to replace the whole word I type Ctrl+d and the word is selected. If I then do control space it would replace the word.
Right, so you'd prefer it to be dependant on whether you had a selection? I don't think we have the ability to do that (from the extension). We give the completion list to VS Code, and it's in charge of applying the edits. We can't change the edits dynamically/conditionally.
I think the only workaround would be to delete the selected text before invoking the completion.
When I hit ctrl+d the cursor is then at the end of the word no longer at the beginning. How would it then replace the whole word?
And yes in that case you could just hit delete.
By default VS Code wants to do insert, but I personally think this is the less common case and since it differs from our current behaviour we may override editor.suggest.overwriteOnAccept for Dart to match the current behaviour (and you can press with <shift> to get insert mode).
You can now control this behaviour by holding <shift> when completing. By default, we will replace (the original behaviour) but holding shift will insert. If you want to swap these around (so insert is the default), you should override the editor.suggest.insertMode setting for Dart (note: you'll need to specifically set it for Dart, or our override will win):
changed the title [-]Code completion at the beginning of a word deletes the following word.[/-][+]Support editor.suggest.insertMode to control insert/replace behaviour[/+]on Apr 20, 2020
Sorry for resurrecting a very old issue...but would it be possible to actually respect the API and global configuration instead of requiring a language-specific override? It "looks" unnecessary and, more importantly, is quite hard to find.
@artoale the way settings are applied is controlled by VS Code, not the extension. The discoverability of this has been raised in the past, and a tooltip was added (by VS Code) to make it clearer when there are language-specific overrides (of which there are many for this setting):
I appreciate that it's frustrating to change a setting and for it to appear not to work, but unfortunately there's not much we can do from the extension here (we can't set the global setting, and I wouldn't be prepared to change Dart's default to insert without some significant indications that it's what most users would prefer).
Activity
DanTup commentedon Sep 16, 2019
I don't think so - that issue was about TypeScript doing bad things, and the Dart server generally does good things here :-)
This is intended (and what I'm asking for in the TS issue above). I do sometimes have the same issue as you and insert a space to avoid this, but having worked with TypeScript doing it the opposite way, I'm not sure having that default behaviour would be better. For example, if you typo a function:
To fix it, you can just put the cursor somewhere in there and hit Ctrl+Space, which brings up the completion:
Selecting the right item will correctly replace the whole thing. Doing it "the TypeScript way" you'd end up with
someFunctionCallmeFuntcionCalldepending on where you put the cursor. I see this a lot in TS and it's quite infuriating as there's no quick way to select the bit to delete.It's true that sometimes I'm trying to completion a function call before some other code (eg. wrap it around a variable), but I think that's less frequent than fixing simple typos. Most of the time, the completion includes the exact symbol name you want, so completing the whole thing is good.
Would typing the
.first (instead of a space) work? I think in this situation I'd probably putnewProperty.in the clipboard and paste it in front of them, so maybe I don't think I've seen this enough to know how annoying it is.I can't repro this - pressing
.in the middle of a word seems to open completion for me. If you can make a small repro, file a separate bug and I can look into it :-)escamoteur commentedon Sep 16, 2019
I'm with you that the behavior that if you trigger autocomplete inside the word it should replace. But could we avoid that when standing at the first character of the next word?
DanTup commentedon Sep 16, 2019
I'm not sure exactly what you mean - could you give an example?
escamoteur commentedon Sep 16, 2019
DanTup commentedon Sep 17, 2019
I'm not sure how you would make this distinction. For example, given this code:
myClass.myMethod();If I want to change the
myMethodcall tomyOtherMethod()because I selected the wrong one, I might put my cursor before theminmyMethodand invoke completion, expecting to selectmyOtherMethodand have it replace the text.I think with the change you're suggesting, it would end up with
myClass.myOtherMethodmyMethod()?escamoteur commentedon Sep 17, 2019
Yes, that would be the consequence. But if I want to replace the whole word I type Ctrl+d and the word is selected. If I then do control space it would replace the word.
DanTup commentedon Sep 17, 2019
Right, so you'd prefer it to be dependant on whether you had a selection? I don't think we have the ability to do that (from the extension). We give the completion list to VS Code, and it's in charge of applying the edits. We can't change the edits dynamically/conditionally.
I think the only workaround would be to delete the selected text before invoking the completion.
escamoteur commentedon Sep 17, 2019
When I hit ctrl+d the cursor is then at the end of the word no longer at the beginning. How would it then replace the whole word?
And yes in that case you could just hit delete.
Maybe we could make this behavior configurable.
DanTup commentedon Nov 11, 2019
VS Code now has support for both insert and replace completions and we'll adopt the new API in the next version:
https://code.visualstudio.com/updates/v1_40#_support-intellisense-replace-mode
By default VS Code wants to do insert, but I personally think this is the less common case and since it differs from our current behaviour we may override
editor.suggest.overwriteOnAcceptfor Dart to match the current behaviour (and you can press with<shift>to get insert mode).8 remaining items
DanTup commentedon Apr 20, 2020
You can now control this behaviour by holding
<shift>when completing. By default, we will replace (the original behaviour) but holding shift will insert. If you want to swap these around (so insert is the default), you should override theeditor.suggest.insertModesetting for Dart (note: you'll need to specifically set it for Dart, or our override will win):[-]Code completion at the beginning of a word deletes the following word.[/-][+]Support editor.suggest.insertMode to control insert/replace behaviour[/+]artoale commentedon Apr 8, 2025
Sorry for resurrecting a very old issue...but would it be possible to actually respect the API and global configuration instead of requiring a language-specific override? It "looks" unnecessary and, more importantly, is quite hard to find.
DanTup commentedon Apr 8, 2025
@artoale the way settings are applied is controlled by VS Code, not the extension. The discoverability of this has been raised in the past, and a tooltip was added (by VS Code) to make it clearer when there are language-specific overrides (of which there are many for this setting):
I appreciate that it's frustrating to change a setting and for it to appear not to work, but unfortunately there's not much we can do from the extension here (we can't set the global setting, and I wouldn't be prepared to change Dart's default to
insertwithout some significant indications that it's what most users would prefer).artoale commentedon Apr 8, 2025
Ah! Appreciate that and thanks for the reply! 👍