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

Short-circuit the word and treesitter object movement commands #5851

Merged
merged 1 commit into from
Feb 7, 2023

Conversation

trink
Copy link
Contributor

@trink trink commented Feb 6, 2023

The loop always iterates the number of times the user specified even if the beginning/end of the document is reached.

For an extreme demonstration try the following commands, Helix will hang for several seconds.
100000000w
100000000]c

@pascalkuthe
Copy link
Member

LGTM, small and simple fix for a pathological case 👍

We might want to do something similar for other movements like move_next_paragraph and move_prev_paragraph too? It's not as critical there as the loop is quite a bit cheapter but 9999999999999]p also seems to take a lot longer than it should.

@pascalkuthe pascalkuthe added C-bug Category: This is a bug E-easy Call for participation: Experience needed to fix: Easy / not much S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. A-core Area: Helix core improvements labels Feb 6, 2023
Copy link
Member

@pascalkuthe pascalkuthe left a comment

Choose a reason for hiding this comment

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

LGTM now, nice catch. It's always good to fixup things that can accidently lockup the UI thread

@pascalkuthe pascalkuthe added S-waiting-on-review Status: Awaiting review from a maintainer. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 6, 2023
Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

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

Just a minor style nit, otherwise I think this looks good

helix-core/src/movement.rs Outdated Show resolved Hide resolved
@pascalkuthe pascalkuthe added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from a maintainer. labels Feb 6, 2023
The loop always iterates the number of times the user specified even
if the beginning/end of the document is reached.

For an extreme demonstration try the following commands, Helix will
hang for several seconds.
100000000w
100000000]c

Review feedback amended:
    - short-circuit the prev/next paragraph commands
@pascalkuthe pascalkuthe added S-waiting-on-review Status: Awaiting review from a maintainer. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 7, 2023
@the-mikedavis the-mikedavis merged commit c704701 into helix-editor:master Feb 7, 2023
@trink trink deleted the shortcircut_movement branch March 2, 2024 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Helix core improvements C-bug Category: This is a bug E-easy Call for participation: Experience needed to fix: Easy / not much S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants