From 25e4662559f7b4c29caba3f0217a2c5761aedd2e Mon Sep 17 00:00:00 2001 From: Kurtis Moxley Date: Thu, 19 May 2022 23:31:58 +0800 Subject: [PATCH] Update vim-surround. --- .../vim-surround/doc/surround.txt | 12 ------------ .../vim-surround/plugin/surround.vim | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/sources_non_forked/vim-surround/doc/surround.txt b/sources_non_forked/vim-surround/doc/surround.txt index fd395d23..f39efb28 100644 --- a/sources_non_forked/vim-surround/doc/surround.txt +++ b/sources_non_forked/vim-surround/doc/surround.txt @@ -202,16 +202,4 @@ that allow you to jump to such markings. > let g:surround_insert_tail = "<++>" < -ISSUES *surround-issues* - -Vim could potentially get confused when deleting/changing occurs at the very -end of the line. Please report any repeatable instances of this. - -Do we need to use |inputsave()|/|inputrestore()| with the tag replacement? - -Indenting is handled haphazardly. Need to decide the most appropriate -behavior and implement it. Right now one can do :let b:surround_indent = 1 -(or the global equivalent) to enable automatic re-indenting by Vim via |=|; -should this be the default? - vim:tw=78:ts=8:ft=help:norl: diff --git a/sources_non_forked/vim-surround/plugin/surround.vim b/sources_non_forked/vim-surround/plugin/surround.vim index 527dc3c9..8a4016e9 100644 --- a/sources_non_forked/vim-surround/plugin/surround.vim +++ b/sources_non_forked/vim-surround/plugin/surround.vim @@ -323,7 +323,7 @@ function! s:insert(...) " {{{1 let cb_save = &clipboard set clipboard-=unnamed clipboard-=unnamedplus let reg_save = @@ - call setreg('"',"\r",'v') + call setreg('"',"\032",'v') call s:wrapreg('"',char,"",linemode) " If line mode is used and the surrounding consists solely of a suffix, " remove the initial newline. This fits a use case of mine but is a @@ -354,19 +354,21 @@ function! s:insert(...) " {{{1 call s:reindent() endif norm! `] - call search('\r','bW') + call search("\032",'bW') let @@ = reg_save let &clipboard = cb_save return "\" endfunction " }}}1 -function! s:reindent() " {{{1 - if exists("b:surround_indent") ? b:surround_indent : (!exists("g:surround_indent") || g:surround_indent) +function! s:reindent() abort " {{{1 + if get(b:, 'surround_indent', get(g:, 'surround_indent', 1)) && (!empty(&equalprg) || !empty(&indentexpr) || &cindent || &smartindent || &lisp) silent norm! '[='] endif endfunction " }}}1 function! s:dosurround(...) " {{{1 + let sol_save = &startofline + set startofline let scount = v:count1 let char = (a:0 ? a:1 : s:inputtarget()) let spc = "" @@ -388,6 +390,9 @@ function! s:dosurround(...) " {{{1 if a:0 > 1 let newchar = a:2 if newchar == "\" || newchar == "\" || newchar == "" + if !sol_save + set nostartofline + endif return s:beep() endif endif @@ -414,6 +419,9 @@ function! s:dosurround(...) " {{{1 if keeper == "" call setreg('"',original,otype) let &clipboard = cb_save + if !sol_save + set nostartofline + endif return "" endif let oldline = getline('.') @@ -478,6 +486,9 @@ function! s:dosurround(...) " {{{1 else silent! call repeat#set("\C".(a:0 > 2 && a:3 ? "S" : "s")."urround".char.newchar.s:input,scount) endif + if !sol_save + set nostartofline + endif endfunction " }}}1 function! s:changesurround(...) " {{{1