microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.66k stars 29.06k forks source link

Inconsistent auto-complete behavior in Markdown #230840

Open paul-rogers opened 2 weeks ago

paul-rogers commented 2 weeks ago

Type: Bug

A recent VS code version added (or enabled) an auto-suggest option as one types text in a Markdown editor. Unfortunately, this "help" makes typing harder: newlines are interpreted as a desire to select a choice, not the end of the line of typing.

It is not clear that auto-suggest has value when typing in Markdown. Perhaps there is an option to disable it, but I could not find it despite a bit of a search. It is not obvious what the option might be called.

Further, it seems that the suggestions are only those words that already appear in the text rather than words in English (or your language of choice). This means that the set of suggestions depends on the document, not the language, which is a bit odd.

In addition, the feature seems random. I have a large markdown document (about 500 lines). Each time I restart VS Code, I get the auto-suggest pop-ups as I type. But, after a while, they stop appearing. When trying to write up the reproduction cases for this issue, I found that the suggestions stopped appearing at some random time. Needless to say, a random feature a bit of a nuisance.

Reproduction

If, during reproduction, the feature turns itself off, the workaround is to exit VS Code and restart. The feature will work for a while until it somehow decides to turn itself off again. If it does, restart again.

Create a file, 'test.md'. Open it in VS-Code. Begin typing:

the quick brown fox<Enter>

A pop-up box will briefly appear for each word, but will contain only Python (?) suggestions. For example, type foo. You'll get a suggestion for a fenced codeblock which isn't actually common in Markdown. No actual word choices appear because the document is empty: it has no symbols to match. Now, type the same text in a second line:

the quick brown fox
the quick brown fox|

Now pop-ups should appear that shows existing words in the document that match the word typed thus far. Now we can get to the main problem. Type a third line and try to add a newline:

...
the quick brown fox<Enter>

When the cursor is just after "fox", and the auto-suggest pop-up appears. When we type <Enter> (the key, not the word), this accepts the current selection, "fox" in the pop-up. This leaves us with:

...
the quick brown fox|

That is, we just accepted the choice "fox" and are still on the same line. We have to press <Enter> a second time to actually get a new line. This is true only when the word you just typed is one that appeared before in the document, or happens to match one of the Python suggestions. You need to type <Enter> once if the word appears for the first time, twice if the word previously appeared.

While this may be convenient for poor typists, it is frustrating for fast typists: the <Enter> is randomly ignored leaving randomly joined lines.

Suggestions

Please provide an obvious option to disable this feature. A search for "Completions" found "Python: Completions Enable" and the same for Java, but nothing for Markdown. Searching for "Intelli" found a bunch of Editor "Suggest: Show X" options such as "Show Variables". Might the Markdown editor think that words are variables? A search for "Markdown" found 41 options, but none that seem to relate to auto-completion.

When the feature is enabled, have it work all the time. (Or, conversely, when it is disabled, have it work none of the time.) Random deactivation is a bit confusing. At present, once the feature is disabled, it is disabled across all Markdown sessions in the same session. Thus caused confusion when I tried to write up the reproduction above and found that, when I created a new document, the feature had turned it self off on that document and the original one. For now, however, the workaround seems to be to wait until the feature turns itself off before doing serious typing in a Markdown document.

For those who wish to use the feature in Markdown, provide an alternative to <Enter> to select a choice so that <Enter> is always read as a newline, not as a "select the current choice" some of the time.

Finally, note that Markdown is special: it is basically text. It is not a programming language, so helping pick out code structures and variable names isn't as useful as it is in actual code editors. That said, for poor spellers, showing word from a spell-check dictionary might be helpful, but not at the cost of having to double-type <Enter>.

Details

VS Code version: Code 1.94.1 (e10f2369d0d9614a452462f2e01cdc4aa9486296, 2024-10-05T05:44:32.189Z) OS version: Linux x64 5.15.0-122-generic Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz (8 x 3926)| |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: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off| |Load (avg)|2, 2, 2| |Memory (System)|31.31GB (7.40GB free)| |Process Argv|--crash-reporter-id 5e232e7b-355a-468c-ac4a-02c300f898bd| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|cinnamon| |XDG_CURRENT_DESKTOP|X-Cinnamon| |XDG_SESSION_DESKTOP|cinnamon| |XDG_SESSION_TYPE|x11|
Extensions (22) Extension|Author (truncated)|Version ---|---|--- vscode-markdownlint|Dav|0.56.0 gitlens|eam|15.6.0 rainbow-csv|mec|3.12.0 debugpy|ms-|2024.10.0 python|ms-|2024.16.0 vscode-pylance|ms-|2024.10.1 jupyter|ms-|2024.9.1 jupyter-keymap|ms-|1.1.2 jupyter-renderers|ms-|1.0.19 vscode-jupyter-cell-tags|ms-|0.1.9 java|red|1.35.1 rewrap|stk|1.16.3 code-spell-checker|str|3.0.1 code-spell-checker-scientific-terms|str|0.2.2 intellicode-api-usage-examples|Vis|0.2.8 vscodeintellicode|Vis|1.3.1 vscode-gradle|vsc|3.16.4 vscode-java-debug|vsc|0.58.0 vscode-java-dependency|vsc|0.24.0 vscode-java-pack|vsc|0.29.0 vscode-java-test|vsc|0.42.0 vscode-maven|vsc|0.44.0
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonnoceb:30805159 asynctok:30898717 pythonmypyd1:30879173 h48ei257:31000450 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 g316j359:31013175 a69g1124:31058053 dvdeprecation:31068756 dwnewjupytercf:31046870 2f103344:31071589 impr_priority:31102340 nativerepl1:31139838 refactort:31108082 pythonrstrctxt:31112756 flighttreat:31134774 wkspc-onlycs-t:31132770 nativeloc1:31134641 wkspc-ranged-t:31151552 cf971741:31144450 defaultse:31146405 cc771715:31146322 ```
paul-rogers commented 1 week ago

Additional details. This is how the UI looks when the auto-complete feature is active in Markdown:

Screenshot from 2024-10-10 12-47-59

In my setup, the auto-complete feature is active when VS Code starts. However, as soon as I switch to another window, the feature becomes disabled. This gives us a workaround: for now, to avoid the hassle of double <Enter>, switch to another window, then back after restarting VS Code.