From 378349c54485091436b1016a1e016d1b4758ec26 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Tue, 1 Jul 2025 15:39:41 -0400 Subject: [PATCH] AutoYADM commit: 2025-07-01 15:39:41 --- .config/kak/autoload/search-highlight.kak | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.config/kak/autoload/search-highlight.kak b/.config/kak/autoload/search-highlight.kak index a4b6c9e2..e6b684cb 100644 --- a/.config/kak/autoload/search-highlight.kak +++ b/.config/kak/autoload/search-highlight.kak @@ -35,21 +35,32 @@ provide-module search-highlight %— try %{ %opt{search_highlight_status} } catch %{ - map window prompt ': set-option window search_highlight_quit true' - # if not, add the highlighter + # if the user escapes search, we should immediately clear the highlight + # in normal mode so we set the flag before escaping + # map window prompt ': set-option window search_highlight_quit true' + # if not already enabled, add the highlighter add-highlighter window/search-highlight dynregex '%reg{/}' %exp{0:%opt{search_highlight_face}} # update status tracker set-option window search_highlight_status 'search-highlight-on' # register hook to clear highlighter after leaving search hook -once -group search-highlight window NormalIdle .* %{ + # check if user escaped search try %{ %opt{search_highlight_quit} + # if so, clear immediately search-highlight-clear } catch %{ - map window normal ': search-highlight-clear' + # otherwise, we clear on escape + hook -once -group search-highlight window NormalKey %{ + search-highlight-clear + } } + # clear the prompt mapping so it doesn't conflict with + # other prompt types unmap window prompt + # reset the quit-early flag + set-option window search_highlight_quit false } } }