2513c9fd4319

Fix up and down.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 09 Oct 2010 09:38:04 -0400
parents 82d190d1da64
children 725085a34b62
branches/tags (none)
files plugin/gundo.vim

Changes

--- a/plugin/gundo.vim	Sat Oct 09 09:00:41 2010 -0400
+++ b/plugin/gundo.vim	Sat Oct 09 09:38:04 2010 -0400
@@ -19,6 +19,32 @@
     let g:gundo_width = 45
 endif
 
+function! s:GundoMoveUp()
+    call cursor(line('.') - 2, 0)
+
+    let line = getline('.')
+    let idx1 = stridx(line, '@')
+    let idx2 = stridx(line, 'o')
+    if idx1 != -1
+        call cursor(0, idx1 + 1)
+    else
+        call cursor(0, idx2 + 1)
+    endif
+endfunction
+
+function! s:GundoMoveDown()
+    call cursor(line('.') + 2, 0)
+
+    let line = getline('.')
+    let idx1 = stridx(line, '@')
+    let idx2 = stridx(line, 'o')
+    if idx1 != -1
+        call cursor(0, idx1 + 1)
+    else
+        call cursor(0, idx2 + 1)
+    endif
+endfunction
+
 function! s:GundoOpenBuffer()
     let existing_gundo_buffer = bufnr("__Gundo__")
 
@@ -27,8 +53,8 @@
         wincmd H
         exe "vertical resize " . g:gundo_width
         nnoremap <script> <silent> <buffer> <CR>  :call <sid>GundoRevert()<CR>
-        nnoremap <script> <silent> <buffer> j     jj0f[hhh
-        nnoremap <script> <silent> <buffer> k     kk0f[hhh
+        nnoremap <script> <silent> <buffer> j     :call <sid>GundoMoveDown()<CR>
+        nnoremap <script> <silent> <buffer> k     :call <sid>GundoMoveUp()<CR>
     else
         let existing_gundo_window = bufwinnr(existing_gundo_buffer)
 
@@ -71,6 +97,9 @@
     setlocal buflisted
     setlocal nomodifiable
     setlocal filetype=gundo
+    setlocal nolist
+    setlocal nonumber
+    setlocal norelativenumber
     call s:GundoSyntax()
 endfunction
 
@@ -462,6 +491,7 @@
     current = int(vim.eval('changenr()'))
 
 result = generate(walk_nodes(dag), asciiedges, current).splitlines()
+result = [' ' + l for l in result]
 
 INLINE_HELP = '''\
 " j/k  - move between undo states