helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
32.89k stars 2.43k forks source link

Panic when incrementing two -1 values #2019

Closed n0s4 closed 1 year ago

n0s4 commented 2 years ago

Summary

The original summary included a lot of context that isn't related. After some discussion this is what has been found.

If you have a file with the following:

-1
-1

And you enter the following keystrokes: % s - <enter> C-a

Helix panics.

This doesn't happen when there is a character, space or empty line after the two lines:

-1
-1

(Helix doesn't panic with the above input on this text)

Here is the backtrace with RUST_BACKTRACE=1:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Char index out of bounds: char index 4, Rope/RopeSlice char length 3', /home/jm/.cargo/registry/src/github.com-1ecc6299db9ec823/ropey-1.4.1/src/slice.rs:349:41
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
   2: core::result::unwrap_failed
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/result.rs:1690:5
   3: ropey::slice::RopeSlice::char_to_byte
   4: helix_core::graphemes::nth_next_grapheme_boundary
   5: helix_core::selection::Range::grapheme_aligned
   6: helix_core::selection::Selection::ensure_invariants
   7: helix_view::document::Document::apply_impl
   8: helix_view::document::Document::apply
   9: helix_term::commands::increment_impl
  10: helix_term::ui::editor::EditorView::handle_keymap_event
  11: <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event
  12: helix_term::compositor::Compositor::handle_event
  13: helix_term::application::Application::handle_terminal_events
  14: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  15: tokio::park::thread::CachedParkThread::block_on
  16: tokio::runtime::thread_pool::ThreadPool::block_on
  17: tokio::runtime::Runtime::block_on
  18: hx::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I also now updated the Helix version to my now current version on this issue because this bug still exists at the time of writing.

Helix log

~/.cache/helix/helix.log ``` please provide a copy of `~/.cache/helix/helix.log` here if possible, you may need to redact some of the lines [helix.log](https://github.com/helix-editor/helix/files/8451943/helix.log) ```

Platform

Linux

Terminal Emulator

alacritty

Helix Version

22.03-105-gcc68fa85

sudormrfbin commented 2 years ago

Putting the cursor on -- doesn't seem to trigger a panic, I suppose it's something else in the date format. Could you upload it as gist and post the link ?

n0s4 commented 2 years ago

Here's the file.

the-mikedavis commented 2 years ago

full backtrace:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Char index out of bounds: char index 61591, Rope/RopeSlice char length 61574', /sources/ropey-1.4.1/src/slice.rs:349:41
stack backtrace:
   0:     0x56150e64600c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3e2b509ce2ce6007
   1:     0x56150dfb5cbc - core::fmt::write::h753c7571fa063ecb
   2:     0x56150e63e435 - std::io::Write::write_fmt::h2815c0519c99ba09
   3:     0x56150e6491b5 - std::panicking::default_hook::{{closure}}::h78d3e6cf97fc623d
   4:     0x56150e648e33 - std::panicking::default_hook::hda898f8d3ad1a5ae
   5:     0x56150e50bf83 - helix_term::application::Application::run::{{closure}}::{{closure}}::hc426ef4564b0e6dc
   6:     0x56150e649861 - std::panicking::rust_panic_with_hook::h1a5ea2d6c23051aa
   7:     0x56150e64952a - std::panicking::begin_panic_handler::{{closure}}::h07f549390938b73f
   8:     0x56150e646534 - std::sys_common::backtrace::__rust_end_short_backtrace::h5ec3758a92cfb00d
   9:     0x56150e64928d - rust_begin_unwind
  10:     0x56150df3ed01 - core::panicking::panic_fmt::h3a79a6a99affe1d5
  11:     0x56150df3edf3 - core::result::unwrap_failed::ha0327e3803285d6e
  12:     0x56150e0893a6 - ropey::slice::RopeSlice::char_to_byte::h0af44ccbe88700cc
  13:     0x56150e08480c - helix_core::graphemes::nth_prev_grapheme_boundary::h5c28fa1317d8600c
  14:     0x56150e07c4d6 - helix_core::selection::Range::grapheme_aligned::hf4ffb7d6cb9c3d84
  15:     0x56150e07d780 - helix_core::selection::Selection::ensure_invariants::hd5a8655b0c6a9c70
  16:     0x56150e4a6fda - helix_view::document::Document::apply_impl::h38f4b5293e7b8ecc
  17:     0x56150e4a7ac6 - helix_view::document::Document::apply::hcfa99bb58b977fb3
  18:     0x56150e3931b5 - helix_term::commands::increment_impl::had10c25cd4071978
  19:     0x56150e2b56c8 - helix_term::ui::editor::EditorView::handle_keymap_event::hf4edf6a934fbb87f
  20:     0x56150e2b7700 - <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event::h0b0e7a1fa2584923
  21:     0x56150e2cd04f - helix_term::compositor::Compositor::handle_event::h87dab55883cec336
  22:     0x56150e2a6996 - helix_term::application::Application::handle_terminal_events::h130d19f94094b8a4
  23:     0x56150e51a738 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h36ed2d9911f7fb67
  24:     0x56150e4e5f5e - tokio::park::thread::CachedParkThread::block_on::hcb853cc0519d735f
  25:     0x56150e4de9b9 - tokio::runtime::thread_pool::ThreadPool::block_on::he629f9db7d969a72
  26:     0x56150e4fa88c - tokio::runtime::Runtime::block_on::h93d2d6fd504ee5ea
  27:     0x56150e4db81a - hx::main::ha4fd9378bdb017e0
  28:     0x56150e4e71e3 - std::sys_common::backtrace::__rust_begin_short_backtrace::ha7074b1a8ee7fe5e
  29:     0x56150e4fa62d - std::rt::lang_start::{{closure}}::hbdc5c69d8a3ab41d
  30:     0x56150e64566e - std::rt::lang_start_internal::h52e73755f77c7dd9
  31:     0x56150e4df592 - main
  32:     0x7fb37ed4c790 - __libc_start_main
  33:     0x56150df6bf2a - _start
  34:                0x0 - <unknown>
sudormrfbin commented 2 years ago

I managed to reproduce this with a subset of the file (with about 240 lines):

Test file (click to expand) ``` "2026-10-1": "WOMEN", "2026-10-2": "MUCUS", "2026-10-3": "BOAST", "2026-10-4": "TODDY", "2026-10-5": "COVEN", "2026-10-6": "TUMOR", "2026-10-7": "TRUER", "2026-10-8": "WRATH", "2026-10-9": "STALL", "2026-10-10": "STEAM", "2026-10-11": "AXIAL", "2026-10-12": "PURER", "2026-10-13": "DAILY", "2026-10-14": "TRAIL", "2026-10-15": "NICHE", "2026-10-16": "MEALY", "2026-10-17": "JUICE", "2026-10-18": "NYLON", "2026-10-19": "PLUMP", "2026-10-20": "MERRY", "2026-10-21": "FLAIL", "2026-10-22": "PAPAL", "2026-10-23": "WHEAT", "2026-10-24": "BERRY", "2026-10-25": "COWER", "2026-10-26": "ERECT", "2026-10-27": "BRUTE", "2026-10-28": "LEGGY", "2026-10-29": "SNIPE", "2026-11--1": "SINEW", "2026-11-0": "SKIER", "2026-11-1": "PENNY", "2026-11-2": "JUMPY", "2026-11-3": "RALLY", "2026-11-4": "UMBRA", "2026-11-5": "SCARY", "2026-11-6": "MODEM", "2026-11-7": "GROSS", "2026-11-8": "AVIAN", "2026-11-9": "GREED", "2026-11-10": "SATIN", "2026-11-11": "TONIC", "2026-11-12": "PARKA", "2026-11-13": "SNIFF", "2026-11-14": "LIVID", "2026-11-15": "STARK", "2026-11-16": "TRUMP", "2026-11-17": "GIDDY", "2026-11-18": "REUSE", "2026-11-19": "TABOO", "2026-11-20": "AVOID", "2026-11-21": "QUOTE", "2026-11-22": "DEVIL", "2026-11-23": "LIKEN", "2026-11-24": "GLOSS", "2026-11-25": "GAYER", "2026-11-26": "BERET", "2026-11-27": "NOISE", "2026-11-28": "GLAND", "2026-12--1": "DEALT", "2026-12-0": "SLING", "2026-12-1": "RUMOR", "2026-12-2": "OPERA", "2026-12-3": "THIGH", "2026-12-4": "TONGA", "2026-12-5": "FLARE", "2026-12-6": "WOUND", "2026-12-7": "WHITE", "2026-12-8": "BULKY", "2026-12-9": "ETUDE", "2026-12-10": "HORSE", "2026-12-11": "CIRCA", "2026-12-12": "PADDY", "2026-12-13": "INBOX", "2026-12-14": "FIZZY", "2026-12-15": "GRAIN", "2026-12-16": "EXERT", "2026-12-17": "SURGE", "2026-12-18": "GLEAM", "2026-12-19": "BELLE", "2026-12-20": "SALVO", "2026-12-21": "CRUSH", "2026-12-22": "FRUIT", "2026-12-23": "SAPPY", "2026-12-24": "TAKER", "2026-12-25": "TRACT", "2026-12-26": "OVINE", "2026-12-27": "SPIKY", "2026-12-28": "FRANK", "2026-12-29": "REEDY", "2027-01--1": "FILTH", "2027-01-0": "SPASM", "2027-01-1": "HEAVE", "2027-01-2": "MAMBO", "2027-01-3": "RIGHT", "2027-01-4": "CLANK", "2027-01-5": "TRUST", "2027-01-6": "LUMEN", "2027-01-7": "BORNE", "2027-01-8": "SPOOK", "2027-01-9": "SAUCE", "2027-01-10": "AMBER", "2027-01-11": "LATHE", "2027-01-12": "CARAT", "2027-01-13": "CORER", "2027-01-14": "DIRTY", "2027-01-15": "SLYLY", "2027-01-16": "AFFIX", "2027-01-17": "ALLOY", "2027-01-18": "TAINT", "2027-01-19": "SHEEP", "2027-01-20": "KINKY", "2027-01-21": "WOOLY", "2027-01-22": "MAUVE", "2027-01-23": "FLUNG", "2027-01-24": "YACHT", "2027-01-25": "FRIED", "2027-01-26": "QUAIL", "2027-01-27": "BRUNT", "2027-01-28": "GRIMY", "2027-01-29": "CURVY", "2027-02--1": "CAGEY", "2027-02-0": "RINSE", "2027-02-1": "DEUCE", "2027-02-2": "STATE", "2027-02-3": "GRASP", "2027-02-4": "MILKY", "2027-02-5": "BISON", "2027-02-6": "GRAFT", "2027-02-7": "SANDY", "2027-02-8": "BASTE", "2027-02-9": "FLASK", "2027-02-10": "HEDGE", "2027-02-11": "GIRLY", "2027-02-12": "SWASH", "2027-02-13": "BONEY", "2027-02-14": "COUPE", "2027-02-15": "ENDOW", "2027-02-16": "ABHOR", "2027-02-17": "WELCH", "2027-02-18": "BLADE", "2027-02-19": "TIGHT", "2027-02-20": "GEESE", "2027-02-21": "MISER", "2027-02-22": "MIRTH", "2027-02-23": "CLOUD", "2027-02-24": "CABAL", "2027-02-25": "LEECH", "2027-02-26": "CLOSE", "2027-03--1": "TENTH", "2027-03-0": "PECAN", "2027-03-1": "DROIT", "2027-03-2": "GRAIL", "2027-03-3": "CLONE", "2027-03-4": "GUISE", "2027-03-5": "RALPH", "2027-03-6": "TANGO", "2027-03-7": "BIDDY", "2027-03-8": "SMITH", "2027-03-9": "MOWER", "2027-03-10": "PAYEE", "2027-03-11": "SERIF", "2027-03-12": "DRAPE", "2027-03-13": "FIFTH", "2027-03-14": "SPANK", "2027-03-15": "GLAZE", "2027-03-16": "ALLOT", "2027-03-17": "TRUCK", "2027-03-18": "KAYAK", "2027-03-19": "VIRUS", "2027-03-20": "TESTY", "2027-03-21": "TEPEE", "2027-03-22": "FULLY", "2027-03-23": "ZONAL", "2027-03-24": "METRO", "2027-03-25": "CURRY", "2027-03-26": "GRAND", "2027-03-27": "BANJO", "2027-03-28": "AXION", "2027-03-29": "BEZEL", "2027-04--1": "OCCUR", "2027-04-0": "CHAIN", "2027-04-1": "NASAL", "2027-04-2": "GOOEY", "2027-04-3": "FILER", "2027-04-4": "BRACE", "2027-04-5": "ALLAY", "2027-04-6": "PUBIC", "2027-04-7": "RAVEN", "2027-04-8": "PLEAD", "2027-04-9": "GNASH", "2027-04-10": "FLAKY", "2027-04-11": "MUNCH", "2027-04-12": "DULLY", "2027-04-13": "EKING", "2027-04-14": "THING", "2027-04-15": "SLINK", "2027-04-16": "HURRY", "2027-04-17": "THEFT", "2027-04-18": "SHORN", "2027-04-19": "PYGMY", "2027-04-20": "RANCH", "2027-04-21": "WRING", "2027-04-22": "LEMON", "2027-04-23": "SHORE", "2027-04-24": "MAMMA", "2027-04-25": "FROZE", "2027-04-26": "NEWER", "2027-04-27": "STYLE", "2027-04-28": "MOOSE", "2027-05--1": "ANTIC", "2027-05-0": "DROWN", "2027-05-1": "VEGAN", "2027-05-2": "CHESS", "2027-05-3": "GUPPY", "2027-05-4": "UNION", "2027-05-5": "LEVER", "2027-05-6": "LORRY", "2027-05-7": "IMAGE", "2027-05-8": "CABBY", "2027-05-9": "DRUID", "2027-05-10": "EXACT", "2027-05-11": "TRUTH", "2027-05-12": "DOPEY", "2027-05-13": "SPEAR", "2027-05-14": "CRIED", "2027-05-15": "CHIME", "2027-05-16": "CRONY", "2027-05-17": "STUNK", "2027-05-18": "TIMID", "2027-05-19": "BATCH", "2027-05-20": "GAUGE", "2027-05-21": "ROTOR", "2027-05-22": "CRACK", "2027-05-23": "CURVE", "2027-05-24": "LATTE", "2027-05-25": "WITCH", "2027-05-26": "BUNCH", ```

Backtrace:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Char index out of bounds: char index 5908, Rope/RopeSlice char length 5905', /home/gokul/.cargo/registry/src/github.com-1ecc6299db9ec823/ropey-1.4.1/src/slice.rs:349:41
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
   2: core::result::unwrap_failed
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/result.rs:1690:5
   3: ropey::slice::RopeSlice::char_to_byte
   4: helix_core::graphemes::nth_prev_grapheme_boundary
   5: helix_core::selection::Range::grapheme_aligned
   6: helix_core::selection::Selection::ensure_invariants
   7: helix_view::document::Document::apply_impl
   8: helix_view::document::Document::apply
   9: helix_term::commands::increment_impl
  10: helix_term::ui::editor::EditorView::handle_keymap_event
  11: <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event
  12: helix_term::compositor::Compositor::handle_event
  13: helix_term::application::Application::handle_terminal_events
  14: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  15: tokio::park::thread::CachedParkThread::block_on
  16: tokio::runtime::thread_pool::ThreadPool::block_on
  17: tokio::runtime::Runtime::block_on
  18: hx::main

Compiling in debug mode also triggered a debug assert:

https://github.com/helix-editor/helix/blob/59f05088b9628086b35631338e49ae8f061dcba2/helix-core/src/graphemes.rs#L35-L38

Debug backtrace::handle_event at ./helix-term/src/ui/editor.rs:1148:33 18: helix_term::compositor::Compositor::handle_event at ./helix-term/src/compositor.rs:147:19 19: helix_term::application::Application::handle_terminal_events at ./helix-term/src/application.rs:363:32 20: helix_term::application::Application::event_loop::{{closure}} at ./helix-term/src/application.rs:217:21 21: as core::future::future::Future>::poll at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/future/mod.rs:84:19 22: helix_term::application::Application::run::{{closure}} at ./helix-term/src/application.rs:720:26 23: as core::future::future::Future>::poll at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/future/mod.rs:84:19 24: hx::main_impl::{{closure}} at ./helix-term/src/main.rs:142:30 25: as core::future::future::Future>::poll at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/future/mod.rs:84:19 26: tokio::park::thread::CachedParkThread::block_on::{{closure}} at /home/gokul/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/park/thread.rs:263:54 27: tokio::coop::with_budget::{{closure}} at /home/gokul/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/coop.rs:102:9 28: std::thread::local::LocalKey::try_with at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/thread/local.rs:413:16 29: std::thread::local::LocalKey::with at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/thread/local.rs:389:9 30: tokio::coop::with_budget at /home/gokul/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/coop.rs:95:5 31: tokio::coop::budget at /home/gokul/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/coop.rs:72:5 32: tokio::park::thread::CachedParkThread::block_on at /home/gokul/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/park/thread.rs:263:31 33: tokio::runtime::enter::Enter::block_on at /home/gokul/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/enter.rs:151:13 34: tokio::runtime::thread_pool::ThreadPool::block_on at /home/gokul/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/thread_pool/mod.rs:73:9 35: tokio::runtime::Runtime::block_on at /home/gokul/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.17.0/src/runtime/mod.rs:477:43 36: hx::main_impl at ./helix-term/src/main.rs:144:5 37: hx::main at ./helix-term/src/main.rs:36:21 38: core::ops::function::FnOnce::call_once at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5 ```
n0s4 commented 2 years ago

I have narrowed this further to just 49 lines, cutting out the words, symbols, and the year part of the date: subset.txt This still crashes with the following keystrokes: %, s, -, enter, l (L), C-a

n0s4 commented 2 years ago

Ok, I've pushed this to as small a file as I can, just three lines: sub.txt Just selecting the 2nd character of every line and C-a panics. Still can't say what causes it though.

Edit, full backtrace:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Char index out of bounds: char index 10, Rope/RopeSlice char length 7', /home/jm/.cargo/registry/src/github.com-1ecc6299db9ec823/ropey-1.4.1/src/slice.rs:349:41
stack backtrace:
   0:     0x556d1768357c - std::backtrace_rs::backtrace::libunwind::trace::h91c465e73bf6c785
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x556d1768357c - std::backtrace_rs::backtrace::trace_unsynchronized::hae9da36f5d58b5f3
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x556d1768357c - std::sys_common::backtrace::_print_fmt::h7f499fa126a7effb
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x556d1768357c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3e2b509ce2ce6007
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x556d16fd6c6c - core::fmt::write::h753c7571fa063ecb
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/fmt/mod.rs:1168:17
   5:     0x556d1767b9a5 - std::io::Write::write_fmt::h2815c0519c99ba09
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/io/mod.rs:1660:15
   6:     0x556d17686725 - std::sys_common::backtrace::_print::h64941a6fc8b0ed9b
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x556d17686725 - std::sys_common::backtrace::print::hcf25e43e1a9b0766
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x556d17686725 - std::panicking::default_hook::{{closure}}::h78d3e6cf97fc623d
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:211:50
   9:     0x556d176863a3 - std::panicking::default_hook::hda898f8d3ad1a5ae
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:228:9
  10:     0x556d17547453 - helix_term::application::Application::run::{{closure}}::{{closure}}::h7fba2e9e000873a0
  11:     0x556d17686dd1 - std::panicking::rust_panic_with_hook::h1a5ea2d6c23051aa
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:610:17
  12:     0x556d17686a9a - std::panicking::begin_panic_handler::{{closure}}::h07f549390938b73f
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:502:13
  13:     0x556d17683aa4 - std::sys_common::backtrace::__rust_end_short_backtrace::h5ec3758a92cfb00d
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:139:18
  14:     0x556d176867fd - rust_begin_unwind
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
  15:     0x556d16f5fd01 - core::panicking::panic_fmt::h3a79a6a99affe1d5
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
  16:     0x556d16f5fdf3 - core::result::unwrap_failed::ha0327e3803285d6e
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/result.rs:1690:5
  17:     0x556d170cb3f6 - ropey::slice::RopeSlice::char_to_byte::ha86b76a66055fcaa
  18:     0x556d170c720c - helix_core::graphemes::nth_prev_grapheme_boundary::h704daf53b87885f9
  19:     0x556d170b9966 - helix_core::selection::Range::grapheme_aligned::h80339e72d9d0845b
  20:     0x556d170bc800 - helix_core::selection::Selection::ensure_invariants::h7b4a4bfd12de95c4
  21:     0x556d174e264a - helix_view::document::Document::apply_impl::ha65b43cb55bb1c55
  22:     0x556d174e3136 - helix_view::document::Document::apply::hf9bf7e10d2ce8d17
  23:     0x556d173cc477 - helix_term::commands::increment_impl::he979b06601b5a79f
  24:     0x556d172e3d68 - helix_term::ui::editor::EditorView::handle_keymap_event::h6ca6ed20204ecc2c
  25:     0x556d172e5da0 - <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event::h95eda4dddaccdaa6
  26:     0x556d172fc13f - helix_term::compositor::Compositor::handle_event::h6baf5e9ddc3de8e5
  27:     0x556d172d4a86 - helix_term::application::Application::handle_terminal_events::h868b8f22bdea5c41
  28:     0x556d17554168 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h71cc7bf01ac22b4a
  29:     0x556d175213fe - tokio::park::thread::CachedParkThread::block_on::h9c4b5e136af251c7
  30:     0x556d17517ef9 - tokio::runtime::thread_pool::ThreadPool::block_on::h712340e0327fa2d4
  31:     0x556d17535f5c - tokio::runtime::Runtime::block_on::h23ce243dbb76cfa2
  32:     0x556d1752082a - hx::main::h4257d6a18d3e40c1
  33:     0x556d17522793 - std::sys_common::backtrace::__rust_begin_short_backtrace::h7c1268abc06e485c
  34:     0x556d17535cfd - std::rt::lang_start::{{closure}}::h3ae220954d80377b
  35:     0x556d17682bde - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h443f738a8e9f947a
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/ops/function.rs:259:13
  36:     0x556d17682bde - std::panicking::try::do_call::h1e21ba261ba489ec
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:406:40
  37:     0x556d17682bde - std::panicking::try::h6afd48af8b6c96ac
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:370:19
  38:     0x556d17682bde - std::panic::catch_unwind::h85dd95e0bab7fb60
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panic.rs:133:14
  39:     0x556d17682bde - std::rt::lang_start_internal::{{closure}}::h038455e697c8b03e
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/rt.rs:128:48
  40:     0x556d17682bde - std::panicking::try::do_call::h6b0ad65979f3077a
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:406:40
  41:     0x556d17682bde - std::panicking::try::h010108d314169ac6
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:370:19
  42:     0x556d17682bde - std::panic::catch_unwind::hff397f912b1535c2
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panic.rs:133:14
  43:     0x556d17682bde - std::rt::lang_start_internal::h52e73755f77c7dd9
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/rt.rs:128:20
  44:     0x556d17523e52 - main
  45:     0x7f0f03671fd0 - <unknown>
  46:     0x7f0f0367207d - __libc_start_main
  47:     0x556d16f8ced5 - _start
  48:                0x0 - <unknown>
sudormrfbin commented 2 years ago

It seems to be a problem with changing a -1 to 0 (ctrl-a is increment by one so -1 + 1 = 0) and then calculating the subsequent cursor position; it doesn't have to do anything with dates at all (the original text contained strings like 2021-07--1 and therefore ctrl-a probably didn't change by date anyway).

With this text:

-1
-1

put the cursor on the two minuses (%s-<enter>) and hit ctrl-a to cause the panic. Interestingly the panic doesn't happen if there is a newline after the last 1, i.e.

-1
-1
n0s4 commented 2 years ago

Strange. I am very much new to helix, and I'm not in a position to start looking into the code myself so I can't really help much further.