Fix indent after an empty tag with '>' in attributes

A line like <input @input="(e) => update(e)" /> was taken as an empty
tag without '/>', as '>' in '=>' matched its end, so the next line was
indented one level less. Skip '>' in quotes, and don't take '/>' as the
end of an empty tag.
This commit is contained in:
leafOfTree committed 2026-10-21 14:03:35 +00:00
1 parent ef886ddbd1
commit ed9e40037f
3 files changed
+23 -1

No files matched your search

+4 -1
View File
@@ -19,7 +19,10 @@ function! s:Init()
" To adjust HTML
let s:empty_tagname = '(area|base|br|col|embed|hr|input|img|'
\.'keygen|link|meta|param|source|track|wbr)'
let s:empty_tag = '\v\<'.s:empty_tagname.'.*(/)@<!\>'
" Empty tag ending with '>' but not '/>'. '>' in quotes like
" @input="(e) => update(e)" doesn't end the tag
let s:empty_tag = '\v\<'.s:empty_tagname
\ .'>("[^"]*"|''[^'']*''|[^\>"''/]|/(\>)@!)*\>'
let s:empty_tag_start = '\v\<'.s:empty_tagname.'[^>]*$'
let s:empty_tag_end = '\v^\s*[^<>/]*\/?\>\s*'
let s:tag_start = '\v^\s*\<\w*' " <