Make GundoToggle behave more sanely.
fixes issue 17
This commit is contained in:
parent
484d9846ef
commit
240584a769
@ -190,6 +190,8 @@ GitHub: http://github.com/sjl/gundo.vim/
|
||||
Development version
|
||||
* Add the g:gundo_disable setting.
|
||||
* Fix movement commands with counts in the graph.
|
||||
* Make GundoToggle close the Gundo windows if they're visible but not the
|
||||
current window, instead of moving to them.
|
||||
v1.0.0
|
||||
* Initial stable release.
|
||||
|
||||
|
@ -390,7 +390,7 @@ MISSING_WINDOW = "Cannot find window (%s) for Gundo's target buffer (%s)"
|
||||
|
||||
def _check_sanity():
|
||||
'''Check to make sure we're not crazy.
|
||||
|
||||
|
||||
Does the following things:
|
||||
|
||||
* Make sure the target buffer still exists.
|
||||
@ -500,6 +500,14 @@ function! s:GundoGoToWindowForBufferName(name)"{{{
|
||||
endif
|
||||
endfunction"}}}
|
||||
|
||||
function! s:GundoIsVisible()"{{{
|
||||
if bufwinnr(bufnr("__Gundo__")) != -1 || bufwinnr(bufnr("__Gundo_Preview__")) != -1
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction"}}}
|
||||
|
||||
"}}}
|
||||
|
||||
"{{{ Gundo buffer settings
|
||||
@ -663,29 +671,21 @@ function! s:GundoClose()"{{{
|
||||
exe bufwinnr(g:gundo_target_n) . "wincmd w"
|
||||
endfunction"}}}
|
||||
|
||||
function! s:GundoOpen()"{{{
|
||||
call s:GundoOpenPreview()
|
||||
exe bufwinnr(g:gundo_target_n) . "wincmd w"
|
||||
|
||||
call s:GundoRenderGraph()
|
||||
call s:GundoRenderPreview()
|
||||
endfunction"}}}
|
||||
|
||||
function! s:GundoToggle()"{{{
|
||||
if expand('%') == "__Gundo__"
|
||||
if s:GundoIsVisible()
|
||||
call s:GundoClose()
|
||||
else
|
||||
if expand('%') != "__Gundo_Preview__"
|
||||
" Record the previous buffer number.
|
||||
"
|
||||
" This sucks because we're not getting the window number, and there
|
||||
" may be more than one window viewing the same buffer, so we might
|
||||
" go back to the wrong one.
|
||||
"
|
||||
" Unfortunately window numbers change as we open more windows.
|
||||
"
|
||||
" TODO: Figure out how to fix this.
|
||||
let g:gundo_target_n = bufnr('')
|
||||
let g:gundo_target_f = @%
|
||||
endif
|
||||
|
||||
call s:GundoOpenPreview()
|
||||
exe bufwinnr(g:gundo_target_n) . "wincmd w"
|
||||
GundoRender
|
||||
|
||||
call s:GundoRenderPreview()
|
||||
let g:gundo_target_n = bufnr('')
|
||||
let g:gundo_target_f = @%
|
||||
call s:GundoOpen()
|
||||
endif
|
||||
endfunction"}}}
|
||||
|
||||
@ -702,7 +702,7 @@ function! s:GundoMouseDoubleClick()"{{{
|
||||
call s:GundoRevert()
|
||||
endif
|
||||
endfunction"}}}
|
||||
|
||||
|
||||
"}}}
|
||||
|
||||
"{{{ Gundo movement
|
||||
@ -770,7 +770,7 @@ def GundoRenderGraph():
|
||||
target = (vim.eval('g:gundo_target_f'), int(vim.eval('g:gundo_target_n')))
|
||||
header = (INLINE_HELP % target).splitlines()
|
||||
|
||||
vim.command('GundoOpenGraph')
|
||||
vim.command('call s:GundoOpenGraph()')
|
||||
vim.command('setlocal modifiable')
|
||||
vim.current.buffer[:] = (header + result)
|
||||
vim.command('setlocal nomodifiable')
|
||||
@ -867,6 +867,7 @@ def GundoRenderPreview():
|
||||
node_after = nmap[target_state]
|
||||
node_before = node_after.parent
|
||||
|
||||
vim.command('call s:GundoOpenPreview()')
|
||||
_output_preview_text(_generate_preview_diff(current, node_before, node_after))
|
||||
|
||||
_goto_window_for_buffer_name('__Gundo__')
|
||||
@ -958,7 +959,6 @@ endfunction"}}}
|
||||
"}}}
|
||||
|
||||
"{{{ Misc
|
||||
command! -nargs=0 GundoOpenGraph call s:GundoOpenGraph()
|
||||
command! -nargs=0 GundoToggle call s:GundoToggle()
|
||||
command! -nargs=0 GundoRenderGraph call s:GundoRenderGraph()
|
||||
autocmd BufNewFile __Gundo__ call s:GundoSettingsGraph()
|
||||
|
@ -332,6 +332,11 @@ let g:gundo_right = 1
|
||||
<ul>
|
||||
<li>Add the <code>g:gundo_disable</code> setting.</li>
|
||||
<li>Fix movement commands with counts in the graph.</li>
|
||||
<li>
|
||||
Make GundoToggle close the Gundo windows if they're
|
||||
visible but not the current window, instead of
|
||||
moving to them.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>v1.0.0
|
||||
|
Loading…
Reference in New Issue
Block a user