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 completion menu items contains UTF-8 characters and ( #837

Open
petricavalry opened this issue Sep 29, 2024 · 0 comments · May be fixed by #839
Open

Panic when completion menu items contains UTF-8 characters and ( #837

petricavalry opened this issue Sep 29, 2024 · 0 comments · May be fixed by #839
Labels
A-Completions Area: Tab completion and inline hint completions bug Something isn't working

Comments

@petricavalry
Copy link

petricavalry commented Sep 29, 2024

Platform Arch Linux
Terminal software Alacritty

Same as title. nushell/nushell#13951 caused by this issues.

Thanks for all amazing work in reedline.

Steps to reproduce

  1. Run the example completions with following lines changed.

    let commands = vec![
        "おはよう".into(),
        "おはよう(".into(),
    ];
  2. Enter おは and press Tab.

Screenshots/Screencaptures

thread 'main' panicked at /usr/src/debug/rust/rustc-1.81.0-src/library/core/src/str/mod.rs:659:21:
byte index 4 is not a char boundary; it is inside 'は' (bytes 3..6) of `おはよう`
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::str::slice_error_fail_rt
   3: core::str::slice_error_fail
   4: core::str::<impl str>::split_at
             at /usr/src/debug/rust/rustc-1.81.0-src/library/core/src/str/mod.rs:659:21
   5: reedline::menu::columnar_menu::ColumnarMenu::create_string
             at ./src/menu/columnar_menu.rs:305:46
   6: <reedline::menu::columnar_menu::ColumnarMenu as reedline::menu::Menu>::menu_string::{{closure}}
             at ./src/menu/columnar_menu.rs:659:21
   7: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
             at /usr/src/debug/rust/rustc-1.81.0-src/library/core/src/ops/function.rs:305:13
   8: core::option::Option<T>::map
             at /usr/src/debug/rust/rustc-1.81.0-src/library/core/src/option.rs:1110:29
   9: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next
             at /usr/src/debug/rust/rustc-1.81.0-src/library/core/src/iter/adapters/map.rs:108:26
   10: <alloc::string::String as core::iter::traits::collect::FromIterator<alloc::string::String>>::from_iter
             at /usr/src/debug/rust/rustc-1.81.0-src/library/alloc/src/string.rs:2153:15
   11: core::iter::traits::iterator::Iterator::collect
             at /usr/src/debug/rust/rustc-1.81.0-src/library/core/src/iter/traits/iterator.rs:2005:9
   12: <reedline::menu::columnar_menu::ColumnarMenu as reedline::menu::Menu>::menu_string
             at ./src/menu/columnar_menu.rs:648:13
   13: <reedline::menu::ReedlineMenu as reedline::menu::Menu>::menu_string
             at ./src/menu/mod.rs:457:9
   14: reedline::painting::painter::Painter::print_menu
             at ./src/painting/painter.rs:307:27
   15: reedline::painting::painter::Painter::print_small_buffer
             at ./src/painting/painter.rs:359:13
   16: reedline::painting::painter::Painter::repaint_buffer
             at ./src/painting/painter.rs:234:13
   17: reedline::engine::Reedline::buffer_paint
             at ./src/engine.rs:1812:9
   18: reedline::engine::Reedline::repaint
             at ./src/engine.rs:1514:13
   19: reedline::engine::Reedline::read_line_helper
             at ./src/engine.rs:802:29
   20: reedline::engine::Reedline::read_line
             at ./src/engine.rs:646:22
   21: completions::main
             at ./examples/completions.rs:66:19
   22: core::ops::function::FnOnce::call_once
             at /usr/src/debug/rust/rustc-1.81.0-src/library/core/src/ops/function.rs:250:5
@petricavalry petricavalry added the bug Something isn't working label Sep 29, 2024
@ysthakur ysthakur added the A-Completions Area: Tab completion and inline hint completions label Sep 29, 2024
petricavalry added a commit to petricavalry/reedline that referenced this issue Sep 30, 2024
@petricavalry petricavalry linked a pull request Sep 30, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Completions Area: Tab completion and inline hint completions bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants