Too many auto import quick fixes returned #3873
Replies: 19 comments 27 replies
-
Is there a set of filters you would want to apply? It's only filtering on the letter 'a' and everything that matches. However, you can control the set of things we index with these settings here: Something like so would eliminate everything except say django: "python.analysis.packageIndexDepths": [
{
"name": "", // This entry turns off symbols for everything
"depth": 0,
"includeAllSymbols": false
},
{
"name": "django", // This adds it back for just django
"depth": 4,
"includeAllSymbols": true
}
], |
Beta Was this translation helpful? Give feedback.
-
Are you suggesting we shouldn't use fuzzy matching on auto import? or wait for more characters? |
Beta Was this translation helpful? Give feedback.
-
The number of actions returned is overwhelming (and none of them are what I want) which makes the UX pretty poor Could you filter by symbols that are a small edit distance from an actual symbol name instead of showing every possible match? Right now it feels like the quick fixes are being used more like how IntelliSense suggestions work |
Beta Was this translation helpful? Give feedback.
-
Maybe two characters would be better. Don't show it for one. @mjbvz what would the list look like if it was symbols that were a small distance apart? Everything in your list seems like it has something that starts with a lower case 'a'. |
Beta Was this translation helpful? Give feedback.
-
Quick fixes are meant to show high confidence fixes for problems in the code. If I want to import For the quick fixes, JS/TS only shows import quick fixes for exact symbol matches. We've never had complaints about this (again likely because auto import completions handle the fuzzy case) If this is too restrictive for some reason, you could return auto import quick fixes for symbols that a very short Levenshtein distance away from the target symbol. As in, like 1 or two missing/transposed characters |
Beta Was this translation helpful? Give feedback.
-
I guess we can move it to discussion and gather users' opinions on filtering logics. current logic is simple, max 2 char apart fuzzy matching. more inputs (the word ... That being said, unfortunately, python is not designed ground up IDE in mind, so its IDE supports can't be as nice as such languages, such as TS, C# and more. languages that are created with IDE support in mind usually encode some data in language syntax or configuration to make IDE support easier. python puts those data in documentation (and no one standard) where it is hard for machine to extract those data. probably that is the reason why there is so many AI projects to help python programming. For an example, unlike typescript which has but python IDE can't. so, we can either add heuristic to reduce suggestions (which always has its own throwback) or show all possibilities with a way to reduce them. for now, we took the latter approach. If there is better way, we are always open to a suggestion. |
Beta Was this translation helpful? Give feedback.
-
It seems like it's comparing prefixes then because otherwise The suggest UI in editors like VS Code is designed specifically for this type fuzzy, prefix based matching. The quick fix UI should not be used for this though and I'm concerned it will teach users to think of quick fixes as a smarter version of the suggestion widget |
Beta Was this translation helpful? Give feedback.
-
We could make this list more relevant by checking packages that are listed in requirements.txt and pyproject.toml |
Beta Was this translation helpful? Give feedback.
-
That sounds like it may help but please still consider filtering the list to only show high confidence fixes |
Beta Was this translation helpful? Give feedback.
-
let's discuss it on the discussion. the worry I have on making the match over the entire symbol is some users don't write out whole word (many times they don't remember whole symbol name). and the filtering is no longer predictable. as user writes more characters, new suggestions will be shown when invoked. making it a guessing game. I think one way we can try before changing filtering logic is trying to reduce candidate modules using things lke |
Beta Was this translation helpful? Give feedback.
-
I hit this writing real python code. If you have an unresolved name in a python file, you get a red squiggle. If you then place the cursor on the red squiggle, you get a lightbulb suggesting that a fix is available. Triggering quick fixes often then shows an overwhelming list of suggestions. This list is so long that I can't find the handful of actual useful suggestions in the list You get similar behavior for common variable names such as Or |
Beta Was this translation helpful? Give feedback.
-
I think the key thing to consider for this situation is what would happen if there were two other language servers came in with the same number of entries for the same thing and had them placed before Pylance's? Would that facilitate finding the appropriate answer that Pylance may have, or would it hinder the user's search for the right answer? After discussing this issue on the VS Code side we realized we need to update the extension guidelines to mention suggesting having more like 10 or less suggestions and to use heuristics when necessary to shorten the list as there isn't any public guidance on this topic. If you're starting from a data-starved scenario like a single letter you could scrape GitHub to calculate import frequencies since chances are that aligns with what people want. We also realized people could lean on something like Copilot to help figure out what they may want when starting with less information. |
Beta Was this translation helpful? Give feedback.
-
@brettcannon Design guidelines for code action likely belongs in the LSP spec, since I believe this is what Pylance targets Here's what the LSP spec on code action requests already says:
We try not to make our API guidance too proscriptive so as not to limit creative new uses cases. However the relevant points for this example are:
|
Beta Was this translation helpful? Give feedback.
-
I am perplexed about the lack of learning ability in QuickFix imports. While you might import for stdlib or same place for hundreds of times, it still fails to learn from previous actions and gives an alphabetically listed list of... mistakes. One of the most annoying suggestions being on |
Beta Was this translation helpful? Give feedback.
-
@ssbarnea, If you open an issue describing behavior you want more in detail, we can certainly discuss about it. we recently made a change on sorting - #3760 - on completion. I think we didn't make the same ordering on code action. but we can certainly do that if more people want that. |
Beta Was this translation helpful? Give feedback.
-
One of the suggestions I had in #4968 was to leverage nesting in the quick fix menu.
That said, I do agree with the sentiment at #3873 (comment) |
Beta Was this translation helpful? Give feedback.
-
Revisiting this since some users have been running into it and it hangs with the excessive code actions (microsoft/vscode#196857) . A quick solution for now is to limit the maximum number of code actions, which is being done in this PR. The top 50 non-AI code actions will be shown, with AI quick fixes at the bottom of the list. Code actions are already sorted prior to this @heejaechang do you have any thoughts on this. |
Beta Was this translation helpful? Give feedback.
-
We're going to address #5226 as a solution to this problem |
Beta Was this translation helpful? Give feedback.
-
Closing as this has been addressed by #5226 |
Beta Was this translation helpful? Give feedback.
-
Type: Bug
a
Bug
I get tons quick fixes for importing what seems like every possible package
Extension version: 2023.1.41
VS Code version: Code - Insiders 1.75.0-insider (Universal) (270c3b12906a88e9c67fc5ddef87be6aa3b75551, 2023-01-25T05:23:34.922Z)
OS version: Darwin x64 22.2.0
Modes:
Sandboxed: Yes
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Beta Was this translation helpful? Give feedback.
All reactions