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

Crash with is_char_boundary in apply_changes #31

Closed
yuriiShmal opened this issue Apr 11, 2023 · 2 comments
Closed

Crash with is_char_boundary in apply_changes #31

yuriiShmal opened this issue Apr 11, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@yuriiShmal
Copy link

yuriiShmal commented Apr 11, 2023

This is the output. I don't think I have any fancy unicode characters. If I do, they should be on accident from option + whatever.

Run with RUST_BACKTRACE=full to include source snippets.
Backtrace (most recent call first):
  File "<unknown>", line 0, in core::panicking::panic
  File "<unknown>", line 0, in lang_srv::helpers::apply_changes
  File "<unknown>", line 0, in lang_srv::notification::go
  File "<unknown>", line 0, in lang_srv::run_inner
  File "<unknown>", line 0, in lang_srv::run_stdio
  File "<unknown>", line 0, in millet_ls::main
  File "<unknown>", line 0, in std::sys_common::backtrace::__rust_begin_short_backtrace
  File "<unknown>", line 0, in _main

Millet (0.8.8) crashed. We would appreciate a bug report: https://github.com/azdavis/millet/issues
  assertion failed: self.is_char_boundary(n)
in rust:library/alloc/src/string.rs, line 1811
thread: main
@azdavis azdavis added the bug Something isn't working label Apr 15, 2023
@azdavis azdavis changed the title Millet Crashed Crash with is_char_boundary in apply_changes Apr 16, 2023
@azdavis
Copy link
Owner

azdavis commented Apr 22, 2023

seems like the bug is here:

text.replace_range(std::ops::Range::<usize>::from(text_range), &change.text);

the underlying bug is probably in PositionDb, which deals with translating utf16 offsets between utf8 ones (essentially). there's a bunch of subtle and tricky string munging code in there. it's heavily derived from rust analyzer's implementation, but i may have made some mistakes when copying it over.

it'd be great if rust analyzer pulled theirs out into a library so i could just copy it wholesale 🤪

bors added a commit to rust-lang/rust-analyzer that referenced this issue May 6, 2023
Make line-index a lib, use nohash_hasher

These seem like they are not specific to rust-analyzer and could be pulled out to their own libraries. So I did.

azdavis/millet#31
@azdavis
Copy link
Owner

azdavis commented May 7, 2023

should hopefully be addressed in v0.9.6 since we basically lifted rust-analyzer's handling of this stuff, which is way more thoroughly tested by virtue of rust/rust-analyzer being far more popular than sml/millet

@azdavis azdavis closed this as completed May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants