vim-patch:ce4f9d2: runtime(nohlsearch): fix CursorHold loop (#36221)

fix exception when entering the insert mode with paste

closes: vim/vim#16818

ce4f9d2a10
This commit is contained in:
An Guoli
2025-10-18 09:28:58 +08:00
committed by GitHub
parent a04c73ca07
commit 671841673e

View File

@@ -1,5 +1,5 @@
" nohlsearch.vim: Auto turn off hlsearch
" Last Change: 2024-07-31
" Last Change: 2025-03-08
" Maintainer: Maxim Kim <habamax@gmail.com>
"
" turn off hlsearch after:
@@ -11,10 +11,14 @@ if exists('g:loaded_nohlsearch')
endif
let g:loaded_nohlsearch = 1
func! s:Nohlsearch()
if v:hlsearch
call feedkeys("\<cmd>nohlsearch\<cr>", 'm')
endif
endfunc
augroup nohlsearch
au!
noremap <Plug>(nohlsearch) <cmd>nohlsearch<cr>
noremap! <Plug>(nohlsearch) <cmd>nohlsearch<cr>
au CursorHold * call feedkeys("\<Plug>(nohlsearch)", 'm')
au InsertEnter * call feedkeys("\<Plug>(nohlsearch)", 'm')
au CursorHold * call s:Nohlsearch()
au InsertEnter * call s:Nohlsearch()
augroup END