mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2026-11-03 02:47:36 +08:00
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:
3 files changed
+23
-1
No files matched your search
+4
-1
@@ -19,7 +19,10 @@ function! s:Init()
|
|||||||
" To adjust HTML
|
" To adjust HTML
|
||||||
let s:empty_tagname = '(area|base|br|col|embed|hr|input|img|'
|
let s:empty_tagname = '(area|base|br|col|embed|hr|input|img|'
|
||||||
\.'keygen|link|meta|param|source|track|wbr)'
|
\.'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_start = '\v\<'.s:empty_tagname.'[^>]*$'
|
||||||
let s:empty_tag_end = '\v^\s*[^<>/]*\/?\>\s*'
|
let s:empty_tag_end = '\v^\s*[^<>/]*\/?\>\s*'
|
||||||
let s:tag_start = '\v^\s*\<\w*' " <
|
let s:tag_start = '\v^\s*\<\w*' " <
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
" Empty tags like <input> with or without '/>', and '>' in attribute
|
||||||
|
" expressions
|
||||||
|
let g:test_flatten = 1
|
||||||
|
|
||||||
|
function! Check()
|
||||||
|
call ExpectIndentEachLine()
|
||||||
|
endfunction
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<input v-model="name" @input="(e) => update(e)" />
|
||||||
|
<p>x</p>
|
||||||
|
<input type="text">
|
||||||
|
<p>y</p>
|
||||||
|
<img src="a.png" alt="a" />
|
||||||
|
<p>z</p>
|
||||||
|
<input :class="a > b ? 'a' : 'b'">
|
||||||
|
<p>w</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
Reference in new issue
Block a user