microsoft / vscode

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

TypeScript and intellisense often randomly opens with "if" snippet selected ignoring any properties #77453

Open lloydjatkinson opened 5 years ago

lloydjatkinson commented 5 years ago

Issue Type: Bug

Declare an interface with some properties. Create a function with parameter type of that interface.

Call function with object declared inside function call. Press CTRL + SPACE and note how usually the intellisense prompt will open approximately half way through the options with the "if" snippet selected. The user then has to manually scroll to the top of the list in order to see the properties expected.

interface Something {
    propertyOne: any,
    propertyTwo: any,
};

const someFunction = (something: Something) => {};

someFunction({ <focus here and press CTRL + SPACE> });

image

The user then has to scroll to the top:

image

I suggest that the intellisense menu scrolls to the very top always (why is it currently in the middle, for example). TypeScript has already inferred what properties are available, so it should be a case of fixing the default selected item in the intellisense menu.

VS Code version: Code 1.36.1 (2213894ea0415ee8c85c5eea0d0ff81ecc191529, 2019-07-08T22:59:35.033Z) OS version: Windows_NT x64 10.0.18362

System Info |Item|Value| |---|---| |CPUs|Intel(R) Xeon(R) CPU E5-1650 v4 @ 3.60GHz (12 x 3592)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
oop_rasterization: unavailable_off
protected_video_decode: unavailable_off
rasterization: unavailable_off
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|15.92GB (4.16GB free)| |Process Argv|--folder-uri |Screen Reader|no| |VM|0%|
Extensions (26) Extension|Author (truncated)|Version ---|---|--- Bookmarks|ale|10.4.4 simple-react-snippets|bur|1.2.2 npm-intellisense|chr|1.3.0 path-intellisense|chr|1.4.2 bracket-pair-colorizer-2|Coe|0.0.28 prettier-vscode|esb|1.9.0 auto-close-tag|for|0.5.6 auto-rename-tag|for|0.1.0 vscode-react-typescript|inf|1.3.0 vscode-peacock|joh|2.4.0 TypeScriptImport|kev|1.17.0 rainbow-csv|mec|1.1.1 vscode-less|mrm|0.6.3 azure-account|ms-|0.8.4 vscode-typescript-tslint-plugin|ms-|1.2.2 vetur|oct|0.21.1 vue-vscode-extensionpack|sdr|0.2.0 vue-vscode-snippets|sdr|1.7.1 ayu|tea|0.18.0 vscode-status-bar-format-toggle|tom|1.5.0 terminal-tabs|Tyr|0.2.0 highlight-matching-tag|vin|0.9.2 WebTemplateStudio-dev-nightly|WAS|0.0.1919601 vscode-import-cost|wix|2.12.0 vscode-jumpy|wma|0.3.1 JavaScriptSnippets|xab|1.7.2 (1 theme extensions excluded)
ffxsam commented 5 years ago

I can replicate this too. And actually, I noticed that if I start with this:

someFunction({ | }) // the pipe is the cursor

and hit ctrl+space, it shows way too much stuff and has the relevant properties at the top (but you have to scroll to get there).

However, if I start with this:

someFunction({|})

and hit ctrl+space, it behaves as expected:

image

So when there's no space before the cursor, it works fine. Seems like VS Code should be internally trimming for spaces, then, when determining what to autosuggest.

lloydjatkinson commented 5 years ago

I can also reproduce this in .tsx files too.

jrieken commented 5 years ago

@lloydjatkinson Do you have the editor.snippetSuggestions-setting configured?

This is because of the editor.suggestSelection-setting. The default is to preselect the least recent used item (unless any other item is selected). You can change the value of that setting to first to get out of this, not sure how to make the default better tho...

lloydjatkinson commented 5 years ago

Sseems like a bug to me. Should first be default? If intellisense is being affected by white space then it seems the real fix is more than changing the settings.

ffxsam commented 5 years ago

Nice! That definitely helps, but auto-suggest still suggests a bunch of stuff that's irrelevant.

image

image

ffxsam commented 5 years ago

Also agree with @lloydjatkinson, "first" ought to be the default. The other default behavior is disorienting. And there's still a bug here regarding how auto-suggest behaves when whitespace is added.

OliverJAsh commented 3 years ago

I made a few suggestions here: https://github.com/microsoft/vscode/issues/122515#:~:text=To%20address,Disable

[…] the suggestion is at the top of the list and the list has been scrolled down to the recently used suggestion.

However, this is really not obvious, especially considering the scroll bar is so discrete and disappears completely after a few seconds. The user might not even realise the list has been scrolled down.

To address this, I would like to suggest a few things. Ideally these suggestions would alter the default behaviour, since this is an accessibility issue, but at the very least they could be configured using new settings.

  • Disable fading scroll bars inside of the suggestions list. Related: #35454
  • When the selected suggestion isn't at the top of the list but is close to the top, keep the list scrolled to the top when it's opened rather than scrolling down to the selected suggestion. Note this isn't the same thing as "editor.suggestSelection": "first" because that changes the suggested selection.
  • When determining the suggestion to select by default, give IntelliSense suggestions higher priority than recently used. We already have a editor.suggestSelection setting but it doesn't have an option for this.