From 7fe27fa7ca3e263162dc9044b2ecf26f9b29e365 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Wed, 5 Aug 2015 20:13:07 +0900 Subject: [PATCH] Fixing annoying edge cases --- autoload/argwrap.vim | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/autoload/argwrap.vim b/autoload/argwrap.vim index b20258e..dc8bfab 100644 --- a/autoload/argwrap.vim +++ b/autoload/argwrap.vim @@ -84,7 +84,9 @@ function! argwrap#extractContainerArgText(range) if l:extractStart < l:extractEnd let l:extract = l:lineText[l:extractStart : l:extractEnd - 1] - let l:text .= substitute(l:extract, '^\s*\(.\{-}\)\s*$', '\1 ', '') + let l:extract = substitute(l:extract, '^\s*\(.\{-}\)\s*$', '\1', '') + let l:extract = substitute(l:extract, ',$', ', ', '') + let l:text .= l:extract endif endfor @@ -121,14 +123,20 @@ function! argwrap#extractContainerArgs(text) call argwrap#updateScope(l:stack, l:char) if len(l:stack) == 0 && l:char == ',' - call add(l:arguments, argwrap#trimArgument(l:argument)) + let l:argument = argwrap#trimArgument(l:argument) + if len(l:argument) > 0 + call add(l:arguments, l:argument) + endif let l:argument = '' else let l:argument .= l:char endif endfor - call add(l:arguments, argwrap#trimArgument(l:argument)) + let l:argument = argwrap#trimArgument(l:argument) + if len(l:argument) > 0 + call add(l:arguments, l:argument) + endif endif return l:arguments