Fix GetVisualStartPosition when blockwise visual

This commit is contained in:
haya14busa 2014-01-14 03:43:22 +09:00
parent 1e4fe83bd6
commit 8f6567aff4

View File

@ -602,37 +602,44 @@ function! s:GetVisualStartPosition(c_pos, v_start, v_end, search_direction) "{{{
let vmode = mode(1) let vmode = mode(1)
if match('Vv',vmode) < 0 if match('Vv',vmode) < 0
throw 'Unkown visual mode:'.vmode throw 'Unkown visual mode:'.vmode
elseif vmode ==# 'V' "line-wise Visual endif
if vmode ==# 'V' "line-wise Visual
" Line-wise Visual {{{ " Line-wise Visual {{{
if a:v_start[0] == a:v_end[0] if a:v_start[0] == a:v_end[0]
if a:search_direction == '' if a:search_direction == ''
let v_pos = a:v_start return a:v_start
elseif a:search_direction == 'b' elseif a:search_direction == 'b'
let v_pos = a:v_end return a:v_end
else else
throw 'Unkown search_direction' throw 'Unkown search_direction'
endif endif
else else
if a:c_pos[0] == a:v_start[0] if a:c_pos[0] == a:v_start[0]
let v_pos = a:v_end return a:v_end
elseif a:c_pos[0] == a:v_end[0] elseif a:c_pos[0] == a:v_end[0]
let v_pos = a:v_start return a:v_start
endif endif
endif endif
"}}} "}}}
else else
" Character-wise or Block-wise Visual"{{{ " Character-wise or Block-wise Visual"{{{
if a:c_pos == a:v_start if a:c_pos == a:v_start
let v_pos = a:v_end return a:v_end
elseif a:c_pos == a:v_end elseif a:c_pos == a:v_end
let v_pos = a:v_start return a:v_start
endif
" virtualedit
if a:c_pos[0] == a:v_start[0]
return a:v_end
elseif a:c_pos[0] == a:v_end[0]
return a:v_start
else else
throw 'Unkown a:c_pos' throw 'Unkown a:c_pos'
endif endif
"}}} "}}}
endif endif
return v_pos
endfunction "}}} endfunction "}}}
" -- Others ------------------------------ " -- Others ------------------------------
function! s:is_folded(line) "{{{ function! s:is_folded(line) "{{{