mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 20:47:44 +08:00
Fix commandline -C regression handling negative offsets
This commit is contained in:
parent
947883c842
commit
94477f3029
|
@ -528,8 +528,12 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
|
|||
Ok(num) => num,
|
||||
};
|
||||
|
||||
let new_pos =
|
||||
std::cmp::min(new_pos.max(0) as usize + range.start, current_buffer.len());
|
||||
let new_pos = std::cmp::min(
|
||||
range
|
||||
.start
|
||||
.saturating_add_signed(isize::try_from(new_pos).unwrap()),
|
||||
current_buffer.len(),
|
||||
);
|
||||
commandline_set_buffer(current_buffer.to_owned(), Some(new_pos));
|
||||
} else {
|
||||
streams.out.append(sprintf!("%lu\n", current_cursor_pos));
|
||||
|
|
10
tests/checks/tmux-commandline.fish
Normal file
10
tests/checks/tmux-commandline.fish
Normal file
|
@ -0,0 +1,10 @@
|
|||
#RUN: %fish %s
|
||||
#REQUIRES: command -v tmux
|
||||
|
||||
isolated-tmux-start
|
||||
|
||||
isolated-tmux send-keys 'bind \eg "commandline -p -C -- -4"' Enter C-l
|
||||
isolated-tmux send-keys 'echo bar|cat' \eg foo
|
||||
tmux-sleep
|
||||
isolated-tmux capture-pane -p
|
||||
# CHECK: prompt 1> echo foobar|cat
|
Loading…
Reference in New Issue
Block a user