Adding toggle function
This commit is contained in:
parent
c2a6e2e2a1
commit
ac53632892
21
argwrap.vim
21
argwrap.vim
@ -99,7 +99,7 @@ function! argwrap#wrapContainer(range, container, arguments)
|
|||||||
let l:line = a:range.lineStart
|
let l:line = a:range.lineStart
|
||||||
call setline(l:line, a:container.prefix)
|
call setline(l:line, a:container.prefix)
|
||||||
for l:argument in a:arguments
|
for l:argument in a:arguments
|
||||||
call append(l:line, l:argument)
|
call append(l:line, l:argument . ",")
|
||||||
let l:line += 1
|
let l:line += 1
|
||||||
exec printf("%s>", l:line)
|
exec printf("%s>", l:line)
|
||||||
endfor
|
endfor
|
||||||
@ -112,20 +112,19 @@ function! argwrap#unwrapContainer(range, container, arguments)
|
|||||||
exec printf("%d,%dd", a:range.lineStart + 1, a:range.lineEnd)
|
exec printf("%d,%dd", a:range.lineStart + 1, a:range.lineEnd)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! argwrap#Unwrap()
|
function! argwrap#toggle()
|
||||||
let l:range = argwrap#findRange()
|
|
||||||
let l:argText = argwrap#extractArgumentText(l:range)
|
|
||||||
let l:arguments = argwrap#extractArguments(l:argText)
|
|
||||||
let l:container = argwrap#extractContainer(l:range)
|
|
||||||
|
|
||||||
call argwrap#unwrapContainer(l:range, l:container, l:arguments)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! argwrap#Wrap()
|
|
||||||
let l:range = argwrap#findRange()
|
let l:range = argwrap#findRange()
|
||||||
|
if l:range.lineStart == l:range.lineEnd && l:range.colStart == l:range.colEnd
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
let l:argText = argwrap#extractArgumentText(l:range)
|
let l:argText = argwrap#extractArgumentText(l:range)
|
||||||
let l:arguments = argwrap#extractArguments(l:argText)
|
let l:arguments = argwrap#extractArguments(l:argText)
|
||||||
let l:container = argwrap#extractContainer(l:range)
|
let l:container = argwrap#extractContainer(l:range)
|
||||||
|
|
||||||
|
if l:range.lineStart == l:range.lineEnd
|
||||||
call argwrap#wrapContainer(l:range, l:container, l:arguments)
|
call argwrap#wrapContainer(l:range, l:container, l:arguments)
|
||||||
|
else
|
||||||
|
call argwrap#unwrapContainer(l:range, l:container, l:arguments)
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
a = Foo(a, [b, z], "hello, world", c)
|
a = Foo(a, [b, z], "hello, world", c, )
|
||||||
|
|
||||||
Foo(
|
Foo(a, b)
|
||||||
a
|
|
||||||
b
|
|
||||||
)
|
|
||||||
|
|
||||||
Foo(
|
Foo(
|
||||||
a,
|
a,
|
||||||
|
Loading…
Reference in New Issue
Block a user