-
Notifications
You must be signed in to change notification settings - Fork 45
Debug: log to show difference in vscode.executeCompletionItemProvider in vscode vs Positron
#777
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
Conversation
…returns differently in vscode and Positron
| // if (hasHooks()) { | ||
| // return { | ||
| // items: [], | ||
| // isIncomplete: false | ||
| // }; | ||
| // } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For debugging purposes: re-enable completions in the visual editor in Positron
| console.log('getCompletions', completions, [...completions.items]) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| parentUri: Uri | ||
| ) { | ||
| const completions = await withVirtualDocUri(vdoc, parentUri, "completion", async (uri: Uri) => { | ||
| console.log('vdocCompletions vdoc uri, adjustedPosition, trigger', uri, adjustedPosition(language, position), trigger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is right before the place where the the visual editor calls a vscode command to gets its completions for Python and R. Let's log out all the arguments to the command.
I looked at this log during a test where I ran an extension host in both vscode and Positron. In an R block in a .qmd, I tried typing lib to get completions.
Here is the log in the debug console in vscode:

Here is the log in the debug console in Positron:

I opened the vdoc in the file system and in both cases it was an r file with lib as the content. I did wc -l to see if there was differences in new lines and there weren't.
In both cases these were logged to have the same values. So... the arguments to the following command seem to be the same in both Positron and vscode.
| trigger | ||
| ); | ||
| }); | ||
| console.log('completions!!!', completions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vscode.executeCompletionItemProvider between vscode and Positronvscode.executeCompletionItemProvider in vscode vs Positron
|
I do also see that the |
|
When I was testing in Positron, I believe I noticed that no matter what the contents of the R language virtual doc were, This seems to be strong evidence that there is a bug outside of Quarto extension code (a bug that is present in Positron but not VScode) that lead to this degradation of quality of completions in the Visual Editor. It may be possible to work around this bug in the Quarto extension by further refining the ranking and filtering code in |
|
I set up my many-windows-open-at-once debugging situation today 😆 to dig into this in more detail. I think it may be easier to use a Python example because then we don't get distracted by the R completion model, and to see the differences between the source and visual editor. Here are some screenshots to get us started: Source editor
Underlying virtual doc for the source editor
Visual editor
Underlying virtual doc for the visual editor
I did some extensive walking through of various scenarios, and I can confirm that:
To me, it looks pretty clear that the differences are happening in the visual editor itself, what you mention here in #777 (comment):
|
|
We will get different completions in VS Code than in Positron because the underlying LSP is different, and providing different things. |
|
You might want to change your VS Code setup to use Jedi instead of Pylance for Python, for a better comparison. |
Thanks @juliasilge, this cleared up a lot for me!: I changed my VSCode Python Language Server to Jedi and tested again. Now I get very similar, if not the same, results as in Positron (and similar, if not the same, completions data). Using Jedi in VSCode, both Positron and VSCode present similar "good" completions in source mode, and present similar "bad" completions in visual mode. Awesome! I finally feel like I understand where the differences in completions between VSCode and Positron were coming from (they were coming from different completions data, which came from different language servers); and as a result of clearing that up (and ignoring the arc stuff for now), I now see the essential issue isolated to the extension's sorting and/or filtering. Regarding
I suppose we don't have to get to the bottom of which of these two possibilities is the. case. Though if the source editor does have magic sorting, it would be really nice to be informed by that magic! I'm sure we could already improve the sorting quite a bit without being informed though. |
|
|
After going over all this information with @juliasilge (also see posit-dev/ark#900), we have arrived at a plan for a solution to the problem of completions not being properly sorted and filtered in the VE in Positron (we now know it affects Jedi users in VSCode as well). I will try copying&pasting from what seems to be the code where the source editor sorts completions. This will give consistency between the source editor and the visual editor; it will respect the LSP spec which says completion sorting and filtering should be handled by the client; it adds a maintenance burden (if the source editor sorting/filtering does change and we want the visual editor to remain consistent with it). |











Please see the comments on the modified code in this PR.