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
|
Development version
|
||||||
* Add the g:gundo_disable setting.
|
* Add the g:gundo_disable setting.
|
||||||
* Fix movement commands with counts in the graph.
|
* 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
|
v1.0.0
|
||||||
* Initial stable release.
|
* Initial stable release.
|
||||||
|
|
||||||
|
@ -500,6 +500,14 @@ function! s:GundoGoToWindowForBufferName(name)"{{{
|
|||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
|
function! s:GundoIsVisible()"{{{
|
||||||
|
if bufwinnr(bufnr("__Gundo__")) != -1 || bufwinnr(bufnr("__Gundo_Preview__")) != -1
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
endfunction"}}}
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ Gundo buffer settings
|
"{{{ Gundo buffer settings
|
||||||
@ -663,29 +671,21 @@ function! s:GundoClose()"{{{
|
|||||||
exe bufwinnr(g:gundo_target_n) . "wincmd w"
|
exe bufwinnr(g:gundo_target_n) . "wincmd w"
|
||||||
endfunction"}}}
|
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()"{{{
|
function! s:GundoToggle()"{{{
|
||||||
if expand('%') == "__Gundo__"
|
if s:GundoIsVisible()
|
||||||
call s:GundoClose()
|
call s:GundoClose()
|
||||||
else
|
else
|
||||||
if expand('%') != "__Gundo_Preview__"
|
let g:gundo_target_n = bufnr('')
|
||||||
" Record the previous buffer number.
|
let g:gundo_target_f = @%
|
||||||
"
|
call s:GundoOpen()
|
||||||
" 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()
|
|
||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
@ -770,7 +770,7 @@ def GundoRenderGraph():
|
|||||||
target = (vim.eval('g:gundo_target_f'), int(vim.eval('g:gundo_target_n')))
|
target = (vim.eval('g:gundo_target_f'), int(vim.eval('g:gundo_target_n')))
|
||||||
header = (INLINE_HELP % target).splitlines()
|
header = (INLINE_HELP % target).splitlines()
|
||||||
|
|
||||||
vim.command('GundoOpenGraph')
|
vim.command('call s:GundoOpenGraph()')
|
||||||
vim.command('setlocal modifiable')
|
vim.command('setlocal modifiable')
|
||||||
vim.current.buffer[:] = (header + result)
|
vim.current.buffer[:] = (header + result)
|
||||||
vim.command('setlocal nomodifiable')
|
vim.command('setlocal nomodifiable')
|
||||||
@ -867,6 +867,7 @@ def GundoRenderPreview():
|
|||||||
node_after = nmap[target_state]
|
node_after = nmap[target_state]
|
||||||
node_before = node_after.parent
|
node_before = node_after.parent
|
||||||
|
|
||||||
|
vim.command('call s:GundoOpenPreview()')
|
||||||
_output_preview_text(_generate_preview_diff(current, node_before, node_after))
|
_output_preview_text(_generate_preview_diff(current, node_before, node_after))
|
||||||
|
|
||||||
_goto_window_for_buffer_name('__Gundo__')
|
_goto_window_for_buffer_name('__Gundo__')
|
||||||
@ -958,7 +959,6 @@ endfunction"}}}
|
|||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ Misc
|
"{{{ Misc
|
||||||
command! -nargs=0 GundoOpenGraph call s:GundoOpenGraph()
|
|
||||||
command! -nargs=0 GundoToggle call s:GundoToggle()
|
command! -nargs=0 GundoToggle call s:GundoToggle()
|
||||||
command! -nargs=0 GundoRenderGraph call s:GundoRenderGraph()
|
command! -nargs=0 GundoRenderGraph call s:GundoRenderGraph()
|
||||||
autocmd BufNewFile __Gundo__ call s:GundoSettingsGraph()
|
autocmd BufNewFile __Gundo__ call s:GundoSettingsGraph()
|
||||||
|
@ -332,6 +332,11 @@ let g:gundo_right = 1
|
|||||||
<ul>
|
<ul>
|
||||||
<li>Add the <code>g:gundo_disable</code> setting.</li>
|
<li>Add the <code>g:gundo_disable</code> setting.</li>
|
||||||
<li>Fix movement commands with counts in the graph.</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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>v1.0.0
|
<li>v1.0.0
|
||||||
|
Loading…
Reference in New Issue
Block a user