1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 22:30:04 +08:00

fix(highlight): use v:argv instead of mode()

`mode()` return `n` even if start nvim with `-Ex` argv
This commit is contained in:
wsdjeg 2022-04-09 16:40:12 +08:00
parent 16823818f6
commit 9047ac81b5

View File

@ -103,13 +103,16 @@ function! s:hi() abort
endfor
endfunction
function! s:is_ex_mode() abort
return exists('v:argv') && index(v:argv, '-Ex') !=# -1
endfunction
function! s:init() abort
call s:hi()
" 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'
if s:is_ex_mode()
let s:current_range = 'Buffer'
let [s:cursor_stack, s:index] = SpaceVim#plugins#iedit#paser(1, line('$'), s:current_match, 0)
else
@ -269,7 +272,7 @@ 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' && (mode() ==# 'cv' || mode() ==# 'ce')
elseif s:current_range ==# 'Function' && s:is_ex_mode()
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()