From c6a7c4ff10f7a840a53e12e32d53a2b099ea077b Mon Sep 17 00:00:00 2001 From: haya14busa Date: Mon, 6 Jan 2014 09:24:32 +0900 Subject: [PATCH] Fix undotree Problem : EasyMotion destroy undotree by overwriting buffer text temporarily Solution : Use wundo & rundo Reference: :h wundo :h rundo --- autoload/EasyMotion.vim | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index 90e047c..d4c3b7a 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -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)