-
Notifications
You must be signed in to change notification settings - Fork 90
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
Extend the symbol range to include the rhs #1887
Conversation
lsp/nls/src/requests/symbols.rs
Outdated
.annotation | ||
.contracts | ||
.iter() | ||
.chain(field.metadata.annotation.typ.as_ref()) |
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.
There's an iter()
method on TypeAnnotation
that is returning the type chained with the contracts as an iterator.
lsp/nls/src/requests/symbols.rs
Outdated
.map(|pos| pos.end.to_usize()) | ||
.max() | ||
{ | ||
last_pos = last_pos.max(last_ty_pos); |
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 don't know if it's useful to reduce boilerplate, but there's a fuse()
method on RawSpan
, which returns the smallest enclosing span that contains both spans given as arguments.
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.
That did turn out nicer, thanks!
@@ -9,6 +9,8 @@ let func = fun x => 1 in | |||
type_checked_block = { | |||
inner_name = { name = "value" }, | |||
} : _, | |||
annotated | String, | |||
docced | doc "The symbol range doesn't current include docs", |
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.
docced | doc "The symbol range doesn't current include docs", | |
docced | doc "The symbol range doesn't currently include docs", |
Fixes #1886.
The symbols response has two ranges: the "selection range" is just the position of the symbol name, but the "range" is supposed to include the "body" of the symbol. VSCode uses this range for the breadcrumb bar: it shows the symbols in the bar when your cursor is in that symbol's body. Previously, we were just reporting the position of the symbol name for both ranges.