edit_command_buffer: silence error when editor reports out-of-bounds line number

This happens when using alt-e to edit the command buffer,
adding some lines, leaving the cursor at the end
and quitting the editor without saving.

Let's avoid the noisy error that has sort of bad rendering (would
need __fish_echo).
This commit is contained in:
Johannes Altmanninger 2024-11-01 19:01:50 +01:00
parent 3710e98d65
commit 6525e3d11a

View file

@ -108,7 +108,7 @@ function edit_command_buffer --description 'Edit the command buffer in an extern
eval set -l pos "$(cat $cursor_from_editor)" eval set -l pos "$(cat $cursor_from_editor)"
if set -q pos[1] && test $pos[1] = $f if set -q pos[1] && test $pos[1] = $f
set -l line $pos[2] set -l line $pos[2]
set -l indent (math (string length -- $raw_lines[$line]) - (string length -- $unindented_lines[$line])) set -l indent (math (string length -- "$raw_lines[$line]") - (string length -- "$unindented_lines[$line]"))
set -l column (math $pos[3] - $indent) set -l column (math $pos[3] - $indent)
commandline -C 0 commandline -C 0
for _line in (seq $line)[2..] for _line in (seq $line)[2..]