From 16823818f698e63171fa4202b60ae9284053d565 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 9 Apr 2022 16:17:12 +0800 Subject: [PATCH] fix(Ex mode): fix highlight plugin for Ex mode In Ex mode `line('w$')` return 0, so we should not use Display range for Ex mode. neovim issues and pull requests: - https://github.com/neovim/neovim/issues/18050 - https://github.com/neovim/neovim/pull/14311 - https://github.com/neovim/neovim/pull/17986 - https://github.com/neovim/neovim/pull/17977 close https://github.com/SpaceVim/SpaceVim/issues/4629 --- autoload/SpaceVim/plugins/highlight.vim | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/autoload/SpaceVim/plugins/highlight.vim b/autoload/SpaceVim/plugins/highlight.vim index dc604e818..2c8bdd497 100644 --- a/autoload/SpaceVim/plugins/highlight.vim +++ b/autoload/SpaceVim/plugins/highlight.vim @@ -105,8 +105,17 @@ endfunction function! s:init() abort call s:hi() - let s:current_range = 'Display' - let [s:cursor_stack, s:index] = SpaceVim#plugins#iedit#paser(line('w0'), line('w$'), s:current_match, 0) + " https://github.com/neovim/neovim/issues/18050 + " vim-patch:8.0.0542 make `line('w$')` return 0 in Ex mode + " so the default range should be Buffer in Ex mode + let mode = mode() + if mode ==# 'cv' || mode ==# 'ce' + let s:current_range = 'Buffer' + let [s:cursor_stack, s:index] = SpaceVim#plugins#iedit#paser(1, line('$'), s:current_match, 0) + else + let s:current_range = 'Display' + let [s:cursor_stack, s:index] = SpaceVim#plugins#iedit#paser(line('w0'), line('w$'), s:current_match, 0) + endif call s:highlight() endfunction " }}} @@ -260,7 +269,12 @@ function! s:change_range() abort let [s:cursor_stack, s:index] = SpaceVim#plugins#iedit#paser(range[0], range[1], s:current_match, 0) call s:clear_highlight() call s:highlight() - elseif s:current_range ==# 'Function' + elseif s:current_range ==# 'Function' && (mode() ==# 'cv' || mode() ==# 'ce') + let s:current_range = 'Buffer' + let [s:cursor_stack, s:index] = SpaceVim#plugins#iedit#paser(1, line('$'), s:current_match, 0) + call s:clear_highlight() + call s:highlight() + else let s:current_range = 'Display' let [s:cursor_stack, s:index] = SpaceVim#plugins#iedit#paser(line('w0'), line('w$'), s:current_match, 0) call s:clear_highlight()