diff --git a/src/reader.rs b/src/reader.rs index 259fdfdc3..b82622784 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -4650,16 +4650,15 @@ fn get_autosuggestion_performer( }; // Search history for a matching item unless this line is not a continuation line or quoted. - if { + let cursor_line_has_process_start = { let mut tokens = vec![]; parse_util_process_extent(&command_line, cursor_pos, Some(&mut tokens)); - tokens - .first() - .map(|tok| { - range_of_line_at_cursor(&command_line, tok.offset()) == search_string_range - }) - .unwrap_or_default() - } { + range_of_line_at_cursor( + &command_line, + tokens.first().map(|tok| tok.offset()).unwrap_or(cursor_pos), + ) == search_string_range + }; + if cursor_line_has_process_start { let mut searcher = HistorySearch::new_with_type( history, search_string.to_owned(), diff --git a/tests/checks/tmux-autosuggestion.fish b/tests/checks/tmux-autosuggestion.fish index f46a7ba8a..ba6175a3a 100644 --- a/tests/checks/tmux-autosuggestion.fish +++ b/tests/checks/tmux-autosuggestion.fish @@ -30,3 +30,9 @@ isolated-tmux send-keys A C-h tmux-sleep isolated-tmux capture-pane -p # CHECK: prompt 2> : ./COMPL + +isolated-tmux send-keys C-u 'echo (echo)' Enter +isolated-tmux send-keys C-l 'echo (' +tmux-sleep +isolated-tmux capture-pane -p +# CHECK: prompt 3> echo (echo)