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
|
endif
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! s:SetLines(lines, key) " {{{
|
function! s:SetLines(lines, key) " {{{
|
||||||
try
|
|
||||||
" Try to join changes with previous undo block
|
|
||||||
undojoin
|
|
||||||
catch
|
|
||||||
endtry
|
|
||||||
|
|
||||||
for [line_num, line] in a:lines
|
for [line_num, line] in a:lines
|
||||||
call setline(line_num, line[a:key])
|
call setline(line_num, line[a:key])
|
||||||
endfor
|
endfor
|
||||||
" Break undo history
|
|
||||||
let &undolevels = &undolevels
|
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! s:GetChar() " {{{
|
function! s:GetChar() " {{{
|
||||||
let char = getchar()
|
let char = getchar()
|
||||||
@ -712,6 +704,10 @@ endfunction "}}}
|
|||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
try
|
try
|
||||||
|
" Save undo tree
|
||||||
|
let s:undo_file = tempname()
|
||||||
|
execute "wundo" s:undo_file
|
||||||
|
|
||||||
" Set lines with markers
|
" Set lines with markers
|
||||||
call s:SetLines(lines_items, 'marker')
|
call s:SetLines(lines_items, 'marker')
|
||||||
|
|
||||||
@ -729,6 +725,12 @@ endfunction "}}}
|
|||||||
" Restore original lines
|
" Restore original lines
|
||||||
call s:SetLines(lines_items, 'orig')
|
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 {{{
|
" Un-highlight targets {{{
|
||||||
if exists('target_hl_id')
|
if exists('target_hl_id')
|
||||||
call matchdelete(target_hl_id)
|
call matchdelete(target_hl_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user