Skip to content

Crash when formatting document 2 #4728

Closed
@getreu

Description

@getreu

Steps to reproduce

  1. Create a file tmp.md with the following content

    word word word
    word word word
    word word word
    
  2. Select all with %

  3. Pipe all with | through fmt

Backtrace

$ RUST_BACKTRACE=1 hx tmp.md
thread 'main' panicked at 'called Result::unwrap() on an Err value: Char index out of bounds: char index 59, Rope/RopeSlice char length 30', /home/getreu/.cargo/registry/src/g.yxqyang.asia-1ecc6299db9ec823/ropey-1.5.0/src/slice.rs:349:41
stack backtrace:

   0: rust_begin_unwind
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
   2: core::result::unwrap_failed
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/result.rs:1785:5
   3: ropey::slice::RopeSlice::char_to_byte
   4: helix_core::graphemes::nth_next_grapheme_boundary
   5: helix_core::selection::Range::grapheme_aligned
   6: helix_core::selection::Selection::ensure_invariants
   7: helix_view::document::Document::apply_impl
   8: helix_view::document::Document::apply
   9: helix_term::commands::shell
  10: <helix_term::ui::prompt::Prompt as helix_term::compositor::Component>::handle_event
  11: helix_term::compositor::Compositor::handle_event
  12: helix_term::application::Application::handle_terminal_events
  13: hx::main_impl::{{closure}}
  14: std::thread::local::LocalKey<T>::with
  15: tokio::park::thread::CachedParkThread::block_on
  16: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
  17: tokio::runtime::Runtime::block_on
  18: hx::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions