ocaml-community / zed

Abstract engine for text edition in OCaml
Other
121 stars 16 forks source link

wanted_column now works with wide graphemes #26

Closed kandu closed 4 years ago

kandu commented 4 years ago

The wanted_column now works with wide graphemes.

Instead of recording the offset, the wanted_column value records the current column_display which is based on the width of the graphemes.

Every time a user goto prev_n or next_n lines, goto bol, eol etc it now calculates the offset at the given column_width and set the result offset as the new position.

Click to expand the GIFs before this patch ![before](https://user-images.githubusercontent.com/357626/67878686-b309fe00-fb76-11e9-81ae-c91808c1d1e6.gif) after this patch ![after](https://user-images.githubusercontent.com/357626/67879753-763f0680-fb78-11e9-9fdb-ce38a6e2ea8c.gif)
ghost commented 4 years ago

Nice! The two gifs look the same to me BTW

hhugo commented 4 years ago

Nice! The two gifs look the same to me BTW

They are actually different, on the first gif, the cursor always fall at the end of the second line.

kandu commented 4 years ago

yeah, previously, wanted_column is counted based on the number of characters. so in the first gif, it always want to jump to the 6th character of line 2, which exceed the eol. Then we move the cursor to "3", it then jump to the third character of line 2, "啊"

ghost commented 4 years ago

Ah, indeed I missed that

kandu commented 4 years ago

thank you