More fixups to paren matching

This commit is contained in:
Alex Yatskov 2014-12-02 19:25:08 +09:00
parent a3caecbd6a
commit b3a2560c59

View File

@ -45,7 +45,7 @@ endfunction
function! argwrap#findRange(braces) function! argwrap#findRange(braces)
let [l:lineStart, l:colStart] = searchpairpos(a:braces[0], '', a:braces[1], 'Wnb') let [l:lineStart, l:colStart] = searchpairpos(a:braces[0], '', a:braces[1], 'Wnb')
let [l:lineEnd, l:colEnd] = searchpairpos(a:braces[0], '', a:braces[1], 'Wn') let [l:lineEnd, l:colEnd] = searchpairpos(a:braces[0], '', a:braces[1], 'Wcn')
return {'lineStart': l:lineStart, 'colStart': l:colStart, 'lineEnd': l:lineEnd, 'colEnd': l:colEnd} return {'lineStart': l:lineStart, 'colStart': l:colStart, 'lineEnd': l:lineEnd, 'colEnd': l:colEnd}
endfunction endfunction
@ -164,24 +164,9 @@ function! argwrap#unwrapContainer(range, container, arguments)
exec printf('silent %d,%dd_', a:range.lineStart + 1, a:range.lineEnd) exec printf('silent %d,%dd_', a:range.lineStart + 1, a:range.lineEnd)
endfunction endfunction
function! argwrap#adjustCursor()
let [l:buffer, l:line, l:col, l:offset] = getpos('.')
let l:lineText = getline('.')
let l:col = match(l:lineText, '[\(\[\{]')
if l:col >= 0
if l:col + 1 == strlen(l:lineText)
call cursor(l:line + 1, 0)
else
call cursor(l:line, l:col + 2)
endif
endif
endfunction
function! argwrap#toggle() function! argwrap#toggle()
let l:cursor = getpos('.') let l:cursor = getpos('.')
call argwrap#adjustCursor()
let l:range = argwrap#findClosestRange() let l:range = argwrap#findClosestRange()
if !argwrap#validateRange(l:range) if !argwrap#validateRange(l:range)
return return