Exclude section headers from workspace symbols in R packages #751
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 inapps/lsp
andapps/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).