Skip to content

Commit

Permalink
Save and restore clipboard option, rather than hack around behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
tpope committed Feb 11, 2007
1 parent c85cef4 commit 8a2116a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions plugin/surround.vim
Expand Up @@ -329,6 +329,7 @@ function! s:insert(...) " {{{1
return ""
endif
"call inputsave()
let cb_save = &clipboard
let reg_save = @@
call setreg('"',"\r",'v')
call s:wrapreg('"',char,linemode)
Expand All @@ -342,6 +343,7 @@ function! s:insert(...) " {{{1
endif
call search('\r','bW')
let @@ = reg_save
let &clipboard = cb_save
return "\<Del>"
endfunction " }}}1

Expand Down Expand Up @@ -376,6 +378,8 @@ function! s:dosurround(...) " {{{1
return s:beep()
endif
endif
let cb_save = &clipboard
set clipboard-=unnamed
let append = ""
let original = getreg('"')
let otype = getregtype('"')
Expand All @@ -386,6 +390,7 @@ function! s:dosurround(...) " {{{1
let okeeper = keeper " for reindent below
if keeper == ""
call setreg('"',original,otype)
let &clipboard = cb_save
return ""
endif
let oldline = getline('.')
Expand Down Expand Up @@ -446,6 +451,7 @@ function! s:dosurround(...) " {{{1
endif
call setreg('"',removed,regtype)
let s:lastdel = removed
let &clipboard = cb_save
endfunction " }}}1

function! s:changesurround() " {{{1
Expand All @@ -465,17 +471,13 @@ function! s:opfunc(type,...) " {{{1
if char == ""
return s:beep()
endif
if &cb =~ 'unnamed'
let reg = 's'
else
let reg = '"'
endif
let reg = '"'
let sel_save = &selection
let &selection = "inclusive"
let cb_save = &clipboard
set clipboard-=unnamed
let reg_save = getreg(reg)
let reg_type = getregtype(reg)
let def_save = getreg('"')
let def_type = getregtype('"')
"call setreg(reg,"\n","c")
let type = a:type
if a:type == "char"
Expand All @@ -495,6 +497,7 @@ function! s:opfunc(type,...) " {{{1
endif
else
let &selection = sel_save
let &clipboard = cb_save
return s:beep()
endif
let keeper = getreg(reg)
Expand All @@ -512,8 +515,8 @@ function! s:opfunc(type,...) " {{{1
call s:reindent()
endif
call setreg(reg,reg_save,reg_type)
call setreg('"',def_save,def_type)
let &selection = sel_save
let &clipboard = cb_save
endfunction

function! s:opfunc2(arg)
Expand Down

0 comments on commit 8a2116a

Please sign in to comment.