parent
e12149d5d6
commit
bae89cbde9
@ -41,10 +41,8 @@ function! s:exchange(x, y, reverse, expand)
|
||||
|
||||
call winrestview(view)
|
||||
|
||||
if a:reverse
|
||||
call cursor(a:x.start.line, a:x.start.column)
|
||||
else
|
||||
call cursor(a:y.start.line, a:y.start.column)
|
||||
if !a:expand
|
||||
call s:fix_cursor(a:x, a:y, a:reverse)
|
||||
endif
|
||||
|
||||
let &selection = selection
|
||||
@ -54,6 +52,20 @@ function! s:exchange(x, y, reverse, expand)
|
||||
call s:restore_reg('+', reg_plus)
|
||||
endfunction
|
||||
|
||||
function! s:fix_cursor(x, y, reverse)
|
||||
if a:reverse
|
||||
call cursor(a:x.start.line, a:x.start.column)
|
||||
else
|
||||
if a:x.start.line == a:y.start.line
|
||||
let horizontal_offset = a:x.end.column - a:y.end.column
|
||||
call cursor(a:x.start.line, a:x.start.column - horizontal_offset)
|
||||
else
|
||||
let vertical_offset = a:x.end.line - a:y.end.line
|
||||
call cursor(a:x.start.line - vertical_offset, a:x.start.column)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:reindent(start, lines, new_indent)
|
||||
if (exists('b:exchange_indent') ? b:exchange_indent : g:exchange_indent) == '=='
|
||||
let lnum = nextnonblank(a:start)
|
||||
|
Loading…
Reference in New Issue
Block a user