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

More IDE features for control flow keywords #17517

Closed
Veykril opened this issue Jun 30, 2024 · 7 comments · Fixed by #17542
Closed

More IDE features for control flow keywords #17517

Veykril opened this issue Jun 30, 2024 · 7 comments · Fixed by #17542
Assignees
Labels
A-ide general IDE features C-feature Category: feature request

Comments

@Veykril
Copy link
Member

Veykril commented Jun 30, 2024

We currently highlight relevant control flow structures when the cursor is on a relevant keyword, an example being highlighting all awaits when on an async fn's async keyword, or all loop control flow keywords when it is on the loops keyword. We can do more things here I'd say. Go to def/decl on return could go the relevant closure/fn, continue and break to the corresponding loop (or block for labeled blocks), go to references could do the same as the highlighting

@Veykril Veykril added C-feature Category: feature request A-ide general IDE features labels Jun 30, 2024
@roife
Copy link
Member

roife commented Jul 1, 2024

@rustbot claim

@roife
Copy link
Member

roife commented Jul 1, 2024

For the return kw, should we navigate to the def (i.e., the function name), the arrow-> or the fn keyword of the function?

@Veykril
Copy link
Member Author

Veykril commented Jul 1, 2024

fn keyword I'd say, for closures the opening bar and for async blocks the async keyword

@roife
Copy link
Member

roife commented Jul 2, 2024

I've encountered some difficulties handling macros:

Currently, for functions, I can correctly handle three scenarios (see GIF):

  • Jumping directly to the function.
  • Inside a macro, and jump to a function within the macro.
  • Inside a macro, but jump to a function outside the macro.

and mixture of them.

录屏2024-07-02 13 30 31

These can be handled using NavigationTarget::from_named (orig_range_with_focus). However, how should I handle closures? Since closures don't have names, can they be mapped through SpanMap?

@Veykril
Copy link
Member Author

Veykril commented Jul 2, 2024

They can be mapped just fine, it's just that we have no API in NavigationTarget for anything without names.

@roife
Copy link
Member

roife commented Jul 2, 2024

Currently, placing the cursor over return (in async block) highlights the corresponding async, while placing it over async just highlights all await. It's a bit inconsistent.

Should we implement a similar approach for goto-definition and goto-references? 🤔 Or changed it to be:

  • return corresponds to the { of the async block
  • async kw corresponds to await kw

@Veykril
Copy link
Member Author

Veykril commented Jul 2, 2024

I think for async blocks we might just wanna highlight await and return together. { isnt really intuitive for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ide general IDE features C-feature Category: feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants