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

VSCode cannot jump to the result file row if got results too fast from vscode-msr + VsCode cannot de-duplicate results correctly #96754

Closed
lqm678 opened this issue May 1, 2020 · 17 comments
Assignees
Labels
editor-symbols definitions, declarations, references info-needed Issue requires more information from poster

Comments

@lqm678
Copy link

lqm678 commented May 1, 2020

  • VSCode Version: 1.44.2
  • OS Version: Window 10 Enterprise 1909 build 18363.778

Issue summary

  • vscode cannot correctly de-duplicate results of Go To Definition from 2 definition providers.
  • vscode cannot correctly de-duplicate results of Find All References from 2 providers.
  • vscode cannot correctly jump to the definition location + progress bar keeps moving, if has 2+ definition providers, when vscode-msr found the definition while other official/professional extensions not found it:

Steps to Reproduce:

  1. Install a tiny vscode extension: vscode-msr (less than 1 minute, about 1.6MB)
  2. To fast verify it: Open a small project (or a sub-folder) to let vscode-msr can find results in 3~50 milliseconds. ( I just cloned vscode-python and reproduced this issue as screenshot below)
  3. Test "Go To Definition" (Press F12 or menu Go To Definition) for a function or method in a code/script file like C#/Python/C++/Java/Powershell etc.
  4. Test "Find All Reference" for a function or method etc.

See my test screenshot below with just cloned vscode-python source code to test:

  • File path: pythonFiles/install_debugpy.py
  • Test finding: _download_and_extract + DEBUGGER_DEST

Additionally:

  • You can uncheck msr.quiet in User settings to auto show searching info each time in MSR-Def-Ref channel in OUTPUT tab.
  • You can press Alt+F2 (or press F1 -> msr toggle enable finding) to temporarily enable or disable vscode-msr finding definition.

Does this issue occur when all extensions are disabled?: No -> after I disabled only the corresponding language extension (like vscode-python in my test case)

1. Cannot jump to the location of only one result, progress bar keeps moving:

image

2.Cannot de-duplicate correctly for results of Go To Definition :

image

3. Also got duplicate results of Find Alll References:

This time the bug location is much obvious to start tracing at here: CommandsConverter#CREATE
image

@lqm678 lqm678 changed the title VSCode cannot jump to the result file row if got results too fast from an extension (vscode-msr) VSCode cannot jump to the result file row if got results too fast May 1, 2020
@lqm678 lqm678 changed the title VSCode cannot jump to the result file row if got results too fast VSCode cannot jump to the result file row if got results too fast from vscode-msr May 1, 2020
@jrieken jrieken added editor-symbols definitions, declarations, references info-needed Issue requires more information from poster labels May 1, 2020
@jrieken
Copy link
Member

jrieken commented May 1, 2020

Are you sure that you are the only definition provider? Check by disabling all other extensions or do "F1 > Log Level > Trace" and the check the extension host log for all providers that are being invoked

@lqm678
Copy link
Author

lqm678 commented May 1, 2020

@jrieken: Thanks so much for your reply! As mentioned above: The issue doesn't occur after I disabled only the corresponding language extension (like vscode-python in my test case)
But users should not disable the language extension (like vscode-python , powershell etc.) as they're official + professional extensions.

@lqm678
Copy link
Author

lqm678 commented May 1, 2020

This seems to be: vscode doesn't coordinate well for multiple definition providers.

What's more, vscode should de-duplicate results: I often found duplicate results were found and vscode prompts a choosing-result-window. But in fact, the results (often 2 results since 2 definition providers) are the same: same file path + same row.

@lqm678
Copy link
Author

lqm678 commented May 2, 2020

@jrieken Just normally wake up now:) Explicitly answer:

1. The issue of finding definition and vscode failed to jump to the location :

  • When vscode-msr got 1 and correct results of definition, but the official/professional language extensions (vscode-python or powershell) don't, vscode doesnt' jump to the file location.
  • No result nor any response if disabled vscode-msr at that circumstance.
  • The issue doesn't always happen, only if vscode-msr got results + official extensions not + vscode-msr got results too fast (in X miliseconds).

2. Not the only definition provider, vscode-msr usually works with one or more official or professional definition provider. For example:

  • Python: I think most people installed vscode-python on their vscode.
  • Powershell: Samely, people installs ms-vscode.PowerShell.
  • And so is it for other languages like C# , C/C++, Java etc.

3. the vscode-msr often get the results while the official/professional extensions don't -- this is just the reason why vscode-msr was written, and it is supposed to be work with many other official/profession language extensions to provide the Best Combined Power + other features for users.

4. I tried to disable all the other extensions, and the issue doesn't occur), I just disabled the official or profession providers and issue disappeared:

  • Disable the vscode-python when finding a Python function/class definition.
  • Disable the vscode-powershell when finding a PowerShell function/class definition.

5. Tracing extension logs with log level = trace (reloaded vscode) when the issue happens:

  • No new logs for vscode-python / ms-vscode.powershell in all channels that has prefix of python or powershell on OUTPUT tab.

  • Found related log in Log(Extension Host):
    [2020-05-02 10:11:54.322] [exthost] [trace] [ms-python.python] INVOKE provider 'S'
    [2020-05-02 10:11:55.119] [exthost] [trace] [ms-python.python] INVOKE provider 'E'
    [2020-05-02 10:11:55.119] [exthost] [trace] [qualiu.vscode-msr] INVOKE provider 'E'
    [2020-05-02 10:11:55.292] [exthost] [trace] [qualiu.vscode-msr] provider DONE after 172ms
    [2020-05-02 10:12:09.241] [exthost] [trace] ExtHostCommands#executeCommand setContext
    [2020-05-02 10:12:09.241] [exthost] [trace] ExtHostCommands#executeCommand setContext
    [2020-05-02 10:12:09.241] [exthost] [trace] ExtHostCommands#executeCommand setContext
    [2020-05-02 10:12:24.254] [exthost] [trace] ProxyResolver#resolveProxy cached https://vortex.data.microsoft.com/collect/v1 DIRECT
    image

  • For each language, I think vscode should works well and coordinate well if one extension returns results, even if some extensions may got problems.

6. For multiple extensions of one language, does vscode wait for all extensions(providers) to return results?

  • If true, what's the waiting logic, using timeout? Will be the root cause is that the official extension return no result and too fast or no response in a long time?

@jrieken
Copy link
Member

jrieken commented May 4, 2020

Yes, VS Code waits for all providers to return their results then shows a merged view. That's done because all providers are equal and because any timeout-value would be totally arbitrary and very likely not transport well to other machines (as hardware specs differ). Waiting for all results is done because we don't want to update the results as they come in, e.g. we need to know if there is just one result or multiple because the UX behaves different. We also want to provide a stable UI that doesn't change after it shows.

I assume that your extension uses some text-search/index based approach that puts speed over correctness. That's fair but you will always compete with "semantic" language services. My only recommendation is to approach those extensions and ask them to add a setting that allows users to enable/disable their definition etc providers. Consequently, your extension should do the same

@lqm678
Copy link
Author

lqm678 commented May 4, 2020

@jrieken Thanks for your profound answer! I understood the waiting logic for all results from all definition providers (extensions) and also the tough work.
And it's true that my extension vscode-msr is a simple text-search tool, often as an independent tool (good enough for no-same-name functions/methods/classes) or as a supplementary tool to those sematic (official or professional) extensions like vscode-python and ms-vscode.PowerShell etc. especially when they often caught problems + inherent drawbacks that unable to solve.

In brief:

1. My extension (vscode-msr) already provided several switches to disable/enable finding definitions or references: Every function is under users' control.

2. How to solve the issue of unable to jump to the definition when 1 extension got results.

  • I agree that it'll be helpful if those official/professional extensions should provide a switch to disable/enable finding definition (Seems just disable the extensions, already have).
  • But still and personally, I think the problem should be fixed by vscode itself:
    • It's in essense a result merging + de-duplicating work and so on.
    • The interface exposed from vscode API doesn't provide the ability to further process it.
  • And it's not a good design to put down the final result processing work into every extension.

3.Summary: I'd like to suggest that vscode should solve the final result processing work:

  • Like merging and de-duplicating etc.
  • And to be robust to fix problems like one or more extension caught problems or unable to get results, or even unable to response.
    (For this issue case: vscode-python and ms-vscode.PowerShell unable to get results and vscode progess-bar keep moving as shown in the screenshot on top).

@jrieken
Copy link
Member

jrieken commented May 4, 2020

Like merging and de-duplicating etc.

We do that. Check out this:

if (current.children.length === 0 || !Range.equalsRange(link.range, current.children[current.children.length - 1].range)) {
. Any more information why this isn't working for you?

fix problems like one or more extension caught problems or unable to get results, or even unable to response.

You will need to file issues against those extensions

@lqm678
Copy link
Author

lqm678 commented May 4, 2020

Thanks so much for such a quick reply! But take care of your body (guess late night or too early~~)
Good to know that.
But I often found duplicate result problems over 8 months. See screenshot below:
Still used vscode-python source code file: pythonFiles/install_debugpy.py to test finding defintion of _download_and_extract
image

@lqm678
Copy link
Author

lqm678 commented May 5, 2020

Add extension host tracing level log of duplicate defintion results:
Still used vscode-python source code file: pythonFiles/install_debugpy.py to test finding definition of _download_and_extract

image

@lqm678
Copy link
Author

lqm678 commented May 5, 2020

After I disabled the official extension ms-python.python, only keep vscode-msr for python, no longer got duplicate results. (I checked and disabled all other extensions named python-xxx)

So the conclusion is clear that:

  • vscode cannot correctly de-duplicate results from 2 definition providers in this case at least.
  • vscode cannot correctly jump to the definition location if has 2 definition providers:
    • Like vscode-msr + ms-python.python for Python sometimes (ms-python.python may got problems)
    • Like vscode-msr + ms-vscode.PowerShell for Powershell sometimes (ms-vscode.PowerShell may got problems)

It's easy to verify them:
Use vscode-python source code file: pythonFiles/install_debugpy.py to test finding the definition of _download_and_extract

@lqm678 lqm678 changed the title VSCode cannot jump to the result file row if got results too fast from vscode-msr VSCode cannot jump to the result file row if got results too fast from vscode-msr + VsCode cannot de-duplicate results correctly May 5, 2020
@lqm678
Copy link
Author

lqm678 commented May 5, 2020

Updated the issue summary and detail on top.

Add screenshot: Duplicate results of Find All References:
image

lqm678 added a commit to qualiu/vscode-msr that referenced this issue May 16, 2020
- Support adding new languages with it's mapped-extension + extension list.
- Search current file at first to fast get results of definition.
- Add highest score for current file to keep 1 result when finding definition.
- Add skip pattern for PowerShell when use `Regex find definition in current file`.
- Add `open-doskeys` command shortcut on Windows.
- Support finding definition in `batch` files (`*.bat` + `*.cmd`).
- Increased max line character count from 260 to 360 when call `Regex finding pure reference`.
- Enabled `Sorting by time/size` command platte for `project files` or `all files includes extra search paths`.
- Add long existing [VsCode Bug](microsoft/vscode#96754): Unable to jump to definitions sometimes + Duplicate definition + reference results.
lqm678 added a commit to qualiu/vscode-msr that referenced this issue May 16, 2020
- Support adding new languages with it's mapped-extension + extension list.
- Search current file at first to fast get results of definition.
- Add highest score for current file to keep 1 result when finding definition.
- Add skip pattern for PowerShell when use `Regex find definition in current file`.
- Add `open-doskeys` command shortcut on Windows.
- Support finding definition in `batch` files (`*.bat` + `*.cmd`).
- Increased max line character count from 260 to 360 when call `Regex finding pure reference`.
- Enabled `Sorting by time/size` command platte for `project files` or `all files includes extra search paths`.
- Add long existing [VsCode Bug](microsoft/vscode#96754): Unable to jump to definitions sometimes + Duplicate definition + reference results.
lqm678 added a commit to qualiu/vscode-msr that referenced this issue May 16, 2020
- Support adding new languages with it's mapped-extension + extension list.
- Search current file at first to fast get results of definition.
- Add highest score for current file to keep 1 result when finding definition.
- Add skip pattern for PowerShell when use `Regex find definition in current file`.
- Add `open-doskeys` command shortcut on Windows.
- Support finding definition in `batch` files (`*.bat` + `*.cmd`).
- Increased max line character count from 260 to 360 when call `Regex finding pure reference`.
- Enabled `Sorting by time/size` command platte for `project files` or `all files includes extra search paths`.
- Add long existing [VsCode Bug](microsoft/vscode#96754): Unable to jump to definitions sometimes + Duplicate definition + reference results.
lqm678 added a commit to qualiu/vscode-msr that referenced this issue May 16, 2020
- Support adding new languages with it's mapped-extension + extension list.
- Search current file at first to fast get results of definition.
- Add highest score for current file to keep 1 result when finding definition.
- Add skip pattern for PowerShell when use `Regex find definition in current file`.
- Add `open-doskeys` command shortcut on Windows.
- Support finding definition in `batch` files (`*.bat` + `*.cmd`).
- Increased max line character count from 260 to 360 when call `Regex finding pure reference`.
- Enabled `Sorting by time/size` command platte for `project files` or `all files includes extra search paths`.
- Add long existing [VsCode Bug](microsoft/vscode#96754): Unable to jump to definitions sometimes + Duplicate definition + reference results.
lqm678 added a commit to qualiu/vscode-msr that referenced this issue May 16, 2020
- Support adding new languages with it's mapped-extension + extension list.
- Search current file at first to fast get results of definition.
- Add highest score for current file to keep 1 result when finding definition.
- Add skip pattern for PowerShell when use `Regex find definition in current file`.
- Add `open-doskeys` command shortcut on Windows.
- Support finding definition in `batch` files (`*.bat` + `*.cmd`).
- Increased max line character count from 260 to 360 when call `Regex finding pure reference`.
- Enabled `Sorting by time/size` command platte for `project files` or `all files includes extra search paths`.
- Add long existing [VsCode Bug](microsoft/vscode#96754): Unable to jump to definitions sometimes + Duplicate definition + reference results.
lqm678 added a commit to qualiu/vscode-msr that referenced this issue May 16, 2020
- Support adding new languages with it's mapped-extension + extension list.
- Search current file at first to fast get results of definition.
- Add highest score for current file to keep 1 result when finding definition.
- Add skip pattern for PowerShell when use `Regex find definition in current file`.
- Add `open-doskeys` command shortcut on Windows.
- Support finding definition in `batch` files (`*.bat` + `*.cmd`).
- Increased max line character count from 260 to 360 when call `Regex finding pure reference`.
- Enabled `Sorting by time/size` command platte for `project files` or `all files includes extra search paths`.
- Add long existing [VsCode Bug](microsoft/vscode#96754): Unable to jump to definitions sometimes + Duplicate definition + reference results.
lqm678 added a commit to qualiu/vscode-msr that referenced this issue May 16, 2020
- Supported adding new languages with it's mapped-extension + extension list.
- Search current file at first to fast get results of definition.
- Added highest score for current file to keep 1 result when finding definition.
- Added skip pattern for PowerShell when use `Regex find definition in current file`.
- Added `open-doskeys` command shortcut on Windows.
- Supported finding definition in `batch` files (`*.bat` + `*.cmd`).
- Increased max line character count from 260 to 360 when call `Regex finding pure reference`.
- Enabled `Sorting by time/size` command palette for `project files: code + config + doc` or `all files`.
- Added long existing [VsCode Bug](microsoft/vscode#96754): Unable to jump to definitions sometimes + Duplicate definition + reference results.
lqm678 added a commit to qualiu/vscode-msr that referenced this issue May 16, 2020
- Supported adding new languages with it's mapped-extension + extension list.
- Search current file at first to fast get results of definition.
- Added highest score for current file to keep 1 result when finding definition.
- Added skip pattern for PowerShell when use `Regex find definition in current file`.
- Added `open-doskeys` command shortcut on Windows.
- Supported finding definition in `batch` files (`*.bat` + `*.cmd`).
- Increased max line character count from 260 to 360 when call `Regex finding pure reference`.
- Enabled `Sorting by time/size` command palette for `project files: code + config + doc` or `all files`.
- Added long existing [VsCode Bug](microsoft/vscode#96754): Unable to jump to definitions sometimes + Duplicate definition + reference results.
@lqm678
Copy link
Author

lqm678 commented Aug 13, 2020

The problem still exists.

@lqm678
Copy link
Author

lqm678 commented Aug 13, 2020

All info with screenshots on the top box (needless to scroll down), easy to reproduce.

@jrieken
Copy link
Member

jrieken commented Aug 13, 2020

The results are different - despite selecting the same line they aren't on the exact same ranges.

@jrieken jrieken closed this as completed Aug 13, 2020
@lqm678
Copy link
Author

lqm678 commented Aug 13, 2020

@jrieken: I guess your reply is only for duplicate results bug, how about the "Unable to jump to the definition and hanging" bug?

@jrieken
Copy link
Member

jrieken commented Aug 13, 2020

1 issue, 1 topic please

@github-actions github-actions bot locked and limited conversation to collaborators Sep 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-symbols definitions, declarations, references info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

3 participants
@jrieken @lqm678 and others