Skip to content
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

Panic when entering Unicode in command prompt #282

Closed
CBenoit opened this issue Jun 16, 2021 · 1 comment · Fixed by #292
Closed

Panic when entering Unicode in command prompt #282

CBenoit opened this issue Jun 16, 2021 · 1 comment · Fixed by #292
Labels
C-bug Category: This is a bug

Comments

@CBenoit
Copy link
Member

CBenoit commented Jun 16, 2021

Hi! Another Unicode panic 👋

Reproduction steps

Type :éé

Environment

  • Platform: Linux
  • Helix version: commit 6fb2d26

Output

$ hx
thread 'main' panicked at 'assertion failed: self.is_char_boundary(idx)', /home/auroden/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/string.rs:1351:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@CBenoit CBenoit added the C-bug Category: This is a bug label Jun 16, 2021
@archseer
Copy link
Member

Okay, this is a dumb one, String::insert indexes by byte position.

self.line.insert(self.cursor, c);

Need to use let (pos, _) = .char_indices().nth(pos).unwrap()

CBenoit added a commit that referenced this issue Jun 17, 2021
It was attempted to use `String::insert` and `String::remove` to insert
without taking care of unicodes.

Fixes #282
CBenoit added a commit that referenced this issue Jun 17, 2021
It was attempted to use `String::insert` and `String::remove` to insert
without taking care of unicodes.

Fixes #282
archseer pushed a commit that referenced this issue Jun 18, 2021
It was attempted to use `String::insert` and `String::remove` to insert
without taking care of unicodes.

Fixes #282
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants