Support :set selection=exclusive
With this, the '> mark points to after the end of the selection. - Do not change the 'selection' value when the plugin is triggered from visual mode, so that we can grab the original selection. - Simplification: gv can be used instead of "`<" . a:type . "`>" to restore the original selection. This also deals with blockwise-to-end in all cases. - For the highlighting, the end position must be corrected. Since these are byte indices, we cannot just decrement by 1, but have to subtract the length of the last selected character!
This commit is contained in:
parent
c83bfb20bc
commit
55421a1852
@ -32,28 +32,33 @@ 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 type = 'V'
|
let end[2] -= len(matchstr(@@, '\_.$'))
|
||||||
let [start, end] = s:store_pos("'[", "']")
|
endif
|
||||||
silent exe "normal! '[V']y"
|
|
||||||
elseif a:type == 'block'
|
|
||||||
let type = "\<C-V>"
|
|
||||||
let [start, end] = s:store_pos("'[", "']")
|
|
||||||
silent exe "normal! `[\<C-V>`]y"
|
|
||||||
else
|
else
|
||||||
let type = 'v'
|
let selection = &selection
|
||||||
let [start, end] = s:store_pos("'[", "']")
|
let &selection = 'inclusive'
|
||||||
silent exe "normal! `[v`]y"
|
if a:type == 'line'
|
||||||
|
let type = 'V'
|
||||||
|
let [start, end] = s:store_pos("'[", "']")
|
||||||
|
silent exe "normal! '[V']y"
|
||||||
|
elseif a:type == 'block'
|
||||||
|
let type = "\<C-V>"
|
||||||
|
let [start, end] = s:store_pos("'[", "']")
|
||||||
|
silent exe "normal! `[\<C-V>`]y"
|
||||||
|
else
|
||||||
|
let type = 'v'
|
||||||
|
let [start, end] = s:store_pos("'[", "']")
|
||||||
|
silent exe "normal! `[v`]y"
|
||||||
|
endif
|
||||||
|
let &selection = selection
|
||||||
endif
|
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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user