Skip to content

Commit 5b491f5

Browse files
committed
fix alone tag indent
1 parent 9aa4a1c commit 5b491f5

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

indent/html.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,14 @@ let s:html_indent_tags = '[a-z_][a-z0-9_.-]*'
258258
let s:cpo_save = &cpo
259259
set cpo-=C
260260

261+
" [-- count self close tags of line a:lnum --]
262+
fun! <SID>HtmlIndentAloneClose(lnum)
263+
let s = substitute('x'.getline(a:lnum),
264+
\ '.\{-}\(/>\)', "\1", 'g')
265+
let s = substitute(s, "[^\1].*$", '', '')
266+
return strlen(s)
267+
endfun
268+
261269
" [-- count indent-increasing tags of line a:lnum --]
262270
fun! <SID>HtmlIndentOpen(lnum, pattern)
263271
let s = substitute('x'.getline(a:lnum),
@@ -290,6 +298,7 @@ fun! <SID>HtmlIndentSum(lnum, style)
290298
if a:style == match(getline(a:lnum), '^\s*</\<\('.s:html_indent_tags.'\)\>')
291299
let open = <SID>HtmlIndentOpen(a:lnum, s:html_indent_tags) - <SID>HtmlIndentOpen(a:lnum, s:html_noindent_tags)
292300
let close = <SID>HtmlIndentClose(a:lnum, s:html_indent_tags) - <SID>HtmlIndentClose(a:lnum, s:html_noindent_tags)
301+
\ + <SID>HtmlIndentAloneClose(a:lnum)
293302
if 0 != open || 0 != close
294303
return open - close
295304
endif

0 commit comments

Comments
 (0)