-
Notifications
You must be signed in to change notification settings - Fork 16
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
wanted_column now works with wide graphemes #26
Conversation
src/zed_lines.mli
Outdated
@@ -74,3 +74,7 @@ val replace : t -> int -> int -> t -> t | |||
(** [replace set offset length repl] replaces the subset at offset | |||
[offset] and length [length] by [repl] in [set]. *) | |||
|
|||
val get_idx_by_width : t -> int -> int -> int | |||
(** [get_idx_by_width set column_width] return the offset of the char at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec in the documentation comment looks wrong; it has only two arguments while the function takes 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, doc comment is fixed now.
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. |
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. |
Ah, indeed I missed that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
thank you |
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 patchafter this patch