Skip to content
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

Merged
merged 2 commits into from
Apr 11, 2024
Merged

Extend the symbol range to include the rhs #1887

merged 2 commits into from
Apr 11, 2024

Conversation

jneem
Copy link
Member

@jneem jneem commented Apr 11, 2024

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.

@jneem jneem requested review from yannham and vkleen April 11, 2024 17:27
@github-actions github-actions bot temporarily deployed to pull request April 11, 2024 17:30 Inactive
.annotation
.contracts
.iter()
.chain(field.metadata.annotation.typ.as_ref())
Copy link
Member

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.

.map(|pos| pos.end.to_usize())
.max()
{
last_pos = last_pos.max(last_ty_pos);
Copy link
Member

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.

Copy link
Member Author

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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
docced | doc "The symbol range doesn't current include docs",
docced | doc "The symbol range doesn't currently include docs",

@jneem jneem enabled auto-merge April 11, 2024 22:00
@github-actions github-actions bot temporarily deployed to pull request April 11, 2024 22:02 Inactive
@jneem jneem added this pull request to the merge queue Apr 11, 2024
Merged via the queue into master with commit 34a99fd Apr 11, 2024
5 checks passed
@jneem jneem deleted the symbol-range branch April 11, 2024 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants