Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kill_to_line_end + undo crashs helix #5261

Closed
otavioschwanck opened this issue Dec 22, 2022 · 2 comments · Fixed by #5294
Closed

kill_to_line_end + undo crashs helix #5261

otavioschwanck opened this issue Dec 22, 2022 · 2 comments · Fixed by #5294
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@otavioschwanck
Copy link

Summary

using kill_to_line_end and undo crashs helix sometimes. Other times, the first undo throws:

Already at oldest change.

Reproduction Steps

SPC ? kill_end_of_line
u

Helix log

https://pasteio.com/xr14w9vbXb60

Platform

macOS

Terminal Emulator

alacritty + tmux

Helix Version

helix 22.12 (96ff64a)

@otavioschwanck otavioschwanck added the C-bug Category: This is a bug label Dec 22, 2022
@the-mikedavis
Copy link
Member

I can reproduce the odd undo behavior but I haven't been able to reproduce the crash yet. If you can reproduce the crash, could you paste the backtrace (setting RUST_BACKTRACE=full)?

I'm also curious if this happens if you make a keybinding for this rather than executing it from the command palette (<space>?). If I make a keybind for this I don't see the odd undo behavior so I assume this is a difference in the way that the command palette executes commands from the normal way commands get executed.

@nrabulinski
Copy link
Contributor

I can reproduce the bug. The undo history has to be populated for helix to crash, otherwise undo simply displays "already at the latest change". Here's a backtrace.

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Char index out of bounds: char index 34, Rope/RopeSlice char length 22', /private/tmp/nix-build-helix-22.12.drv-0/helix-22.12-vendor.tar.gz/ropey/src/rope.rs:671:41
stack backtrace:
   0:        0x104d79934 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc1d1e117199a4988
   1:        0x104580f4c - core::fmt::write::ha2a36b1977c662fd
   2:        0x104d98e54 - std::io::Write::write_fmt::hd9480b72d562b8cb
   3:        0x104da17a0 - std::panicking::default_hook::{{closure}}::h83dcf1445256c043
   4:        0x104da144c - std::panicking::default_hook::hb01d707a221a377b
   5:        0x104da204c - std::panicking::rust_panic_with_hook::h7d0b30e02e145808
   6:        0x104d79ff0 - std::panicking::begin_panic_handler::{{closure}}::hef5f50c978011674
   7:        0x104d79a58 - std::sys_common::backtrace::__rust_end_short_backtrace::h7730f7b3c6ee18fc
   8:        0x104da1bd4 - _rust_begin_unwind
   9:        0x104e31a7c - core::panicking::panic_fmt::h89e74af214ee85bf
  10:        0x104e31b58 - core::result::unwrap_failed::h32fc4c45072e5119
  11:        0x1046aa4e8 - helix_core::syntax::generate_edits::point_at_pos::h3940fdaaf0667721
  12:        0x1046a8cb8 - helix_core::syntax::Syntax::update::hed7cc3cac43de201
  13:        0x104b89d60 - helix_view::document::Document::apply_impl::h006ab692419b07d2
  14:        0x104b8af20 - helix_view::document::Document::undo_redo_impl::hea3d998218711afe
  15:        0x104a9a3f4 - helix_term::commands::undo::hd4b2c46267638f19
  16:        0x104953e54 - helix_term::ui::editor::EditorView::handle_keymap_event::{{closure}}::h8990c0214c56e8e7
  17:        0x104953d8c - helix_term::ui::editor::EditorView::handle_keymap_event::h873d31f0dc6f560e
  18:        0x104955e4c - <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event::h26ab649b6fea27d5
  19:        0x104a5f99c - helix_term::compositor::Compositor::handle_event::h089e8b2053e43bb7
  20:        0x104c08ec4 - helix_term::application::Application::run::{{closure}}::hf3c91e2249a77ce9
  21:        0x104c24d64 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hf2dfa2f7efe3a711
  22:        0x104c5942c - tokio::runtime::park::CachedParkThread::block_on::h31444c4365fc45ba
  23:        0x104c79fb8 - tokio::runtime::runtime::Runtime::block_on::hab961b46eed0d7bc
  24:        0x104c25864 - hx::main::hde412a4ecb78e9c8
  25:        0x104c60c6c - std::sys_common::backtrace::__rust_begin_short_backtrace::h41f5b8d45273b714
  26:        0x104c70880 - std::rt::lang_start::{{closure}}::h151b89415e94da73
  27:        0x104d9fecc - std::rt::lang_start_internal::he865f5d8ce8bd49f
  28:        0x104c25974 - _main

I also noticed the same behaviour with undo not doing anything or doing something unexpected when using other commands from the palette so my best guess is that executing command from a palette doesn't update the changes history which is why this can't be observed when you use a keybind to execute the command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants