Fix undotree
Problem : EasyMotion destroy undotree by overwriting buffer text temporarily Solution : Use wundo & rundo Reference: :h wundo :h rundo
This commit is contained in:
parent
28cfe7eefd
commit
c6a7c4ff10
@ -255,17 +255,9 @@ endfunction "}}}
|
||||
endif
|
||||
endfunction " }}}
|
||||
function! s:SetLines(lines, key) " {{{
|
||||
try
|
||||
" Try to join changes with previous undo block
|
||||
undojoin
|
||||
catch
|
||||
endtry
|
||||
|
||||
for [line_num, line] in a:lines
|
||||
call setline(line_num, line[a:key])
|
||||
endfor
|
||||
" Break undo history
|
||||
let &undolevels = &undolevels
|
||||
endfunction " }}}
|
||||
function! s:GetChar() " {{{
|
||||
let char = getchar()
|
||||
@ -712,6 +704,10 @@ endfunction "}}}
|
||||
|
||||
" }}}
|
||||
try
|
||||
" Save undo tree
|
||||
let s:undo_file = tempname()
|
||||
execute "wundo" s:undo_file
|
||||
|
||||
" Set lines with markers
|
||||
call s:SetLines(lines_items, 'marker')
|
||||
|
||||
@ -729,6 +725,12 @@ endfunction "}}}
|
||||
" Restore original lines
|
||||
call s:SetLines(lines_items, 'orig')
|
||||
|
||||
" Restore undo tree
|
||||
if exists("s:undo_file")
|
||||
silent execute "rundo" s:undo_file
|
||||
unlet s:undo_file
|
||||
endif
|
||||
|
||||
" Un-highlight targets {{{
|
||||
if exists('target_hl_id')
|
||||
call matchdelete(target_hl_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user