From cd3b6f912488f2d30d46f78a023d9197cffcfc1f Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Wed, 30 Oct 2024 06:19:04 +0100 Subject: [PATCH] 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" 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. --- src/reader.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/reader.rs b/src/reader.rs index 5a8d7e344..d08c2e8c5 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -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 }