vim-patch:0e6adf8a29d5

Update runtime files

0e6adf8a29

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2022-12-07 14:11:26 +08:00
parent 7dfd466437
commit c61af03cd2

View File

@@ -872,28 +872,35 @@ Here is an example that counts the number of spaces with <F4>: >
" doubling <F4> works on a line " doubling <F4> works on a line
nnoremap <expr> <F4><F4> CountSpaces() .. '_' nnoremap <expr> <F4><F4> CountSpaces() .. '_'
function CountSpaces(type = '') abort function CountSpaces(virtualedit = '', irregular_block = v:false, type = '') abort
if a:type == '' if a:type == ''
set opfunc=CountSpaces let &operatorfunc = function('CountSpaces', [&virtualedit, v:false])
set virtualedit=block
return 'g@' return 'g@'
endif endif
let cb_save = &clipboard
let sel_save = &selection let sel_save = &selection
let reg_save = getreginfo('"') let reg_save = getreginfo('"')
let cb_save = &clipboard
let visual_marks_save = [getpos("'<"), getpos("'>")] let visual_marks_save = [getpos("'<"), getpos("'>")]
try try
set clipboard= selection=inclusive set clipboard= selection=inclusive virtualedit=
let commands = #{line: "'[V']y", char: "`[v`]y", block: "`[\<c-v>`]y"} let commands = #{line: "'[V']", char: "`[v`]", block: "`[\<C-V>`]"}->get(a:type, 'v')
silent exe 'noautocmd keepjumps normal! ' .. get(commands, a:type, '') if getpos("']")[-1] != 0 || a:irregular_block
echom count(getreg('"'), ' ') let commands ..= 'oO$'
let &operatorfunc = function('CountSpaces', [a:virtualedit, v:true])
endif
let commands ..= 'y'
execute 'silent noautocmd keepjumps normal! ' .. commands
echomsg getreg('"')->count(' ')
finally finally
call setreg('"', reg_save) call setreg('"', reg_save)
call setpos("'<", visual_marks_save[0]) call setpos("'<", visual_marks_save[0])
call setpos("'>", visual_marks_save[1]) call setpos("'>", visual_marks_save[1])
let &clipboard = cb_save let &clipboard = cb_save
let &selection = sel_save let &selection = sel_save
let &virtualedit = a:virtualedit
endtry endtry
endfunction endfunction