Skip to content

Panic when opening annotations list with non-ASCII annotation text #145

Description

@CruelAddict

When an annotation contains non-ASCII text (eg Cyrillic), opening the annotations list with I can panic with byte index 40 is not a char boundary
This appears to happen when the annotation preview is truncated for display.
Steps to reproduce

  1. Open any diff in lumen
  2. Press i to create a file annotation
  3. Paste this:
    123456789012345678901234567890123456789б
  4. Save with Enter
  5. Press I to open the annotations list

Result: lumen crashes with a panic like:

byte index 40 is not a char boundary; it is inside 'б' (bytes 39..41)
of `123456789012345678901234567890123456789б`
stack backtrace:
   0: <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::sys::backtrace::BacktraceLock::print
   4: std::panicking::panic_with_hook
   5: std::panicking::panic_handler::{{closure}}
   6: std::sys::backtrace::__rust_end_short_backtrace
   7: __rustc[d9b87f19e823c0ef]::rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::str::slice_error_fail_rt
  10: core::str::slice_error_fail
  11: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
  12: lumen::command::diff::app::run_app_internal
  13: lumen::command::diff::run_diff_ui
  14: lumen::main
  15: std::sys::backtrace::__rust_begin_short_backtrace
  16: _main

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions