-
Notifications
You must be signed in to change notification settings - Fork 19
terminal: refactor to use unicode graphemes properly, fix special character bugs #528
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
Conversation
@nick1udwig I have tested this informally, would you mind running through some informal tests of normal user behavior through this terminal on linux? Some behavior may be platform-specific |
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.
- When scrolling cursor near unicode characters (e.g. emojis 😊 ™️) behavior is not quite right: e.g. it takes two lefts/rights to get past either of those emojis
- Ctrl+R search for an emoji crashes node when there is a hit:
fake.dev *:thread 'main' panicked at /rustc/791adf759cc065316f054961875052d5bc03e16c/library/alloc/src/string.rs:1704:9: assertion failed: self.is_char_boundary(idx)
- When scrolling up to a previously-sent command containing an emoji (not necessarily the last unicode char: could be emoji in middle of command), cursor is messed up (not on an empty space after the command, instead on last character; new entries still go at end)
Fixing cursor handling of wider-than-one-column unicode graphemes such as emojis was harder than I thought.. but it's working now on my machine. @nick1udwig would you mind re-reviewing? |
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.
Almost perfect. Still crashing with TM emoji Ctrl+R tho:
fake.dev > hi fake2.dev Soon™️
Tue 22:08 terminal:sys: response from fake2.dev: delivered
fake.dev *:thread 'main' panicked at kinode/src/terminal/utils.rs:245:43:
byte index 23 is not a char boundary; it is inside '™' (bytes 21..24) of `hi fake2.dev Soon™️`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Cleaning up "/tmp/kinode-fake-node"...
Done cleaning up "/tmp/kinode-fake-node".
@nick1udwig lol turns out that emoji triggers a bit of an edge case. fixed, I think |
Still seeing the Soon™️ nit:
|
|
|
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.
lol
Problem
The terminal was using string slicing to do all character-level manipulation, causing special characters to create panics due to inserts/removes in the middle of unicode graphemes.
Solution
Rewrite the terminal with the
unicode_segmentation
crate to properly handle character input.Testing
Docs Update
N/A
Notes
N/A