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

prefer Document::set_selection to inserting selections directly #2411

Merged
merged 1 commit into from
May 11, 2022

Conversation

the-mikedavis
Copy link
Member

Inserting these with the HashMap::insert method evades the call
to Selection::ensure_invariants. The effect is that the scratch
buffer (or other buffers opened through these code-paths) can start
with a selection at (0, 0), when a file with equivalent contents ("\n")
would start with (0, 1).

I.e.:

hx

and

touch f
hx f

start with different selections even though they have an equivalent
Rope. With this change they both start with (0, 1).

Inserting these with the `HashMap::insert` method evades the call
to `Selection::ensure_invariants`. The effect is that the scratch
buffer (or other buffers opened through these code-paths) can start
with a selection at (0, 0), when a file with equivalent contents ("\n")
would start with (0, 1).

I.e.:

    hx

and

    touch f
    hx f

start with different selections even though they have an equivalent
Rope. With this change they both start with (0, 1).
@the-mikedavis
Copy link
Member Author

I found this when digging through #2147 but itself I don't think this causes any bugs at the moment. It seems like it's always better to check the bounds of the selection though. Plus this brings the scratch buffer in line with the behavior of buffers backed by files.

@archseer archseer merged commit 247ab25 into helix-editor:master May 11, 2022
@the-mikedavis the-mikedavis deleted the md-prefer-set-selection branch May 11, 2022 00:54
mtoohey31 pushed a commit to mtoohey31/helix that referenced this pull request Jun 15, 2022
…x-editor#2411)

Inserting these with the `HashMap::insert` method evades the call
to `Selection::ensure_invariants`. The effect is that the scratch
buffer (or other buffers opened through these code-paths) can start
with a selection at (0, 0), when a file with equivalent contents ("\n")
would start with (0, 1).

I.e.:

    hx

and

    touch f
    hx f

start with different selections even though they have an equivalent
Rope. With this change they both start with (0, 1).
mtoohey31 pushed a commit to mtoohey31/helix that referenced this pull request Jun 15, 2022
…x-editor#2411)

Inserting these with the `HashMap::insert` method evades the call
to `Selection::ensure_invariants`. The effect is that the scratch
buffer (or other buffers opened through these code-paths) can start
with a selection at (0, 0), when a file with equivalent contents ("\n")
would start with (0, 1).

I.e.:

    hx

and

    touch f
    hx f

start with different selections even though they have an equivalent
Rope. With this change they both start with (0, 1).
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.

2 participants