From 08666e545da73e4b42e5569ef670cfcb5bf6d938 Mon Sep 17 00:00:00 2001 From: mattn Date: Mon, 28 May 2012 09:23:16 +0900 Subject: [PATCH] fix findtoken. it occur maxmempattern error. --- autoload/zencoding/html.vim | 17 +++++++++-------- unittest.vim | 6 ++++++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/autoload/zencoding/html.vim b/autoload/zencoding/html.vim index 82cb118..ebbd18d 100644 --- a/autoload/zencoding/html.vim +++ b/autoload/zencoding/html.vim @@ -1,23 +1,24 @@ +"let s:mx = '\([+>]\|<\+\)\{-}\((*\)\{-}\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\-$]*\|' let s:mx = '\([+>]\|<\+\)\{-}\s*\((*\)\{-}\s*\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\-$]*\|' \ .'{.\{-}}[ \t\r\n}]*\)\(\%(\%(#{[{}a-zA-Z0-9_\-\$]\+\|' \ .'#[a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|' \ .'\%(\.{[{}a-zA-Z0-9_\-\$]\+\|' -\ .'\.[a-zA-Z0-9_\-\$]\+\)\)*\)\%(\({[^}]\+}\+\)\)\{0,1}\%(\s*\*\s*\([0-9]\+\)\s*\)\{0,1}\(\%(\s*)\%(\s*\*\s*[0-9]\+\s*\)\{0,1}\)*\)' +\ .'\.[a-zA-Z0-9_\-\$]\+\)\)*\)\%(\({[^}]\+}\+\)\)\{0,1}\%(\*\([0-9]\+\)\)\{0,1}\(\%()\%(\*[0-9]\+\)\{0,1}\)*\)' function! zencoding#html#findTokens(str) let str = a:str + let last_pos = 0 while len(str) > 0 - let token = matchstr(str, s:mx.'\s*$') + let token = matchstr(str, '\s'.s:mx) if token == '' break - elseif token =~ '^\s' - let token = substitute(token, '^\s*', '', '') - let str = str[0 : -len(token)-1] - break endif - let str = str[0 : -len(token)-1] + if token =~ '^\s' + let last_pos = stridx(str, matchstr(token, '^\s*\zs.*')) + endif + let str = str[stridx(str, token) + len(token):] endwhile - return a:str[len(str) :-1] + return a:str[last_pos :-1] endfunction function! zencoding#html#parseIntoTree(abbr, type) diff --git a/unittest.vim b/unittest.vim index 3acdac5..6e480af 100644 --- a/unittest.vim +++ b/unittest.vim @@ -529,6 +529,12 @@ finish 'type': "html", 'result': "foo

bar baz

", }, + { + 'name': "f div.boxes>article.box2>header>(hgroup>h2{aaa}+h3{bbb})+p{ccc}$$$$", + 'query': "f div.boxes>article.box2>header>(hgroup>h2{aaa}+h3{bbb})+p{ccc}$$$$", + 'type': "html", + 'result': "f
\n\t
\n\t\t
\n\t\t\t
\n\t\t\t\t

aaa

\n\t\t\t\t

bbb

\n\t\t\t
\n\t\t\t

ccc

\n\t\t
\n\t
\n
", + }, ], }, {