helix icon indicating copy to clipboard operation
helix copied to clipboard

Crash after using save selection -> smart tab on a new line

Open Omnikar opened this issue 2 years ago • 6 comments

Summary

For context, I have made an insert mode binding of "tab" = ["save_selection", "smart_tab"] so that I can use C-o to go back if I smart tab out too many times. I have encountered this crash as described in the reproduction steps detailed below.

Reproduction Steps

  1. Bind "tab" = ["save_selection", "smart_tab"] in insert mode as described above.
  2. Open a new buffer.
  3. Enter either of the following key sequences:
  • o<tab><esc>
  • i<ret><tab><esc>

Helix crashes with the following error message:

thread 'main' panicked at 'Positions [(2, Before)] are out of range for changeset len 1!', helix-core/src/transaction.rs:461:9

Helix log

Nothing of note was produced in the log file (with -vv).

Platform

MacOS

Terminal Emulator

iTerm2 3.5.0beta11

Helix Version

helix 23.05 (e1a9f6e0)

Omnikar avatar Sep 19 '23 23:09 Omnikar

cc @dead10ck

pascalkuthe avatar Sep 20 '23 11:09 pascalkuthe

Hmm, that's strange, I'll look into this. At first glance, I'm not sure how smart tab could be involved here; all it's doing is moving the cursor. I wouldn't expect it to be any different than, e.g., moving with the arrow keys.

dead10ck avatar Sep 20 '23 12:09 dead10ck

The problem is probably save_selection not working in insert_mode. That seems like the typical "commands assume there is a revision/don't work with insert mode crash

pascalkuthe avatar Sep 20 '23 15:09 pascalkuthe

Right, I forgot to clarify that I did test it without the save_selection binding and it didn't crash.

Omnikar avatar Sep 22 '23 00:09 Omnikar

I encountered it twice too:

thread 'main' panicked at helix-core/src/transaction.rs:461:9:
Positions [(29740, After), (29741, Before)] are out of range for changeset len 28544!

Context for the second encounter:

  • Modified a file while editing
  • Opened a terminal via helix set keybinds and did git restore path/to/file, then closed the terminal
  • Now back in helix, did :reload-all + :wa and proceeded to select inside a function in Insert mode (by moving line by line, holding j)
  • Commented the selection (Ctrl+c) and it crashed while commenting i think
Logs (none relevant)
2023-12-27T20:35:09.224 helix_view::editor [ERROR] Failed to initialize the language servers for `source.toml` - `taplo` { cannot find binary path }
2023-12-27T20:35:18.472 helix_view::editor [ERROR] Failed to initialize the language servers for `source.toml` - `taplo` { cannot find binary path }
2023-12-27T20:35:27.309 helix_lsp::transport [ERROR] Tried sending response into a closed channel (id=Num(371)), original request likely timed out

zuixalias avatar Dec 27 '23 15:12 zuixalias

I encountered it twice too:

thread 'main' panicked at helix-core/src/transaction.rs:461:9:
Positions [(29740, After), (29741, Before)] are out of range for changeset len 28544!

Context for the second encounter:

  • Modified a file while editing
  • Opened a terminal via helix set keybinds and did git restore path/to/file, then closed the terminal
  • Now back in helix, did :reload-all + :wa and proceeded to select inside a function in Insert mode (by moving line by line, holding j)
  • Commented the selection (Ctrl+c) and it crashed while commenting i think

Logs (none relevant)

That's completely ynrekated (the reproduktion cases are nothing alike). That is #6752

pascalkuthe avatar Dec 27 '23 16:12 pascalkuthe