floem icon indicating copy to clipboard operation
floem copied to clipboard

Shared text editors can crash from edits

Open ArthurCose opened this issue 3 months ago • 1 comments

I believe this is from RopeDelta applying only to the active editor.

Reproducing:

ASCII (used in clip):

  • Place the caret at the end of the line in the first editor
  • Delete all text in the second editor
  • Click on the space to the right of the last button and press tab to focus the editor without moving the caret
  • Press space, crashes with self must cover all 0-regions of other

Non-ASCII:

  • Set the text to a and place the caret after a in the first editor
  • Paste before a in the second editor
  • Click on the space to the right of the last button and press tab to focus the editor without moving the caret
  • Press space, crashes with: byte index 1 is not a char boundary; it is inside 'あ' (bytes 0..3) of `あa`

https://github.com/user-attachments/assets/f9881de2-933c-4114-90b7-6cc1182324a7

Crash log:
thread 'main' panicked at /home/konst/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/lapce-xi-rope-0.3.2/src/multiset.rs:237:30:
self must cover all 0-regions of other
stack backtrace:
   0: __rustc::rust_begin_unwind
             at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/std/src/panicking.rs:697:5
   1: core::panicking::panic_fmt
             at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/panicking.rs:75:14
   2: core::panicking::panic_display
             at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/panicking.rs:268:5
   3: core::option::expect_failed
             at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/option.rs:2139:5
   4: core::option::Option<T>::expect
             at /home/konst/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:964:21
   5: lapce_xi_rope::multiset::Subset::transform
             at /home/konst/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/lapce-xi-rope-0.3.2/src/multiset.rs:237:30
   6: lapce_xi_rope::multiset::Subset::transform_expand
             at /home/konst/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/lapce-xi-rope-0.3.2/src/multiset.rs:262:14
   7: floem_editor_core::buffer::Buffer::mk_new_rev
             at /home/konst/Documents/Projects/Rust/floem/editor-core/src/buffer/mod.rs:392:39
   8: floem_editor_core::buffer::Buffer::add_delta
             at /home/konst/Documents/Projects/Rust/floem/editor-core/src/buffer/mod.rs:320:18
   9: floem_editor_core::buffer::Buffer::edit
             at /home/konst/Documents/Projects/Rust/floem/editor-core/src/buffer/mod.rs:299:14
  10: floem_editor_core::editor::Action::insert
             at /home/konst/Documents/Projects/Rust/floem/editor-core/src/editor.rs:238:57
  11: <floem::views::editor::text_document::TextDocument as floem::views::editor::text::Document>::receive_char::{{closure}}
             at /home/konst/Documents/Projects/Rust/floem/src/views/editor/text_document.rs:210:25
  12: floem_reactive::signal::Signal::update_value
             at /home/konst/Documents/Projects/Rust/floem/reactive/src/signal.rs:228:22
  13: floem_reactive::write::SignalUpdate::try_update::{{closure}}
             at /home/konst/Documents/Projects/Rust/floem/reactive/src/write.rs:61:48
  14: core::option::Option<T>::map
             at /home/konst/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:1158:29
  15: floem_reactive::write::SignalUpdate::try_update
             at /home/konst/Documents/Projects/Rust/floem/reactive/src/write.rs:61:28
  16: <floem::views::editor::text_document::TextDocument as floem::views::editor::text::Document>::receive_char
             at /home/konst/Documents/Projects/Rust/floem/src/views/editor/text_document.rs:209:22
  17: floem::views::editor::Editor::receive_char
             at /home/konst/Documents/Projects/Rust/floem/src/views/editor/mod.rs:499:20
  18: floem::views::editor::view::editor_content::{{closure}}
             at /home/konst/Documents/Projects/Rust/floem/src/views/editor/view.rs:1215:48
  19: floem::views::decorator::Decorators::on_event_stop::{{closure}}
             at /home/konst/Documents/Projects/Rust/floem/src/views/decorator.rs:258:13
  20: <alloc::boxed::Box<F,A> as core::ops::function::FnMut<Args>>::call_mut
             at /home/konst/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1978:9
  21: floem::context::EventCx::unconditional_view_event::{{closure}}
             at /home/konst/Documents/Projects/Rust/floem/src/context.rs:472:39
  22: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::fold
             at /home/konst/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/iter/macros.rs:255:27
  23: floem::context::EventCx::unconditional_view_event
             at /home/konst/Documents/Projects/Rust/floem/src/context.rs:471:44
  24: floem::window_handle::WindowHandle::event
             at /home/konst/Documents/Projects/Rust/floem/src/window_handle.rs:281:26
  25: floem::window_handle::WindowHandle::key_event
             at /home/konst/Documents/Projects/Rust/floem/src/window_handle.rs:494:18
  26: floem::app_handle::ApplicationHandle::handle_window_event
             at /home/konst/Documents/Projects/Rust/floem/src/app_handle.rs:244:35
  27: <floem::app::Application as floem_winit_core::application::ApplicationHandler>::window_event
             at /home/konst/Documents/Projects/Rust/floem/src/app.rs:169:14
  28: <&mut A as floem_winit_core::application::ApplicationHandler>::window_event
             at /home/konst/.cargo/git/checkouts/winit-8836e04ddbb588c2/133268d/winit-core/src/application/mod.rs:377:18
  29: floem_winit_x11::event_processor::EventProcessor::xinput_key_input
             at /home/konst/.cargo/git/checkouts/winit-8836e04ddbb588c2/133268d/winit-x11/src/event_processor.rs:913:21
  30: floem_winit_x11::event_processor::EventProcessor::process_xevent
             at /home/konst/.cargo/git/checkouts/winit-8836e04ddbb588c2/133268d/winit-x11/src/event_processor.rs:200:22
  31: floem_winit_x11::event_processor::EventProcessor::process_event
             at /home/konst/.cargo/git/checkouts/winit-8836e04ddbb588c2/133268d/winit-x11/src/event_processor.rs:83:14
  32: floem_winit_x11::event_loop::EventLoop::drain_events
             at /home/konst/.cargo/git/checkouts/winit-8836e04ddbb588c2/133268d/winit-x11/src/event_loop.rs:630:34
  33: floem_winit_x11::event_loop::EventLoop::single_iteration
             at /home/konst/.cargo/git/checkouts/winit-8836e04ddbb588c2/133268d/winit-x11/src/event_loop.rs:574:14
  34: floem_winit_x11::event_loop::EventLoop::poll_events_with_timeout
             at /home/konst/.cargo/git/checkouts/winit-8836e04ddbb588c2/133268d/winit-x11/src/event_loop.rs:561:14
  35: floem_winit_x11::event_loop::EventLoop::pump_app_events
             at /home/konst/.cargo/git/checkouts/winit-8836e04ddbb588c2/133268d/winit-x11/src/event_loop.rs:481:18
  36: floem_winit_x11::event_loop::EventLoop::run_app_on_demand
             at /home/konst/.cargo/git/checkouts/winit-8836e04ddbb588c2/133268d/winit-x11/src/event_loop.rs:440:24
  37: floem_winit_x11::event_loop::EventLoop::run_app
             at /home/konst/.cargo/git/checkouts/winit-8836e04ddbb588c2/133268d/winit-x11/src/event_loop.rs:431:14
  38: floem_winit::platform_impl::linux::EventLoop::run_app
             at /home/konst/.cargo/git/checkouts/winit-8836e04ddbb588c2/133268d/winit/src/platform_impl/linux/mod.rs:151:61
  39: floem_winit::event_loop::EventLoop::run_app
             at /home/konst/.cargo/git/checkouts/winit-8836e04ddbb588c2/133268d/winit/src/event_loop.rs:204:25
  40: floem::app::Application::run
             at /home/konst/Documents/Projects/Rust/floem/src/app.rs:251:28
  41: floem::app::launch
             at /home/konst/Documents/Projects/Rust/floem/src/app.rs:80:58
  42: editor::main
             at ./src/main.rs:81:5
  43: core::ops::function::FnOnce::call_once
             at /home/konst/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:253:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

ArthurCose avatar Oct 17 '25 23:10 ArthurCose

Similar crash like the one in this issue: #693, when trying to focus editor view. Most likely solution will solve both crashes.

charlescgs avatar Oct 20 '25 13:10 charlescgs