Skip to content

assertion left == right upon backspace after Invalid validation #897

@xguerin

Description

@xguerin

Hello,

I'm using a very basic validation that triggers an assertion error upon pressing backspace after returning an Invalid(..) result. The code for the validator is trivially inspired from the example here.

Example of input:

>> (~)

After pressing enter:

>> (~) --< unexpected token ) at [2..3]

And after pressing backspace:

thread 'main' panicked at /Users/xguerin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustyline-17.0.1/src/edit.rs:586:17:
assertion `left == right` failed
  left: Position { col: 5, row: 0 }
 right: Position { col: 38, row: 0 }

Here is the backtrace:

   3: core::panicking::assert_failed
             at /Users/xguerin/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/panicking.rs:387:5
   4: rustyline::edit::State<H>::edit_kill
             at /Users/xguerin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustyline-17.0.1/src/edit.rs:586:17
   5: rustyline::command::execute
             at /Users/xguerin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustyline-17.0.1/src/command.rs:174:15
   6: rustyline::Editor<H,I>::readline_edit
             at /Users/xguerin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustyline-17.0.1/src/lib.rs:785:19
   7: rustyline::Editor<H,I>::readline_with
             at /Users/xguerin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustyline-17.0.1/src/lib.rs:665:35
   8: rustyline::Editor<H,I>::readline
             at /Users/xguerin/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustyline-17.0.1/src/lib.rs:639:14
   9: slr::main

If I skip the last character by pressing left arrow before pressing backspace, the assertion is not triggered.

This is running rustyline 17.0.1 on stable rust (1.89).

Thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions