helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.48k stars 2.48k forks source link

Auto pairs incorrectly shifts selections with `crlf` line endings #8043

Open CptPotato opened 1 year ago

CptPotato commented 1 year ago

Summary

When using multiple selections and crlf line endings, auto pairs can cause selections to shift when inserting on the newline character.

Reproduction Steps

Open a new file with this content:

fn aaa
fn bbb
fn ccc
fn ddd

The result is this (each auto pair causes the following selections' anchor to shift):

image

All selections should remain 1 character wide instead.

Helix log

log ```js 2023-08-23T10:20:55.527 helix_core::auto_pairs [DEBUG] auto pair transaction: Transaction { changes: ChangeSet { changes: [ Retain( 6, ), Insert( "()", ), Retain( 8, ), Insert( "()", ), Retain( 8, ), Insert( "()", ), Retain( 8, ), Insert( "()", ), Retain( 2, ), ], len: 32, len_after: 40, }, selection: Some( Selection { ranges: [ Range { anchor: 7, head: 8, old_visual_position: None, }, Range { anchor: 15, head: 18, old_visual_position: None, }, Range { anchor: 23, head: 28, old_visual_position: None, }, Range { anchor: 31, head: 38, old_visual_position: None, }, ], primary_index: 0, }, ), } ```

Platform

Windows

Terminal Emulator

wezterm (20230712-072601)

Helix Version

master at 929eb0c39e34f8046b5ec9ecfede4ec80b5e0c8a

pascalkuthe commented 1 year ago

cc @dead10ck

dead10ck commented 1 year ago

I'm unable to reproduce the issue with these steps. @pascalkuthe would you be able to give it a shot just so we can rule out that I'm doing something wrong?

dead10ck commented 1 year ago

Oh actually I was using my personal branch. I am able to reproduce from the latest master. This makes me suspect that it's already fixed by #7269

Edit: yep, confirmed, this is fixed by #7269

CptPotato commented 1 year ago

Oh actually I was using my personal branch. I am able to reproduce from the latest master. This makes me suspect that it's already fixed by #7269

Ah nice, I can check later if this fixes the auto-pair issues.