rabite0 / hunter

The fastest file manager in the galaxy!
Do What The F*ck You Want To Public License
1.31k stars 64 forks source link

Panic after typing german umlaut in minibuffer #97

Open wullewutz opened 4 years ago

wullewutz commented 4 years ago

Hunter panics on the second input character typed into the minibuffer after a german umlaut e.g. "ü". For example:

  1. Start a search in current dir
  2. Type üb (<-or copy this string if no german keyboard layout available)
  3. Panic with message:
    thread 'main' panicked at 'assertion failed: self.is_char_boundary(idx)', /rustc/ff5b446d2fdbd898bc97a751f2f72858de185cf1/src/libcore/macros/mod.rs:10:9
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

    Reason is probably the cursor positioning/indexing in minibuffer.rs. I'm on current master (355d9a3101f6d8dc375807de79e368602f1cb87d) using 1.46.0-nightly. Happens in alacritty as well as xterm.

wullewutz commented 4 years ago

Typing ü adds two bytes to self.input in minibuffer.rs instead of just one here (minibuffer.rs:521):

InsertChar(ch) => {
    self.input.insert(self.position, *ch);
    self.position += 1;
}

Since position is only incremented by one, the next character input is not at a char boundary anymore leading insert() to panic. Not so easy to fix, i suspect... Have you considered using rustyline for minibuffer input?