From 597068870b8f093a8b2d11536c62ff31222ee8d0 Mon Sep 17 00:00:00 2001 From: matsuhav <28914976+matsuhav@users.noreply.github.com> Date: Tue, 24 Jul 2018 03:52:25 +0900 Subject: [PATCH] Fix blank lines issue In #254, probably because the tag is followed by , cstta sets regtype 'V'(linewise) though its keeper doesn't end with . And setreg() adds extra at @". Remove this extra and fix adding method. --- plugin/surround.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugin/surround.vim b/plugin/surround.vim index 72a1442..5626f22 100644 --- a/plugin/surround.vim +++ b/plugin/surround.vim @@ -263,11 +263,16 @@ function! s:wrap(string,char,type,removed,special) elseif keeper =~ '\n$' && after =~ '^\n' let after = strpart(after,1) endif - if before !~ '\n\s*$' + if keeper !~ '^\n' && before !~ '\n\s*$' let before .= "\n" if a:special let before .= "\t" endif + elseif keeper =~ '^\n' && before =~ '\n\s*$' + let keeper = strcharpart(keeper,1) + endif + if type ==# 'V' && keeper =~ '\n\s*\n$' + let keeper = strcharpart(keeper,0,strchars(keeper) - 1) endif endif if type ==# 'V'