Better argument splitting
This commit is contained in:
parent
d668043880
commit
c856cacfa7
10
wrap.vim
10
wrap.vim
@ -55,13 +55,12 @@ function! ExtractText(range)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! UpdateScopeStack(stack, char)
|
function! UpdateScopeStack(stack, char)
|
||||||
let l:openers = {"\"": "\"", "\'": "\'", "(": ")", "[": "]", "{": "}"}
|
let l:pairs = {"\"": "\"", "\'": "\'", ")": "(", "]": "[", "}": "{"}
|
||||||
let l:closers = {"\"": "\"", "\'": "\'", ")": "(", "]": "[", "}": "{"}
|
|
||||||
|
|
||||||
let l:length = len(a:stack)
|
let l:length = len(a:stack)
|
||||||
if l:length > 0 && get(l:closers, a:char) == a:stack[l:length - 1]
|
|
||||||
|
if l:length > 0 && get(l:pairs, a:char, "") == a:stack[l:length - 1]
|
||||||
call remove(a:stack, l:length - 1)
|
call remove(a:stack, l:length - 1)
|
||||||
elseif has_key(l:openers, a:char)
|
elseif index(values(l:pairs), a:char) >= 0
|
||||||
call add(a:stack, a:char)
|
call add(a:stack, a:char)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -74,6 +73,7 @@ function! ExtractArguments(text)
|
|||||||
for l:index in range(strlen(a:text))
|
for l:index in range(strlen(a:text))
|
||||||
let l:char = a:text[l:index]
|
let l:char = a:text[l:index]
|
||||||
call UpdateScopeStack(l:stack, l:char)
|
call UpdateScopeStack(l:stack, l:char)
|
||||||
|
|
||||||
if len(l:stack) == 0 && l:char == ","
|
if len(l:stack) == 0 && l:char == ","
|
||||||
call add(l:arguments, l:argument)
|
call add(l:arguments, l:argument)
|
||||||
let l:argument = ""
|
let l:argument = ""
|
||||||
|
Loading…
Reference in New Issue
Block a user