Crash In Vim Mode With 'ge' Motion On 2-Byte Characters (e.g., Ó, €)
Summary
When using Vim mode in Zed, the editor crashes if you use the reverse motion ge
(go to end of previous word) while the cursor is on a 2-byte character, such as ó
or €
.
Description
Steps to Trigger the Problem
To reproduce this issue, follow these steps:
- Switch to Vim mode in Zed: Open Zed and switch to Vim mode by clicking on the mode selector or pressing
Esc
to enter command mode. - Open a file or insert text containing a 2-byte character: Open a new file or insert text containing a 2-byte character, such as
ó
or€
. - Place the cursor on the 2-byte character: Move the cursor to the 2-byte character using the arrow keys or other navigation commands.
- Press
ge
to trigger the reverse motion: Press thege
key combination to trigger the reverse motion and move the cursor to the end of the previous word.
Actual Behavior
When you press ge
while the cursor is on a 2-byte character, the editor crashes immediately.
Expected Behavior
The expected behavior is that the cursor should move to the end of the previous word without crashing.
Zed Version and System Specs
Zed Version
- Zed: v0.186.9 (Zed)
System Specs
- OS: Linux Wayland arch unknown
- Memory: 15.2 GiB
- Architecture: x86_64
- GPU: Intel(R) Iris(R) Plus Graphics (ICL GT2) || Intel open-source Mesa driver || Mesa 25.0.5-arch1.1
Log File
The log file attached to this issue contains the following error message:
2025-05-18T18:45:58+02:00 ERROR [zed::reliability] {
"thread": "main",
"payload": "byte index 10 is not a char boundary; it is inside '€' (bytes 9..12) of `test the € character\n`",
"location_data": {
"file": "crates/rope/src/rope.rs",
"line": 772
},
"backtrace": [
"zed::reliability::init_panic_hook::{{closure}}::hd6958bb9d75896d2+149038150",
"std::panicking::rust_panic_with_hook::h541791bcc774ef34+121500819",
"std::panicking::begin_panic_handler::{{closure}}::h6479a2f0137c7d19+121500042",
"std::sys::backtrace::__rust_end_short_backtrace::ha04e7c0fc61ded91+121493561",
"rust_begin_unwind+121499181",
"core::panicking::panic_fmt::h5764ee7030b7a73d+8894000",
"core::str::slice_error_fail_rt::h95fb5a3efddd85ad+41187143",
"core::str::slice_error_fail::hbde71130ea7318aa+8895370",
"rope::Chunks::peek::h7d10fe5a758e801+115396758",
"<rope::Chunks as core::iter::traits::iterator::Iterator>::next::h1032cc99dd7c6bdf+115397632",
"<multi_buffer::ReversedMultiBufferChunks as core::iter::traits::iterator::Iterator>::next::h74f6fc6929cec59f+88436624",
"<core::iter::adapters::flatten::FlattenCompat<I,U> as core::iter::traits::iterator::Iterator>::next::ha76ea92b182907c2+131824921",
"vim::motion::previous_word_end::h2433e4729afc67f7+133483454",
"vim::motion::Motion::move_point::h84a0be201693ca58+133472403",
"vim::normal::<impl vim::Vim>::move_cursor::h12e59f9ef4a165ed+133741368",
"vim::normal::<impl vim::Vim>::normal_motion::ha924872775454bdf+133714831",
"vim::motion::<impl vim::Vim>::motion::h667e31136ac8ac7d+133471216",
"editor::Editor::register_action::{{closure}}::{{closure}}::h9f3f8e0113be063c+132977700",
"gpui::window::Window::dispatch_action_on_node::hf1c831bf8b8d40c2+71083855",
"gpui::window::Window::dispatch_event::haef88848bf7bdbf0+71159581",
"gpui::window::Window::new::{{closure}}::hedfac7913180e35e+71015010",
"gpui::platform::linux::wayland::window::WaylandWindowStatePtr::handle_input::h20f96aedb3c7054c+70558312",
"<gpui::platform::linux::wayland::client::WaylandClientStatePtr as wayland_client::event_queue::Dispatch<wayland_client::protocol::wl_keyboard::WlKeyboard,()>>::event::ha606e326a62c3057+70487212",
"wayland_client::event_queue::queue_callback::ha5aa848661d1285e+67307197",
"<core::cell::RefCell<calloop::sources::DispatcherInner<S,F>> as calloop::sources::EventDispatcher<Data>>::process_events::hf5b11128309d3b9a+67277170",
"<gpui::platform::linux::wayland::client::WaylandClient as gpui::platform::linux::platform::LinuxClient>::run::h274a00bd7842ad81+70438612",
"gpui::platform::linux::platform::<impl gpui::platform::Platform for P>::run::h65b9651c3c6d5326+70290605",
"gpui::app::Application::run::h2295b3aa488b367b+146001716",
"zed::main::h779a51b726c887e7+148395077",
"std::sys::backtrace::__rust_begin_short_backtrace::h9a92f2d035749930+149725251",
"std::rt::lang_start::{{closure}}::h005b3ad262729908+148807881",
"stdrt::lang_start_internal::h15895544e2012228+121424401",
"main+148414252",
"__libc_start_main+31613162903401",
"_start+11256046"
],
"app_version": "0.186.9",
"app_commit_sha": "5b61a59e6cd533bc8dec94fbd3738bec2b0d042a",
"release_channel": "stable",
"target": "x86_64-unknown-linux-gnu",
"os_name": "Linux Wayland",
"os_version": "arch unknown",
"architecture": "x86_64",
"panicked_on": 1747586758134,
"system_id": "fc35e1ca-a957-48b4-aec8-c80defa75915",
"installation_id": "00e8012f-69ce-488a-be95-5fe052730b54",
"session_id": "08694c08-ab90-4f05-9efc-176c6d4f1bad"
}
Possible Causes
The error message suggests that the issue is related to the way Zed handles 2-byte characters. Specifically, the error message mentions that the byte index 10 is not a char boundary, which suggests that the issue is related to the way Zed handles the boundaries between characters.
Possible Solutions
To fix this issue, we may need to modify the way Zed handles 2-byte characters. This could involve changing the way Zed splits text into individual characters, or modifying the way Zed handles the boundaries between characters.
Conclusion
The issue described in this article is a bug in Zed that causes the editor to crash when using the ge
motion on 2-byte characters. The error message suggests that the issue is related to the way Zed handles 2-byte characters, and possible solutions may involve modifying the way Zed handles these characters.
Future Work
To further investigate this issue, we may need to:
- Modify the way Zed handles 2-byte characters
- Test the modified code to ensure that it fixes the issue
- Verify that the modified code does not introduce any new issues
Related Issues
This issue may be related to other issues in Zed that involve handling 2-byte characters. To investigate this further, we may need to:
- Review the code for other issues that involve handling 2-byte characters
- Test the code to ensure that it fixes the issue
- Verify that the modified code does not introduce any new issues
References
- Zed documentation
- [Vim documentation](https://vim
Q: What is the issue with using 'ge' motion on 2-byte characters in Vim mode?
A: When using the ge
motion on 2-byte characters in Vim mode, the editor crashes due to an error in handling the boundaries between characters.
Q: What are 2-byte characters?
A: 2-byte characters are characters that are represented by two bytes in a character encoding, such as UTF-8. Examples of 2-byte characters include ó, €, and others.
Q: What is the expected behavior when using 'ge' motion on 2-byte characters?
A: The expected behavior is that the cursor should move to the end of the previous word without crashing.
Q: What is the actual behavior when using 'ge' motion on 2-byte characters?
A: The actual behavior is that the editor crashes immediately when using the ge
motion on 2-byte characters.
Q: What is the error message that is displayed when the editor crashes?
A: The error message is:
2025-05-18T18:45:58+02:00 ERROR [zed::reliability] {
"thread": "main",
"payload": "byte index 10 is not a char boundary; it is inside '€' (bytes 9..12) of `test the € character\n`",
"location_data": {
"file": "crates/rope/src/rope.rs",
"line": 772
},
"backtrace": [
...
],
"app_version": "0.186.9",
"app_commit_sha": "5b61a59e6cd533bc8dec94fbd3738bec2b0d042a",
"release_channel": "stable",
"target": "x86_64-unknown-linux-gnu",
"os_name": "Linux Wayland",
"os_version": "arch unknown",
"architecture": "x86_64",
"panicked_on": 1747586758134,
"system_id": "fc35e1ca-a957-48b4-aec8-c80defa75915",
"installation_id": "00e8012f-69ce-488a-be95-5fe052730b54",
"session_id": "08694c08-ab90-4f05-9efc-176c6d4f1bad"
}
Q: What are the possible causes of this issue?
A: The possible causes of this issue are related to the way Zed handles 2-byte characters. Specifically, the issue may be related to the way Zed splits text into individual characters, or the way Zed handles the boundaries between characters.
Q: What are the possible solutions to this issue?
A: The possible solutions to this issue may involve modifying the way Zed handles 2-byte characters. This could involve changing the way Zed splits text into individual characters, or modifying the way Zed handles the boundaries between characters.
Q: How can I test the modified code to ensure that it fixes the issue?
A: To test the modified code, you can try using the ge
motion on 2-byte characters in Vim mode and verify that the editor does not crash.
Q: How can I verify that the modified code does not introduce any new issues?
A: To verify that the modified code does not introduce any new issues, you can try using the ge
motion on 2-byte characters in Vim mode and verify that the editor behaves as expected.
Q: Are there any related issues that I should be aware of?
A: Yes, there may be related issues that involve handling 2-byte characters. To investigate this further, you may need to review the code for other issues that involve handling 2-byte characters.
Q: Where can I find more information about this issue?
A: You can find more information about this issue in the Zed documentation and the Vim documentation.