quarto-dev / quarto

Quarto open-source scientific and technical publishing system
https://quarto.org
GNU Affero General Public License v3.0
336 stars 29 forks source link

Positron's help panel is not used when F1 is invoked #580

Open andrewheiss opened 1 week ago

andrewheiss commented 1 week ago

Currently, in VS Code, pressing F1 inside a function name opens the documentation in a special "Quarto: Help" panel in the File Explorer:

Image

That's great when using VS Code because it doesn't have a dedicated help panel like RStudio does.

However, in the spirit of RStudio, Positron does have a dedicated help panel—when pressing F1 in a regular R script in Positron, the documentation opens there:

Image

When pressing F1 in a Quarto file in Positron, though, nothing happens in the Positron help panel. Instead, the documentation appears in the custom Quarto help panel:

Image

There's an issue at Positron tracking this: https://github.com/posit-dev/positron/issues/4097 and it's part of a larger push for better Quarto improvements (https://github.com/posit-dev/positron/issues/4858). I figured that F1 wasn't doing anything at all (I'd forgotten about Quarto's custom help panel), and others likely thought the same, but a recent comment https://github.com/posit-dev/positron/issues/4097#issuecomment-2427178059 discovered that F1 is actually working as expected in Positron—it's just invisible if the custom Quarto help panel is hidden.

So the underlying issue seems to be that Quarto's VS Code extension is hijacking F1 inside Positron

juliasilge commented 1 day ago

It turns out this is the quarto-assist webview the Quarto extension contributes; it can be pinned/unpinned with commands quarto.assist.pin and quarto.assist.unpin. There are three kinds of things that can get rendered in this webview:

https://github.com/quarto-dev/quarto/blob/227af7814a1e42737383ed4ce361242c36504dad/apps/vscode/src/providers/assist/render-assist.ts#L43-L45

Once you get this webview going, it responds to where your cursor is and renders things for you, depending on whether it is an equation, a function etc. The Help does not seem to work for Python for me, and I have not found a pydoc server or anything like that.

One option would be to turn this webview off in Positron and hook up F1 to calling Positron's Help; it does seem like most use of it is for Help from the issues about it. Or I guess we can pipe through F1 to Positron's Help without messing with this at all, and they both would be available.

Real talk: I had never pulled up this webview until starting to look into this today.

juliasilge commented 1 day ago

The command in Positron is positron.help.showHelpAtCursor here: https://github.com/posit-dev/positron/blob/465058d309f13331ba2f458f8e99e6d5eeaea541/src/vs/workbench/contrib/positronHelp/browser/positronHelpActions.ts#L32

The command goes to a help topic provider that is a languageFeaturesService which I guess is different from a languageFeaturesRegistry (what the statement range provider is); still we'll probably need something along the lines of https://github.com/posit-dev/positron/pull/3107/ in Positron to pipe it through.