Exclude comment sections from workspace symbols by default #866
+54
−17
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.
Branched from #865.
Addresses posit-dev/positron#4886.
When a comment section like
# name ---
clashes with an actual symbol likename <- 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:
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 ofpositron.r.workspaceSymbols.includeCommentSections
.When
positron.r.workspaceSymbols.includeCommentSections
is set totrue
, you should see comment sections in the workspace symbol quickpick. Otherwise they shouldn't be included.