Merge pull request #27 from inkarkat/fix-selection-exclusive

Support :set selection=exclusive
This commit is contained in:
Tom McDonald 2014-06-24 11:26:05 -04:00
commit 9c025e5914

View File

@ -32,13 +32,17 @@ endfunction
function! s:exchange_get(type, vis) function! s:exchange_get(type, vis)
let reg = getreg('"') let reg = getreg('"')
let reg_mode = getregtype('"') let reg_mode = getregtype('"')
let selection = &selection
let &selection = 'inclusive'
if a:vis if a:vis
let type = a:type let type = a:type
let [start, end] = s:store_pos("'<", "'>") let [start, end] = s:store_pos("'<", "'>")
silent exe "normal! `<" . a:type . "`>y" silent normal! gvy
elseif a:type == 'line' if &selection ==# 'exclusive' && start != end
let end[2] -= len(matchstr(@@, '\_.$'))
endif
else
let selection = &selection
let &selection = 'inclusive'
if a:type == 'line'
let type = 'V' let type = 'V'
let [start, end] = s:store_pos("'[", "']") let [start, end] = s:store_pos("'[", "']")
silent exe "normal! '[V']y" silent exe "normal! '[V']y"
@ -51,9 +55,10 @@ function! s:exchange_get(type, vis)
let [start, end] = s:store_pos("'[", "']") let [start, end] = s:store_pos("'[", "']")
silent exe "normal! `[v`]y" silent exe "normal! `[v`]y"
endif endif
let &selection = selection
endif
let text = getreg('@') let text = getreg('@')
call setreg('"', reg, reg_mode) call setreg('"', reg, reg_mode)
let &selection = selection
return [text, type, start, end] return [text, type, start, end]
endfunction endfunction