Fix regression causing builtin commandline to report wrong relative cursor

Regressed in 55fd43d86c (Port reader, 2023-12-22).

Fixes #11085
This commit is contained in:
Johannes Altmanninger 2025-01-26 15:48:21 +01:00
parent 4c28a7771e
commit c651a79cb6
2 changed files with 11 additions and 1 deletions

View File

@ -643,7 +643,9 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
); );
commandline_set_buffer(None, Some(new_pos)); commandline_set_buffer(None, Some(new_pos));
} else { } else {
streams.out.append(sprintf!("%lu\n", current_cursor_pos)); streams
.out
.append(sprintf!("%lu\n", current_cursor_pos - range.start));
} }
return STATUS_CMD_OK; return STATUS_CMD_OK;
} }

View File

@ -9,6 +9,7 @@ set -g isolated_tmux_fish_extra_args -C '
bind ctrl-q "functions --erase fish_right_prompt" "commandline \'\'" clear-screen bind ctrl-q "functions --erase fish_right_prompt" "commandline \'\'" clear-screen
set -g fish_autosuggestion_enabled 0 set -g fish_autosuggestion_enabled 0
bind ctrl-g "__fish_echo commandline --current-job" bind ctrl-g "__fish_echo commandline --current-job"
bind ctrl-t \'__fish_echo echo cursor is at offset $(commandline --cursor --current-token) in token\'
' '
isolated-tmux-start isolated-tmux-start
@ -61,3 +62,10 @@ isolated-tmux capture-pane -p
# CHECK: another job # CHECK: another job
# CHECK: prompt {{\d+}}> echo | echo; # CHECK: prompt {{\d+}}> echo | echo;
# CHECK: another job # CHECK: another job
isolated-tmux send-keys C-q 'echo foobar' Left Left Left C-t
tmux-sleep
# CHECK: prompt {{\d+}}> echo foobar
# CHECK: cursor is at offset 3 in token
# CHECK: prompt {{\d+}}> echo foobar
isolated-tmux capture-pane -p