AutoYADM commit: 2025-07-01 15:39:41
This commit is contained in:
parent
163abe5562
commit
378349c544
1 changed files with 14 additions and 3 deletions
|
@ -35,21 +35,32 @@ provide-module search-highlight %—
|
||||||
try %{
|
try %{
|
||||||
%opt{search_highlight_status}
|
%opt{search_highlight_status}
|
||||||
} catch %{
|
} catch %{
|
||||||
map window prompt <esc> '<a-;>: set-option window search_highlight_quit true<ret>'
|
# if the user escapes search, we should immediately clear the highlight
|
||||||
# if not, add the highlighter
|
# in normal mode so we set the flag before escaping
|
||||||
|
# map window prompt <esc> '<a-;>: set-option window search_highlight_quit true<ret><esc>'
|
||||||
|
# if not already enabled, add the highlighter
|
||||||
add-highlighter window/search-highlight dynregex '%reg{/}' %exp{0:%opt{search_highlight_face}}
|
add-highlighter window/search-highlight dynregex '%reg{/}' %exp{0:%opt{search_highlight_face}}
|
||||||
# update status tracker
|
# update status tracker
|
||||||
set-option window search_highlight_status 'search-highlight-on'
|
set-option window search_highlight_status 'search-highlight-on'
|
||||||
|
|
||||||
# register hook to clear highlighter after leaving search
|
# register hook to clear highlighter after leaving search
|
||||||
hook -once -group search-highlight window NormalIdle .* %{
|
hook -once -group search-highlight window NormalIdle .* %{
|
||||||
|
# check if user escaped search
|
||||||
try %{
|
try %{
|
||||||
%opt{search_highlight_quit}
|
%opt{search_highlight_quit}
|
||||||
|
# if so, clear immediately
|
||||||
search-highlight-clear
|
search-highlight-clear
|
||||||
} catch %{
|
} catch %{
|
||||||
map window normal <esc> ': search-highlight-clear<ret>'
|
# otherwise, we clear on escape
|
||||||
|
hook -once -group search-highlight window NormalKey <esc> %{
|
||||||
|
search-highlight-clear
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
# clear the prompt mapping so it doesn't conflict with
|
||||||
|
# other prompt types
|
||||||
unmap window prompt <esc>
|
unmap window prompt <esc>
|
||||||
|
# reset the quit-early flag
|
||||||
|
set-option window search_highlight_quit false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue