-
Notifications
You must be signed in to change notification settings - Fork 17
Don't emit nested objects as document symbols #859
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
base: feature/method-symbols
Are you sure you want to change the base?
Conversation
698f1a3
to
f67b10f
Compare
5e3988d
to
a4f5a00
Compare
// Otherwise, collect as generic object | ||
let name = contents.node_slice(&lhs)?.to_string(); | ||
if ctx.top_level || ctx.include_assignments_in_blocks { | ||
// Collect as generic object, but only if we're at top-level. Assigned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Collect as generic object, but only if we're at top-level. Assigned | |
// Collect as generic object, but typically only if we're at top-level. Assigned |
foo.detail = Some(String::from("function()")); | ||
|
||
assert_eq!(test_symbol("foo <- function() { bar <- 1 }"), vec![foo]); | ||
insta::assert_debug_snapshot!(test_symbol("foo <- function() { bar <- function() 1 }")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be worth also having a snapshot test that sets include_assignments_in_blocks
to true
if you can easily expose that toggle
// Assigned variables in nested contexts are not emitted as symbols | ||
fn test_symbol_nested_assignments() { | ||
insta::assert_debug_snapshot!(test_symbol( | ||
" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And, to be super clear, at top level we do want assigned variables to be treated as symbols?
I honestly don't think that sounds super useful either
Like, a 300 line R script is bound to have a ton of assignments, and I'm not sure that seeing them in the outline feels that useful.
Branched from #858
Addresses posit-dev/positron#8330
Objects assigned in
{}
blocks are currently emitted as document symbols, which causes the ouline and document symbol search (@
prefix in command palette) to be quite busy:Screen.Recording.2025-06-27.at.15.18.45.mov
Here is how it looks like if we only emit top-level objects:
Screen.Recording.2025-06-27.at.15.20.35.mov
This is controllable via a new
"positron.r.symbols.includeAssignmentsInBlocks
setting. By default we don't include these nested assignments.QA Notes
You should see the new setting in the config UI:
It's documented that files need to be reopened (they can also be changed) or the server restarted for this setting to take effect.