From a3caecbd6ac3d0e8e16fdb8faa3241810ac70ce2 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Tue, 2 Dec 2014 12:31:44 +0900 Subject: [PATCH] Early out when no arguments, store cursor position --- autoload/argwrap.vim | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/autoload/argwrap.vim b/autoload/argwrap.vim index 75f32c4..5bd4fa0 100644 --- a/autoload/argwrap.vim +++ b/autoload/argwrap.vim @@ -179,8 +179,9 @@ function! argwrap#adjustCursor() endfunction function! argwrap#toggle() - call argwrap#adjustCursor() + let l:cursor = getpos('.') + call argwrap#adjustCursor() let l:range = argwrap#findClosestRange() if !argwrap#validateRange(l:range) return @@ -188,11 +189,16 @@ function! argwrap#toggle() let l:argText = argwrap#extractContainerArgText(l:range) let l:arguments = argwrap#extractContainerArgs(l:argText) - let l:container = argwrap#extractContainer(l:range) + if len(l:arguments) == 0 + return + endif + let l:container = argwrap#extractContainer(l:range) if l:range.lineStart == l:range.lineEnd call argwrap#wrapContainer(l:range, l:container, l:arguments) else call argwrap#unwrapContainer(l:range, l:container, l:arguments) endif + + call setpos('.', l:cursor) endfunction