fix(vars): E121 in get_wikilocal no-index path; add regression test
CI / cargo fmt --check (push) Successful in 39s
CI / cargo clippy (push) Successful in 28s
CI / cargo test (push) Successful in 29s
CI / editor keymaps (push) Successful in 1m45s

s:resolve_index referenced an undefined `a:file` (a copy-paste leftover
from wiki_root_for, whose parameter is named a:file) inside the
buffer-owning-wiki loop. Any get_wikilocal() call with no explicit index
while a wiki buffer was current — i.e. the ftplugin BufRead path — hit
`E121: undefined variable a:file`. The local is `l:file`, and the
surrounding `!empty(l:file)` guard already covers emptiness, so the
clause was both wrong and redundant; removed it.

Add development/tests/test-vars-vim.{sh,vim} covering the shim:
per-wiki-index resolution, global-default fallback, out-of-range clamp,
the no-index owning-wiki path (direct guard for this E121), and the
single-wiki shorthand. Wired into CI. 14/14 pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-03 14:57:14 +00:00
parent 255e24d1e0
commit ddb9d0b916
4 changed files with 127 additions and 1 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ function! s:resolve_index(...) abort
for l:w in nuwiki#commands#wiki_list()
let l:wroot = fnamemodify(expand(l:w.root), ':p')
if l:wroot[len(l:wroot) - 1:] !=# '/' | let l:wroot .= '/' | endif
if a:file !=# '' && l:file[: len(l:wroot) - 1] ==# l:wroot
if l:file[: len(l:wroot) - 1] ==# l:wroot
return l:n
endif
let l:n += 1