From 2dda8634e9ec765f4d41937174214b7f444ebe88 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 5 Mar 2012 09:34:31 -0800 Subject: [PATCH] Fix to stop autosuggesting on whitespace --- reader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/reader.cpp b/reader.cpp index ba62b1b79..f48dbeb12 100644 --- a/reader.cpp +++ b/reader.cpp @@ -1301,7 +1301,11 @@ static int threaded_autosuggest(autosuggestion_context_t *ctx) { } static bool can_autosuggest(void) { - return ! data->suppress_autosuggestion && ! data->command_line.empty() && data->history_search.is_at_end(); + /* We autosuggest if suppress_autosuggestion is not set, if we're not doing a history search, and our command line contains a non-whitespace character. */ + const wchar_t *whitespace = L" \t\r\n\v"; + return ! data->suppress_autosuggestion && + data->history_search.is_at_end() && + data->command_line.find_first_not_of(whitespace) != wcstring::npos; } static void autosuggest_completed(autosuggestion_context_t *ctx, int result) {