From d563084dfb752465e48929e4a2a27a907d28be19 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 23 Aug 2020 12:53:05 -0700 Subject: [PATCH] Correct highlighting of executed invalid commands If you expand an abbreviation by executing the command, fish uses a synchronous mode of syntax highlighting that performs no I/O, because we want to highlight the abbreviation but don't know if it's valid or not without doing I/O. However we were doing this too aggressively, after every command regardless of whether it contained an abbreviation. Only do this for commands with abbreviations. --- src/reader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index cdb568052..5709fb137 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -3021,11 +3021,11 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat bool abbreviation_expanded = expand_abbreviation_as_necessary(1); if (abbreviation_expanded && conf.syntax_check_ok) { command_test_result = reader_shell_test(parser(), el->text()); + // If the command is OK, then we're going to execute it. We still want to do + // syntax highlighting on this newly changed command, but a synchronous variant + // that performs no I/O, so as not to block the user. + if (command_test_result == 0) super_highlight_me_plenty(true); } - // If the command is OK, then we're going to execute it. We still want to do - // syntax highlighting, but a synchronous variant that performs no I/O, so - // as not to block the user. - if (command_test_result == 0) super_highlight_me_plenty(true); } if (command_test_result == 0) {