mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2026-11-01 10:06:24 +08:00
Fix undefined a:block in indent
s:AdjustBlockIndent() had `let block = a:block` without such an argument, so GetVueIndent() hit E121 for every line in template, script and style. It was hidden as errors in 'indentexpr' are silent and the function goes on, but showed up when calling GetVueIndent() directly. Also return [0, 0] in s:PrevMultilineEmptyTag() when no tag start is found, instead of no value. Add ExpectIndentEachLine() for tests to call GetVueIndent() for each line and check the result.
This commit is contained in:
4 files changed
+49
-1
No files matched your search
@@ -0,0 +1,6 @@
|
||||
" GetVueIndent() for each line without errors
|
||||
let g:test_flatten = 1
|
||||
|
||||
function! Check()
|
||||
call ExpectIndentEachLine()
|
||||
endfunction
|
||||
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<div
|
||||
class="a"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
>
|
||||
<p :class="{ a: b }">x</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return { a: 1 }
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
p {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
@@ -91,6 +91,24 @@ function! ExpectTag(lnum, tag)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Call GetVueIndent() for each non-blank line from line 2 as when typing it,
|
||||
" which shows errors hidden by 'indentexpr', and check the indent
|
||||
function! ExpectIndentEachLine()
|
||||
for lnum in range(2, line('$'))
|
||||
if getline(lnum) =~ '^\s*$'
|
||||
continue
|
||||
endif
|
||||
call cursor(lnum, 1)
|
||||
let v:lnum = lnum
|
||||
try
|
||||
call ExpectEqual(GetVueIndent(), indent(lnum),
|
||||
\ printf('GetVueIndent() at line %d', lnum))
|
||||
catch
|
||||
call Fail(printf('GetVueIndent() at line %d: %s', lnum, v:exception))
|
||||
endtry
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
if filereadable(s:case.'.vim')
|
||||
execute 'source '.fnameescape(s:case.'.vim')
|
||||
endif
|
||||
|
||||
Reference in new issue
Block a user