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

Fix locals tracking in Rust closures #3027

Conversation

the-mikedavis
Copy link
Member

@the-mikedavis the-mikedavis commented Jul 10, 2022

The fix comes from the rewriting of the closure_parameters stanza:
it was capturing the entire closure_parameters node including
|s, whitespace and commas. Capturing the identifiers within
fixes the tracking.

In order to make sure locals definitions from closure parameters don't
leak out of the body of the closure, though, we should also mark the
closure itself as a locals scope.

Before After
before after

Where variable.parameter is underlined white in my theme (notice layer and r above).

The fix comes from the rewriting of the `closure_parameters` stanza:
it was capturing the entire `closure_parameters` node including
paretheses, whitespace, and commas. Capturing the identifiers within
fixes the tracking.

In order to make sure locals definitions from closure parameters don't
leak out of the body of the closure, though, we should also mark the
closure itself as a locals scope.
Copy link
Contributor

@pickfire pickfire left a comment

Choose a reason for hiding this comment

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

I don't quite know what you did there but it is interesting. Can merge if you want I guess.

@archseer archseer merged commit 9753da6 into helix-editor:master Jul 20, 2022
aikomastboom pushed a commit to aikomastboom/helix that referenced this pull request Jul 20, 2022
The fix comes from the rewriting of the `closure_parameters` stanza:
it was capturing the entire `closure_parameters` node including
paretheses, whitespace, and commas. Capturing the identifiers within
fixes the tracking.

In order to make sure locals definitions from closure parameters don't
leak out of the body of the closure, though, we should also mark the
closure itself as a locals scope.
@the-mikedavis the-mikedavis deleted the md-rust-locals-tracking-in-closures branch July 24, 2022 08:21
thomasskk pushed a commit to thomasskk/helix that referenced this pull request Sep 9, 2022
The fix comes from the rewriting of the `closure_parameters` stanza:
it was capturing the entire `closure_parameters` node including
paretheses, whitespace, and commas. Capturing the identifiers within
fixes the tracking.

In order to make sure locals definitions from closure parameters don't
leak out of the body of the closure, though, we should also mark the
closure itself as a locals scope.
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.

3 participants