Skip to content

fix(swap): annotate query_strings as string|string[] - #893

Closed
samov0619-prog wants to merge 2 commits into
nvim-treesitter:mainfrom
samov0619-prog:annotate-query-strings-as-string(s)
Closed

fix(swap): annotate query_strings as string|string[]#893
samov0619-prog wants to merge 2 commits into
nvim-treesitter:mainfrom
samov0619-prog:annotate-query-strings-as-string(s)

Conversation

@samov0619-prog

Copy link
Copy Markdown

M.swap_next and M.swap_previous are annotated ---@PARAM query_strings string, but they pass the argument straight through to swap_textobject, which is annotated string|string[] and unwraps tables natively (if type(query_strings) == 'string' then query_strings = { query_strings } end). A list is the native path — a plain string is the one that gets wrapped.
The parameter name is already plural. move.lua annotates its goto_* functions correctly as string|string[], so only these two are affected.
Passing a list works at runtime but makes lua_ls emit Cannot assign 'table' to parameter 'string' [param-type-mismatch], forcing users to either add ---@diagnostic disable-next-line or cast with --[[@as string]], which is a lie about the actual type.

@clason

clason commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

duplicate of #892

@clason clason closed this Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants