helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
32.77k stars 2.41k forks source link

Command suggestions sometimes panic in `self.is_char_boundary(n)` #1888

Closed ReagentX closed 1 year ago

ReagentX commented 2 years ago

Summary

Using tab to complete/cycle through completion options sometimes crashes with the following message:

thread 'main' panicked at 'assertion failed: self.is_char_boundary(n)', /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/string.rs:1718:29

Reproduction Steps

I tried this: 1. `hx` 2. type `:theme` 3. press tab to start autocomplete 4. `Space` to select `theme` 5. tab again to select from the theme list I expected this to happen: The selection moves through the theme list Instead, this happened: ``` thread 'main' panicked at 'assertion failed: self.is_char_boundary(n)', /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/string.rs:1718:29 ``` ### Helix log `~/.cache/helix/helix.log` is empty ### Platform macOS ### Terminal Emulator alacritty 0.10.1 (2844606) ### Helix Version helix 22.03 (d4e45fd4)
sudormrfbin commented 2 years ago

Duplicate of #1246, but it's still not reproducible in my machine :/

archseer commented 2 years ago

Can you get us a full backtrace by setting the env RUST_BACKTRACE=1?

ReagentX commented 2 years ago

I tried that, but there was no additional output.

archseer commented 2 years ago

I tried that, but there was no additional output.

Did you export the env var? What exactly did you run

archseer commented 2 years ago

Feels like the range returned by completions isn't aligned to a char which then causes replace_range to panic https://github.com/helix-editor/helix/blob/d37369c1e056e41d405bc95b13efd550c57fa933/helix-term/src/ui/prompt.rs#L311

archseer commented 2 years ago

Could also be because the completion isn't recalculated when you press tab, but the completions are all calculated from what the original input was

archseer commented 2 years ago

Based on the trace in the other issue that seems to be it: https://github.com/helix-editor/helix/issues/2004#issuecomment-1091289091

pascalkuthe commented 1 year ago

I tried to reproduce this by the various methods described. No matter how long I spam any keys or try I can't reproduce this. Is it possible this has been fixed? There were quite a few reports around April last year but nothing since

gabydd commented 1 year ago

yeah you are correct @pascalkuthe this looks like it was fixed by https://github.com/helix-editor/helix/pull/3193