Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-commit characters do not work consistently #208332

Closed
frevds opened this issue Mar 20, 2024 · 11 comments
Closed

Auto-commit characters do not work consistently #208332

frevds opened this issue Mar 20, 2024 · 11 comments

Comments

@frevds
Copy link

frevds commented Mar 20, 2024

Type: Bug

In TypeScript, I can use the "." as an auto-commit character for committing the suggestion only in the left-hand-side expression. After an " = " in the right-hand-side they don't seem to work.
Also, these characters cannot be configured.

It is extremely annoying during development. I unlearnt my prior behaviour from other editors and am pressing Return or Tab all the time for autocompletion, but am annoyed having to do this explicitly.

It is surprising that a feature as very basic and essential as this does not get properly implemented in VSCode for such a long time. If Visual Studio is able to do it, VSCode should be.

Furthermore, committing a suggestion does not recognize what follows, always committing the whole word even if the rest of the word is already there, forcing everybody to delete the rest of the word. These basic convenience features are expected of a proper code editor. If it's too complicated to implement using a Regex-based system, I'm afraid you'll have to find a different way, having this not working properly cannot be excused, it's a must to have, or a reason to switch to a different editor.

VS Code version: Code 1.87.2 (863d258, 2024-03-08T15:20:17.278Z)
OS version: Windows_NT x64 10.0.22631
Modes:

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz (16 x 2496)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.73GB (16.34GB free)
Process Argv --crash-reporter-id fd07ca10-4e2d-453c-ba70-cbc1dfbb2fa2
Screen Reader no
VM 0%
Extensions (17)
Extension Author (truncated) Version
vscode-pandoc Chr 0.4.5
vscode-typescript-to-json-schema mar 0.0.17
debugpy ms- 2024.2.0
isort ms- 2023.10.1
python ms- 2024.2.1
vscode-pylance ms- 2024.3.1
jupyter ms- 2024.2.0
jupyter-renderers ms- 1.0.17
vscode-jupyter-cell-tags ms- 0.1.8
vscode-jupyter-slideshow ms- 0.1.5
azure-account ms- 0.11.6
cpptools ms- 1.19.8
vscode-xml red 0.26.1
LiveServer rit 5.7.9
vscode-counter uct 3.4.0
vscode-icons vsc 12.7.0
markdown-pdf yza 1.5.0
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscorecescf:30445987
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:30899288
c4g48928:30535728
azure-dev_surveyonecf:30548226
2i9eh265:30646982
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:30992801
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
pydisww1:30991133
cppperfnew:30979542
d34g3935:30971562
fegfb526:30981948
bg6jg535:30979843
ccp1r3:30958155
dsvsc020:30976470
gee8j676:30988843

@mjbvz mjbvz self-assigned this Mar 20, 2024
@mjbvz
Copy link
Contributor

mjbvz commented Mar 20, 2024

Please share a code example that demonstrates the issue

@frevds
Copy link
Author

frevds commented Mar 20, 2024

Please share a code example that demonstrates the issue

Certainly, here is a way to reproduce two issues: @mjbvz

Make a new file, set the language to "TypeScript", then paste the following snippet and follow the instructions:

const foo = { boo: '' }; 

// 1. type "f" to see the suggestions pop up
// 2. type "." to autocomplete "foo"
// 3. press Enter or Tab (to commit "boo", since other characters we wish to type next (such as space or "=") don't work)
// 4. write " = " (now we are on the right-hand side of an expression)
// 5. now repeat, type "f" to see the suggestions pop up
// 6. type "." to see it FAIL to autocomplete "foo"

// foo.boo = f.

PS: The same issue occurs using Javascript as the language.

@mjbvz mjbvz transferred this issue from microsoft/vscode Mar 21, 2024
@mjbvz mjbvz removed their assignment Mar 21, 2024
@mjbvz
Copy link
Contributor

mjbvz commented Mar 21, 2024

@RyanCavanaugh On the right hand side, isNewIdentifierLocation is true which surpasses commit characters. Seems wrong but maybe I'm overlooking a use case

@RyanCavanaugh
Copy link
Member

AFAICT it's been this way forever. It's straightforward to change but I'd be quite concerned about messing with muscle memory.

@frevds
Copy link
Author

frevds commented Mar 21, 2024

At least provide a setting for activating it?
And preferably also a setting for the actual commit chars?
Muscle-memory and forever indeed, but I can't imagine anybody enjoying this actually having to press Tab and Enter all the time rather than the next character that should follow.

And how is the right-hand side ever a new identifier?
Only for inline/lambda functions with parameters maybe, which is a valid case sure, but doesn't occur that often to drop the commit.

@RyanCavanaugh
Copy link
Member

I'm not trying to disagree with anything here, just stating facts.

@frevds
Copy link
Author

frevds commented Mar 21, 2024

I'm also not trying to press any change here (apparently this behaviour has some point).
But it would be great to have a choice to switch this behaviour, maybe even interactive (I remember VS had a keyboard combo to switch the commit behaviour on-the-fly, if it cannot be decided generally).

@RyanCavanaugh
Copy link
Member

@DanielRosenwasser reminded me why we do this

If you're trying to write this code by typing the characters it contains:

const addOne = x => x + 1;

At this point when you write the space:

const addOne = x|
//              ^- space here

we would end up completing it to

const addOne = XMLDocument

which is extremely annoying.

@frevds
Copy link
Author

frevds commented Mar 21, 2024

Yeah, the space could be selectively disabled then maybe. Or (as in VS) the autocommit suggestion is not selected in the list in this case, but the mode can be switched using Alt+Space (or whatever it was there), since indeed both cases are possible and cannot be formally known beforehand.
However, it is more likely that you don't want to write a lambda expression here, and the commit only working sometimes is even more annoying (you don't consciously discriminate these cases, you just notice that sometimes it works and sometimes it doesn't, ergo you cannot rely on it).

@RyanCavanaugh RyanCavanaugh transferred this issue from microsoft/TypeScript Mar 21, 2024
@mjbvz
Copy link
Contributor

mjbvz commented Mar 21, 2024

@RyanCavanaugh I think the proper fix is for TS to compute commit characters instead of having VS Code try to derive them: microsoft/TypeScript#27623

Closing in favor of that issue which also should align with lsp

@mjbvz mjbvz closed this as completed Mar 21, 2024
@frevds
Copy link
Author

frevds commented Mar 21, 2024

May I point out the other part of my request @mjbvz again:

Furthermore, committing a suggestion does not recognize what follows, always committing the whole word even if the rest of the word is already there, forcing everybody to delete the rest of the word.

Anything that can be done here?

As an example:
image

That also happens if I complete everything:
image

@microsoft microsoft locked and limited conversation to collaborators Jun 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants