Skip to content

Commit 5970688

Browse files
hayatoghtpope
authored andcommitted
Fix blank lines issue
In #254, probably because the tag is followed by <CR>, cstta<CR> sets regtype 'V'(linewise) though its keeper doesn't end with <CR>. And setreg() adds extra <CR> at @". Remove this extra <CR> and fix adding <CR> method.
1 parent aa1f120 commit 5970688

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

plugin/surround.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,16 @@ function! s:wrap(string,char,type,removed,special)
263263
elseif keeper =~ '\n$' && after =~ '^\n'
264264
let after = strpart(after,1)
265265
endif
266-
if before !~ '\n\s*$'
266+
if keeper !~ '^\n' && before !~ '\n\s*$'
267267
let before .= "\n"
268268
if a:special
269269
let before .= "\t"
270270
endif
271+
elseif keeper =~ '^\n' && before =~ '\n\s*$'
272+
let keeper = strcharpart(keeper,1)
273+
endif
274+
if type ==# 'V' && keeper =~ '\n\s*\n$'
275+
let keeper = strcharpart(keeper,0,strchars(keeper) - 1)
271276
endif
272277
endif
273278
if type ==# 'V'

0 commit comments

Comments
 (0)