Factor out the "get target state" functionality into its own function.
This commit is contained in:
parent
0502b8ae47
commit
d16683449c
@ -459,6 +459,12 @@ def changenr(nodes):
|
|||||||
ENDPYTHON
|
ENDPYTHON
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
|
"{{{ Gundo utility functions
|
||||||
|
function! s:GundoGetTargetState()
|
||||||
|
let target_line = matchstr(getline("."), '\v\[[0-9]+\]')
|
||||||
|
return matchstr(target_line, '\v[0-9]+')
|
||||||
|
endfunction"}}}
|
||||||
|
|
||||||
"{{{ Gundo buffer settings
|
"{{{ Gundo buffer settings
|
||||||
|
|
||||||
function! s:GundoMapGraph()"{{{
|
function! s:GundoMapGraph()"{{{
|
||||||
@ -525,7 +531,7 @@ endfunction"}}}
|
|||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ Buffer/window management
|
"{{{ Gundo buffer/window management
|
||||||
|
|
||||||
function! s:GundoResizeBuffers(backto)"{{{
|
function! s:GundoResizeBuffers(backto)"{{{
|
||||||
exe bufwinnr(bufnr('__Gundo__')) . "wincmd w"
|
exe bufwinnr(bufnr('__Gundo__')) . "wincmd w"
|
||||||
@ -626,15 +632,14 @@ function! s:GundoToggle()"{{{
|
|||||||
GundoRender
|
GundoRender
|
||||||
|
|
||||||
" TODO: Move these lines into RenderPreview
|
" TODO: Move these lines into RenderPreview
|
||||||
let target_line = matchstr(getline("."), '\v\[[0-9]+\]')
|
let target_num = s:GundoGetTargetState()
|
||||||
let target_num = matchstr(target_line, '\v[0-9]+')
|
|
||||||
call s:GundoRenderPreview(target_num)
|
call s:GundoRenderPreview(target_num)
|
||||||
endif
|
endif
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ Mouse handling
|
"{{{ Gundo mouse handling
|
||||||
|
|
||||||
function! s:GundoMouseDoubleClick()"{{{
|
function! s:GundoMouseDoubleClick()"{{{
|
||||||
let start_line = getline('.')
|
let start_line = getline('.')
|
||||||
@ -648,7 +653,7 @@ endfunction"}}}
|
|||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ Movement
|
"{{{ Gundo movement
|
||||||
|
|
||||||
function! s:GundoMove(direction)"{{{
|
function! s:GundoMove(direction)"{{{
|
||||||
let start_line = getline('.')
|
let start_line = getline('.')
|
||||||
@ -680,14 +685,13 @@ function! s:GundoMove(direction)"{{{
|
|||||||
call cursor(0, idx2 + 1)
|
call cursor(0, idx2 + 1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let target_line = matchstr(getline("."), '\v\[[0-9]+\]')
|
let target_num = s:GundoGetTargetState()
|
||||||
let target_num = matchstr(target_line, '\v[0-9]+')
|
|
||||||
call s:GundoRenderPreview(target_num)
|
call s:GundoRenderPreview(target_num)
|
||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ Rendering
|
"{{{ Gundo rendering
|
||||||
|
|
||||||
function! s:GundoRenderGraph()"{{{
|
function! s:GundoRenderGraph()"{{{
|
||||||
python << ENDPYTHON
|
python << ENDPYTHON
|
||||||
@ -817,11 +821,10 @@ endfunction"}}}
|
|||||||
|
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
"{{{ Undo/redo commands
|
"{{{ Gundo undo/redo
|
||||||
|
|
||||||
function! s:GundoRevert()"{{{
|
function! s:GundoRevert()"{{{
|
||||||
let target_line = matchstr(getline("."), '\v\[[0-9]+\]')
|
let target_num = s:GundoGetTargetState()
|
||||||
let target_num = matchstr(target_line, '\v[0-9]+')
|
|
||||||
let back = bufwinnr(g:gundo_target_n)
|
let back = bufwinnr(g:gundo_target_n)
|
||||||
exe back . "wincmd w"
|
exe back . "wincmd w"
|
||||||
python << ENDPYTHON
|
python << ENDPYTHON
|
||||||
@ -832,8 +835,7 @@ ENDPYTHON
|
|||||||
endfunction"}}}
|
endfunction"}}}
|
||||||
|
|
||||||
function! s:GundoPlayTo()"{{{
|
function! s:GundoPlayTo()"{{{
|
||||||
let target_line = matchstr(getline("."), '\v\[[0-9]+\]')
|
let target_num = s:GundoGetTargetState()
|
||||||
let target_num = matchstr(target_line, '\v[0-9]+')
|
|
||||||
let back = bufwinnr(g:gundo_target_n)
|
let back = bufwinnr(g:gundo_target_n)
|
||||||
exe back . "wincmd w"
|
exe back . "wincmd w"
|
||||||
normal zR
|
normal zR
|
||||||
|
Loading…
x
Reference in New Issue
Block a user