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

Edit/Chat: Always expand to the nearest enclosing function, if available, before folding ranges #3507

Merged
merged 8 commits into from
Mar 25, 2024

Conversation

umpox
Copy link
Contributor

@umpox umpox commented Mar 22, 2024

Description

This PR:

  • Adds Tree-sitter querys for getEnclosingFunction in languages: JS/TS/Go/Python
  • Updates getSmartSelection to run this query first, before using the folding range logic.

Test plan

  1. Start an edit, using just a cursor position.
  2. Check that the edit is correctly expanded to the nearest function.

An example of where this is a significant improvement, is in JS test files that use describe and it blocks.

  • Try putting cursor inside an it block and starting an edit
  • Notice that the range only expands to the entire it now, whereas before it would expand to the full describe

@umpox umpox requested review from steveyegge, a team and valerybugakov March 22, 2024 09:57
Copy link
Contributor

@dominiccooney dominiccooney left a comment

Choose a reason for hiding this comment

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

NICE! 🎉

@umpox umpox enabled auto-merge (squash) March 25, 2024 08:36
@umpox umpox merged commit 5096b57 into main Mar 25, 2024
19 of 20 checks passed
@umpox umpox deleted the tr/nearest-enclosing-function branch March 25, 2024 08:39
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.

None yet

2 participants