Skip to content

Exclude section headers from workspace symbols in R packages #755

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

Open
wants to merge 2 commits into
base: feature/lsp-logger
Choose a base branch
from

Conversation

lionel-
Copy link
Collaborator

@lionel- lionel- commented Jul 7, 2025

(This reopens #751 after a weird auto-merge, sorry for any confusion.)

Branched from #750.
Addresses posit-dev/positron#8401.

Once activated, the Quarto extension currently scans all md files and exports section headers to workspace symbols. While great generally, this can get in the way of the dev workflow in R packages.

R packages may include a variety of md files:

This causes Quarto to flood workspace symbols with headers that are mostly irrelevant for package development:

Screen.Recording.2025-07-03.at.15.25.47.mov

I think by default (without any user configuration), headers shouldn't be exported as workspace symbols in R packages. But we need to preserve the existing behaviour for other projects.

To fix this, this PR:

  • Introduces a new setting quarto.symbols.exportToWorkspace, with values "default", "all", or "none". We need an enum with a default case instead of a boolean to provide the default behaviour that depends on the project type. The other two values allow hardcoding the behaviour in a project.

  • When set to "default", the LSP detects if the project is an R package.

    While the LSP would ideally be agnostic regarding the project type, having a customisation mechanism for extensions to set the default behaviour for a project would be complicated and require conflict solving if two extensions try to handle the same project.

  • We already have a tool to detect R packages in the extension module (thanks to @juliasilge to have let me know!). It's a bit complicated because we need to parse the project's DESCRIPTION file if present, so I think we need to use the same implementation in both the LSP and extension. I pulled it up one level in apps/utils. To keep things light I didn't make it a full node module.

  • The tool in apps/utils take a folder path. Then two wrappers in apps/lsp and apps/vscode are in charge of unpacking the relevant workspace folder (via different APIs specific to the LSP and extension) and calling the util.

QA Notes

Create an R package with markdown files and make sure the Quarto extension is activated (it activates when navigating to an R file). Look for workspace symbols (cmd T, or # prefix in command palette). The markdown headers shouldn't be included.

In a project that's not an R package, they should be included.

In the R package you can opt into including the headers via quarto.symbols.exportToWorkspace. In the regular project you can disable them. The setting should immediately apply (at the next request).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant