Fix multi byte auto pairs
Currently if you configure any auto pairs with multi-byte Unicode characters, auto pairing does not produce a correct selection. This is because it is summing bytes, when it should be summing chars.
I took this opportunity to migrate the auto pairs tests to the integration tests, as this makes the tests much more readable with the new selection DSL, and will also allow testing more complicated intersections of auto pairs with other features like dedenting, as described in https://github.com/helix-editor/helix/pull/1379#issuecomment-1003724997. Ironically, the tests weren't passing, and it turns out the test selection DSL parser suffered from exactly the same bug, counting bytes and not chars. This was also fixed, and regression tests were added.
Fixes #3946.
Sigh, Windows strikes again. Will look into the failure tomorrow.
Ok, actually it turned out to be a legitimate preexisting bug!
The selection was not computed correctly in the case that the cursor was:
- a single grapheme in width
- this grapheme was more than one
char - the direction of the cursor is backwards
- a secondary range
In this case, the offset was not being added into the anchor. An example of a case for this would be inserting a new pair in insert mode with multiple single width cursors at the end of their respective lines in a CRLF document. This was fixed.
@the-mikedavis or @archseer did you guys want anything else for this PR?
This looks good to me but I'll defer the merge to archseer
Looks good but there's one conflict to resolve now
Done!