From acdcadc39bbb0c3c67c9f6d6eae0473adc3b49cd Mon Sep 17 00:00:00 2001 From: leafOfTree Date: Wed, 21 Oct 2026 12:11:30 +0000 Subject: [PATCH] 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. --- indent/vue.vim | 2 +- test/cases/indent-each-line.vim | 6 ++++++ test/cases/indent-each-line.vue | 24 ++++++++++++++++++++++++ test/run.vim | 18 ++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 test/cases/indent-each-line.vim create mode 100644 test/cases/indent-each-line.vue diff --git a/indent/vue.vim b/indent/vue.vim index 5f3c60b..f4b1fe3 100644 --- a/indent/vue.vim +++ b/indent/vue.vim @@ -122,7 +122,6 @@ function! s:PrevNonBlankNonComment(lnum) endfunction function! s:AdjustBlockIndent(syntax, ind) - let block = a:block let syntax = a:syntax let ind = a:ind @@ -173,6 +172,7 @@ function! s:PrevMultilineEmptyTag(lnum) let lnum = lnum - 1 endwhile + return [0, 0] endfunction function! s:AdjustHTMLIndent(ind) diff --git a/test/cases/indent-each-line.vim b/test/cases/indent-each-line.vim new file mode 100644 index 0000000..7c3977e --- /dev/null +++ b/test/cases/indent-each-line.vim @@ -0,0 +1,6 @@ +" GetVueIndent() for each line without errors +let g:test_flatten = 1 + +function! Check() + call ExpectIndentEachLine() +endfunction diff --git a/test/cases/indent-each-line.vue b/test/cases/indent-each-line.vue new file mode 100644 index 0000000..2c132d6 --- /dev/null +++ b/test/cases/indent-each-line.vue @@ -0,0 +1,24 @@ + + + + + diff --git a/test/run.vim b/test/run.vim index beaa711..1179998 100644 --- a/test/run.vim +++ b/test/run.vim @@ -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