Wrap Python functions, fix last diff.

This commit is contained in:
Steve Losh 2010-10-12 18:36:02 -04:00
parent 805a3da08b
commit 80ef17d623

View File

@ -508,6 +508,13 @@ def _goto_window_for_buffer(b):
def _goto_window_for_buffer_name(bn):
b = vim.eval('bufnr("%s")' % bn)
_goto_window_for_buffer(b)
INLINE_HELP = '''\
" Gundo for %s [%d]
" j/k - move between undo states
" <cr> - revert to that state
'''
ENDPYTHON
"}}}
@ -561,6 +568,7 @@ ENDPYTHON
function! s:GundoRender()
python << ENDPYTHON
def GundoRender():
ut = vim.eval('undotree()')
entries = ut['entries']
@ -582,17 +590,12 @@ result = generate(walk_nodes(dag), asciiedges, current).splitlines()
result = [' ' + l for l in result]
target = (vim.eval('g:gundo_target_f'), int(vim.eval('g:gundo_target_n')))
INLINE_HELP = ('''\
" Gundo for %s [%d]
" j/k - move between undo states
" <cr> - revert to that state
''' % target).splitlines()
header = (INLINE_HELP % target).splitlines()
vim.command('GundoOpenBuffer')
vim.command('setlocal modifiable')
vim.command('normal ggdG')
vim.current.buffer[:] = (INLINE_HELP + result)
vim.current.buffer[:] = (header + result)
vim.command('setlocal nomodifiable')
i = 1
@ -604,8 +607,9 @@ for line in result:
except ValueError:
pass
i += 1
vim.command('%d' % (i+3))
vim.command('%d' % (i+len(header)-1))
GundoRender()
ENDPYTHON
endfunction
"}}}
@ -615,6 +619,7 @@ function! s:GundoRenderPreview(target)
python << ENDPYTHON
import difflib
def GundoRenderPreview():
_goto_window_for_buffer(vim.eval('g:gundo_target_n'))
root, nodes = make_nodes(entries)
@ -624,6 +629,9 @@ target_n = int(vim.eval('a:target'))
node_after = [node for node in nodes if node.n == target_n][0]
node_before = node_after.parent
if not node_before.n:
before = []
else:
vim.command('silent undo %d' % node_before.n)
before = vim.current.buffer[:]
vim.command('silent undo %d' % node_after.n)
@ -640,6 +648,7 @@ vim.command('setlocal nomodifiable')
_goto_window_for_buffer_name('__Gundo__')
GundoRenderPreview()
ENDPYTHON
endfunction
"}}}