Skip to content

Exclude comment sections from workspace symbols by default #866

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: task/refactor-config
Choose a base branch
from

Conversation

lionel-
Copy link
Contributor

@lionel- lionel- commented Jul 7, 2025

Branched from #865.
Addresses posit-dev/positron#4886.

When a comment section like # name --- clashes with an actual symbol like name <- function() {}, whichever symbols comes first (usually the section) is included in the workspace index, and the other is ignored. Ideally we'd track both but for now we only track one identifier per file.

This causes sections to win over function definitions in cases like this:

# my_section ----

my_section <- function() {}

my_section # Reference

If you then jump to definition on a reference to that function, Positron jumps to the section instead of the function.

  • To fix this, we now allow functions and variables to overwrite sections in the indexer.

  • In addition, we no longer emit sections as workspace symbols by default. This can be turned back on with a new setting positron.r.workspaceSymbols.includeCommentSections. This is consistent with the fix in Exclude section headers from workspace symbols in R packages quarto-dev/quarto#755 where we no longer export markdown headers as workspace symbols by default, to avoid flooding workspace symbol quickpicks (# prefix in command palette) with section headers.

QA Notes

  • You should be able to command+quick on the my_section reference and be taken to the function definition rather than the section. This should be the case no matter the value of positron.r.workspaceSymbols.includeCommentSections.

  • When positron.r.workspaceSymbols.includeCommentSections is set to true, you should see comment sections in the workspace symbol quickpick. Otherwise they shouldn't be included.

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