mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 17:31:14 -03:00
Fix regression in forward-single-char
This crashes if the autosuggesion is exhausted. C++ used
autosuggestion.text.substr(pos, 1)
which throws if pos is OOB but not if pos + 1 is.
This commit is contained in:
@@ -3944,12 +3944,14 @@ fn accept_autosuggestion(
|
|||||||
self.autosuggestion.text.clone(),
|
self.autosuggestion.text.clone(),
|
||||||
);
|
);
|
||||||
} else if single {
|
} else if single {
|
||||||
self.replace_substring(
|
let pos = self.command_line.len();
|
||||||
EditableLineTag::Commandline,
|
if pos + 1 < self.autosuggestion.text.len() {
|
||||||
self.command_line.len()..self.command_line.len(),
|
self.replace_substring(
|
||||||
self.autosuggestion.text[self.command_line.len()..self.command_line.len() + 1]
|
EditableLineTag::Commandline,
|
||||||
.to_owned(),
|
pos..pos,
|
||||||
);
|
self.autosuggestion.text[pos..pos + 1].to_owned(),
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Accept characters according to the specified style.
|
// Accept characters according to the specified style.
|
||||||
let mut state = MoveWordStateMachine::new(style);
|
let mut state = MoveWordStateMachine::new(style);
|
||||||
|
|||||||
@@ -84,3 +84,13 @@ isolated-tmux send-keys 'echo sug' C-w C-z
|
|||||||
tmux-sleep
|
tmux-sleep
|
||||||
isolated-tmux capture-pane -p
|
isolated-tmux capture-pane -p
|
||||||
# CHECK: prompt 6> echo suggest this
|
# CHECK: prompt 6> echo suggest this
|
||||||
|
|
||||||
|
isolated-tmux send-keys C-u 'bind \cs forward-single-char' Enter C-l
|
||||||
|
isolated-tmux send-keys 'echo suggest thi'
|
||||||
|
tmux-sleep
|
||||||
|
isolated-tmux send-keys C-s
|
||||||
|
tmux-sleep
|
||||||
|
isolated-tmux send-keys C-s
|
||||||
|
tmux-sleep
|
||||||
|
isolated-tmux capture-pane -p
|
||||||
|
# CHECK: prompt 7> echo suggest this
|
||||||
|
|||||||
Reference in New Issue
Block a user