mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 14:01:20 -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(),
|
||||
);
|
||||
} else if single {
|
||||
self.replace_substring(
|
||||
EditableLineTag::Commandline,
|
||||
self.command_line.len()..self.command_line.len(),
|
||||
self.autosuggestion.text[self.command_line.len()..self.command_line.len() + 1]
|
||||
.to_owned(),
|
||||
);
|
||||
let pos = self.command_line.len();
|
||||
if pos + 1 < self.autosuggestion.text.len() {
|
||||
self.replace_substring(
|
||||
EditableLineTag::Commandline,
|
||||
pos..pos,
|
||||
self.autosuggestion.text[pos..pos + 1].to_owned(),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// Accept characters according to the specified style.
|
||||
let mut state = MoveWordStateMachine::new(style);
|
||||
|
||||
@@ -84,3 +84,13 @@ isolated-tmux send-keys 'echo sug' C-w C-z
|
||||
tmux-sleep
|
||||
isolated-tmux capture-pane -p
|
||||
# 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