mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 03:51:14 -03:00
commandline --showing-suggestion to ignore single-space autosuggestion
All-whitespace autocompletions are invisible, no matter the cursor shape. We do offer such autosuggestions after typing a command name such as "fish". Since the autosuggestion is invisible it's probably not useful. It also does no harm except when using a binding like bind ctrl-g ' if commandline --showing-suggestion commandline -f accept-autosuggestion else up-or-search end' where typing "fish<ctrl-g>" surprisingly does not perform a history search. Fix this by detecting this specific case. In future we could probably stop showing autosuggestions whenever they only contain whitespace.
This commit is contained in:
@@ -963,7 +963,10 @@ pub fn reader_showing_suggestion(parser: &Parser) -> bool {
|
||||
}
|
||||
if let Some(data) = current_data() {
|
||||
let reader = Reader { parser, data };
|
||||
!reader.autosuggestion.is_empty()
|
||||
let suggestion = &reader.autosuggestion.text;
|
||||
let is_single_space = suggestion.ends_with(L!(" "))
|
||||
&& reader.command_line.text() == suggestion[..suggestion.len() - 1];
|
||||
!suggestion.is_empty() && !is_single_space
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user