helix
helix copied to clipboard
Switch to regex-cursor
Closes #185
Replaces our use of regex with regex-cursor, so we don't have to convert ropes to string. That implementation passes the regex testsuite so it should be stable but definitely needs testing.
See discussion at https://github.com/rust-lang/regex/issues/425.
I used the chance to replace split_at_newline with something that uses ropey so that unicode feature flags are correctly respected (should also be slightly faster).
Crashed with (not sure what I did)
thread 'main' panicked at /home/sumire/.cargo/registry/src/index.crates.io-6f17d22bba15001f/regex-cursor-0.1.2/src/input.rs:204:13:
internal error: entered unreachable code: cursor does not support backtracking 506
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: regex_cursor::engines::dfa::search::find_fwd
3: regex_cursor::engines::dfa::try_search
4: regex_cursor::engines::meta::strategy::StrategyI::search
5: regex_cursor::engines::meta::regex::Regex::search
6: helix_term::commands::search_impl
7: helix_term::commands::search_next_or_prev_impl
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: hx::main_impl::{{closure}}
13: tokio::runtime::park::CachedParkThread::block_on
14: tokio::runtime::context::runtime::enter_runtime
15: tokio::runtime::runtime::Runtime::block_on
16: hx::main
Crashed with (not sure what I did)
thread 'main' panicked at /home/sumire/.cargo/registry/src/index.crates.io-6f17d22bba15001f/regex-cursor-0.1.2/src/input.rs:204:13: internal error: entered unreachable code: cursor does not support backtracking 506 stack backtrace: 0: rust_begin_unwind 1: core::panicking::panic_fmt 2: regex_cursor::engines::dfa::search::find_fwd 3: regex_cursor::engines::dfa::try_search 4: regex_cursor::engines::meta::strategy::StrategyI::search 5: regex_cursor::engines::meta::regex::Regex::search 6: helix_term::commands::search_impl 7: helix_term::commands::search_next_or_prev_impl 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: hx::main_impl::{{closure}} 13: tokio::runtime::park::CachedParkThread::block_on 14: tokio::runtime::context::runtime::enter_runtime 15: tokio::runtime::runtime::Runtime::block_on 16: hx::main
Thats a stranfe one that shouldn't happen but it's very hard to track down without reproduction case (the backtrack is too stripped because it's a release build)
Ah, it's hx
then /git nix
. This is on a personal fork with multiple PRs pulled in (I forgot to mention) but I don't think any of them touch regex.
Edit: I can reproduce with this branch alone
oh yeah I can reproduce that is very odd. Is suspect it has do do with the special case of an empty file
I don't think it's a special case with an empty file. If you delete the entire buffer and then do /git n
it won't crash. If you add a new line and then 1G
, it won't crash. If you add a new line without moving the cursor, it crashes. Maybe it has something to do with the cursor being on the line before the EOF newline?
It was an edgecase when you search for stuff at a one-past-the-end position which is what I suspected. Adapting the ropey cursor semantics to the one regex-cusor uses isn't trivial. I published a new version where that is fixed
I also haven't hit any bugs with this anymore