no need to add cursor when has children.

This commit is contained in:
mattn
2012-06-10 02:02:56 +09:00
parent b75f89ab57
commit 01b6732fd6
2 changed files with 19 additions and 15 deletions

View File

@@ -317,11 +317,12 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
else else
let str .= ">" let str .= ">"
let str .= current.value[1:-2] let str .= current.value[1:-2]
let str .= '${cursor}' let nc = len(current.child)
for n in range(len(current.child)) if nc > 0
for n in range(nc)
let child = current.child[n] let child = current.child[n]
if len(current.child) > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1 if stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
if len(current.child) > 1 || stridx(','.settings.html.inline_elements.',', ','.child.name.',') == -1 if nc > 1 || stridx(','.settings.html.inline_elements.',', ','.child.name.',') == -1
let str .= "\n" . indent let str .= "\n" . indent
endif endif
endif endif
@@ -330,8 +331,11 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters,
let inner = substitute(inner, "\n" . indent . '$', '', 'g') let inner = substitute(inner, "\n" . indent . '$', '', 'g')
let str .= inner let str .= inner
endfor endfor
if len(current.child) > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1 else
if len(current.child) > 1 || (len(current.child) == 1 && stridx(','.settings.html.inline_elements.',', ','.current.child[0].name.',') == -1) let str .= '${cursor}'
endif
if nc > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
if nc > 1 || (nc == 1 && stridx(','.settings.html.inline_elements.',', ','.current.child[0].name.',') == -1)
let str .= "\n" let str .= "\n"
endif endif
endif endif

View File

@@ -425,7 +425,7 @@ finish
}, },
{ {
'query': "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}$$$$",
'result': "f <div class=\"boxes\">\n\t<article class=\"box2\">\n\t\t<header>\n\t\t\t<hgroup>\n\t\t\t\t<h2>aaa</h2>\n\t\t\t\t<h3>bbb</h3>\n\t\t\t</hgroup>\n\t\t\t<p>ccc</p>\n\t\t</header>\n\t</article>\n</div>\n", 'result': "f <div class=\"boxes\">\n\t<article class=\"box2\">\n\t\t<header>\n\t\t\t<hgroup>\n\t\t\t\t<h2>aaa</h2>\n\t\t\t\t<h3>bbb</h3>\n\t\t\t</hgroup>\n\t\t\t<p>ccc</p>\n\t\t</header>\n\t</article>\n</div>",
}, },
{ {
'query': "div.boxes>(div.box2>section>h2{a}+p{b})+(div.box1>section>h2{c}+p{d}+p{e}+(bq>h2{f}+h3{g})+p{h})", 'query': "div.boxes>(div.box2>section>h2{a}+p{b})+(div.box1>section>h2{c}+p{d}+p{e}+(bq>h2{f}+h3{g})+p{h})",