diff --git a/src/reader.rs b/src/reader.rs index eb76111df..019c5beb0 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -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); diff --git a/tests/checks/tmux-complete.fish b/tests/checks/tmux-complete.fish index f4c060a87..ed22c12fc 100644 --- a/tests/checks/tmux-complete.fish +++ b/tests/checks/tmux-complete.fish @@ -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