From f6c5a8c717a7cc4385e7dc95d4d62bca540e946a Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 4 Dec 2012 10:51:32 +0900 Subject: [PATCH] fix balance inward. --- autoload/zencoding/lang/html.vim | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/autoload/zencoding/lang/html.vim b/autoload/zencoding/lang/html.vim index db89269..fd4b33a 100644 --- a/autoload/zencoding/lang/html.vim +++ b/autoload/zencoding/lang/html.vim @@ -358,7 +358,6 @@ function! zencoding#lang#html#toString(settings, current, type, inline, filters, let str .= "\n" . indent let dr = 1 elseif current.multiplier == 1 && nc == 1 && len(child.name) == 0 - echo current.multiplier let str .= "\n" . indent let dr = 1 endif @@ -536,9 +535,9 @@ function! zencoding#lang#html#balanceTag(flag) range endif let settings = zencoding#getSettings() - if a:flag > 0 + if a:flag > 0 || abs(a:flag) == 1 + let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>' while 1 - let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>' let pos1 = searchpos(mx, 'bW') let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx) let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze') @@ -557,9 +556,18 @@ function! zencoding#lang#html#balanceTag(flag) range endif endwhile else + let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>' while 1 - let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>' let pos1 = searchpos(mx, 'W') + if pos1 == curpos[1:2] + let pos1 = searchpos(mx . '\zs', 'W') + let pos2 = searchpos('.\ze<', 'W') + let block = [pos1, pos2] + if zencoding#util#regionIsValid(block) + call zencoding#util#selectRegion(block) + return + endif + endif let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx) let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze') if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1