Allow zero-width matches

This commit is contained in:
Junegunn Choi
2013-08-12 11:58:52 +09:00
parent 0546969c6b
commit 712bab8c72
3 changed files with 18 additions and 11 deletions

View File

@@ -158,20 +158,24 @@ function! s:split_line(line, fc, lc, pattern, stick_to_left, ignore_unmatched, i
while 1
let matches = matchlist(left, pattern, idx)
if empty(matches) | break | endif
let ignorable = s:highlighted_as(a:line, idx + len(matches[2]) + a:fc, a:ignores)
if ignorable
let token .= matches[1]
if empty(matches[1])
let char = strpart(left, idx, 1)
if empty(char) | break | endif
let [match, part, delim] = [char, char, '']
else
call add(tokens, token . matches[1])
call add(delims, matches[3])
let [match, part, delim] = matches[1 : 3]
endif
let ignorable = s:highlighted_as(a:line, idx + len(part) + a:fc, a:ignores)
if ignorable
let token .= match
else
call add(tokens, token . match)
call add(delims, delim)
let token = ''
endif
if empty(matches[1])
call s:exit("Invalid regular expression")
endif
let idx += len(matches[1])
let idx += len(match)
endwhile
let leftover = token . strpart(left, idx)

View File

@@ -91,3 +91,6 @@ apricot = 'DAD' + 'F#AD'
banana = 'Gros Michel' # comment 2
```
a()p()p()l()e();():()b()a()n()a()n()a():():()c()a()k()e
d()a()t()a();();()e()x()c()h()a()n()g()e():();()f()o()r()m()a()t

View File

@@ -1 +1 @@
4Gvipjyvip:EasyAlign:
4Gvipjyvip:EasyAlign: