nushell / nushell/nushell

Panic when using help menu

Open
#6,785 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A:line-editor category:bug panic
Dominant language
Rust
Stars
40.5k
Forks
2.3k
Avg merge
1d 19h
Merged PRs (30d)
85

Description

Describe the bug

When using completions from the help menu, certain behaviours cause a panic in reedline:

  1. If the line is non-empty and the help menu is used to find a command, typing any non-return character causes a panic
  2. If the line is empty and the help menu is used to find a command, typing the space character causes a panic.
How to reproduce
  1. Type some string into the command prompt
  2. Open the help menu (using some keybind)
  3. Type a search term and select a suggestion
  4. Type a non-return character
Expected behavior

I expect nu to not panic. Furthermore, I expect nu to parse the command and behave as it would if the help command was not used and the "helped command" was inputted manually.

Screenshots

No response

Configuration
key value
version 0.69.2
branch main
commit_hash cd6437943ad9f9e1dc39323a05fd075069f0caa3
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.63.0 (4b91a6ea7 2022-08-08)
rust_channel 1.63.0-x86_64-unknown-linux-gnu
cargo_version cargo 1.63.0 (fd9c4297c 2022-07-01)
pkg_version 0.69.2
build_time 2022-10-14 11:11:33 -04:00
build_rust_channel debug
features default, trash, which, zip
installed_plugins
Additional context

Here is the backtrace:

/u5/dsnelgro/nushell〉hlsthread 'main' panicked at 'assertion failed: self.is_char_boundary(idx)', /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/alloc/src/string.rs:1530:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:142:14
   2: core::panicking::panic
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:48:5
   3: alloc::string::String::insert
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/alloc/src/string.rs:1530:9
   4: reedline::core_editor::line_buffer::LineBuffer::insert_char
             at /u5/dsnelgrove/.cargo/git/checkouts/reedline-e42026a78d91c510/f949f56/src/core_editor/line_buffer.rs:342:9
   5: reedline::core_editor::editor::Editor::run_edit_command
             at /u5/dsnelgrove/.cargo/git/checkouts/reedline-e42026a78d91c510/f949f56/src/core_editor/editor.rs:57:43
   6: reedline::engine::Reedline::run_edit_commands
             at /u5/dsnelgrove/.cargo/git/checkouts/reedline-e42026a78d91c510/f949f56/src/engine.rs:1173:13
   7: reedline::engine::Reedline::handle_editor_event
             at /u5/dsnelgrove/.cargo/git/checkouts/reedline-e42026a78d91c510/f949f56/src/engine.rs:915:17
   8: reedline::engine::Reedline::handle_event
             at /u5/dsnelgrove/.cargo/git/checkouts/reedline-e42026a78d91c510/f949f56/src/engine.rs:586:13
   9: reedline::engine::Reedline::read_line_helper
             at /u5/dsnelgrove/.cargo/git/checkouts/reedline-e42026a78d91c510/f949f56/src/engine.rs:563:23
  10: reedline::engine::Reedline::read_line
             at /u5/dsnelgrove/.cargo/git/checkouts/reedline-e42026a78d91c510/f949f56/src/engine.rs:440:22
  11: nu_cli::repl::evaluate_repl
             at ./crates/nu-cli/src/repl.rs:340:21
             at ./src/main.rs:458:31
  13: core::ops::function::FnOnce::call_once
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the help-menu interaction described in the issue, then start with reedline's core_editor/line_buffer.rs at LineBuffer::insert_char and core_editor/editor.rs at Editor::run_edit_command, as identified by the backtrace. Trace how selecting a help suggestion changes the line and verify that subsequent non-return input does not panic and preserves the expected command behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.