usagi-flow / evil-helix

Bringing the Helix editor to the evil side
https://github.com/usagi-flow/helix
Mozilla Public License 2.0
280 stars 7 forks source link

x at the last line produces a panic #18

Closed antoyo closed 3 months ago

antoyo commented 3 months ago

Summary

Pressing x on the last line will produce the following panic:

thread 'main' panicked at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ropey-1.6.1/src/slice.rs:656:9:
Attempt to slice past end of RopeSlice: slice end 2, RopeSlice length 1
stack backtrace:
   0: rust_begin_unwind
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panicking.rs:72:14
   2: ropey::slice::RopeSlice::slice
   3: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   4: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
   5: helix_term::commands::evil::EvilCommands::yank_selection
   6: helix_term::commands::evil::EvilCommands::delete_selection
   7: helix_term::commands::evil::EvilCommands::delete_immediate
   8: helix_term::ui::editor::EditorView::handle_keymap_event::{{closure}}
   9: helix_term::ui::editor::EditorView::handle_keymap_event
  10: <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event
  11: helix_term::compositor::Compositor::handle_event
  12: helix_term::application::Application::run::{{closure}}
  13: tokio::runtime::park::CachedParkThread::block_on
  14: hx::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Reproduction Steps

I tried this:

  1. hx
  2. jto go to the last line.
  3. x

I expected this to happen: Not panicking.

Instead, this happened: It panicked.

Helix log

No response

Platform

Linux

Terminal Emulator

Alacritty

Installation Method

Source

Helix Version

evil-helix 24.3 (d969d507)

usagi-flow commented 3 months ago

Thank you very much for your report, this would also be caused when appending (a) while at the EOF.

antoyo commented 3 months ago

Thanks for your fixes!