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

correctly map unsorted positions #7471

Merged
merged 2 commits into from
Jun 28, 2023

Conversation

pascalkuthe
Copy link
Member

Fixes #7468
Fixes #7470

#7408 caused cashes because it assumed that all positions that are mapped with update_position are sorted. This is almost always the case. Except for the end of diagnostics. Diagnostics are sorted by their start position (and only if start positions are equal by end position). That caused various crashes. This is not a problem for selections since they are non-overlapping so ends re always sorted.

This PR addresses that by allowing update_positions to backtrack in case if encounters an unsorted position. That does mean that the position mapping isn't quite linear anymore for diagnostics ends. However, this shouldn't really be an issue in practice as most diagnostics don't overlap, so the performance impact should be quite small in practice.

@pascalkuthe pascalkuthe added C-bug Category: This is a bug A-core Area: Helix core improvements S-waiting-on-review Status: Awaiting review from a maintainer. labels Jun 27, 2023
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
@archseer archseer merged commit 4a2337d into helix-editor:master Jun 28, 2023
wes-adams pushed a commit to wes-adams/helix that referenced this pull request Jul 4, 2023
* correctly map unsorted positions

* Fix typo

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
mtoohey31 pushed a commit to mtoohey31/helix that referenced this pull request Jun 2, 2024
* correctly map unsorted positions

* Fix typo

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
smortime pushed a commit to smortime/helix that referenced this pull request Jul 10, 2024
* correctly map unsorted positions

* Fix typo

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
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 S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic with Positions [..] are out of range ... Panic on weird n" in a Rust file
3 participants