From a33d15d238053b52ab5e24cc7cdb09e080c7b800 Mon Sep 17 00:00:00 2001 From: Lazar Bulovan Date: Wed, 22 Jul 2026 14:19:02 +0200 Subject: [PATCH] fix: add filterText so variables match when typing without # prefix Variable labels use # prefix (#instTestTimer) but users type without # (instTestTimer). Without filterText, the client filters using the label and #instTestTimer doesn't match instTestTimer, so the variable never appears in autocomplete. Setting filterText to the bare variable name fixes this. Also removed aggressive fallback in else branch that treated any word typed as function call context even without a ( in the line. --- src/main.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.lua b/src/main.lua index cfcc9c9..ff90c47 100644 --- a/src/main.lua +++ b/src/main.lua @@ -838,6 +838,7 @@ function handlers.textDocument_completion(params) if prefix == "" or name:upper():find("^" .. prefix:upper(), 1, true) then table.insert(items, { label = "#" .. name, + filterText = name, kind = 13, detail = "Variable (" .. (info.type or "VAR") .. "): " .. (info.data_type or "unknown"), insertText = "#" .. name, @@ -933,9 +934,6 @@ function handlers.textDocument_completion(params) else -- Check if we're inside a function call (e.g., after instTestTimer() local call_name = get_call_context(line, col) - if not call_name and col > 0 then - call_name = line:sub(1, col):match("([%w_]+)%s*$") - end local call_params = call_name and resolve_call_params(call_name, doc.variables, doc.types) -- Check context before cursor @@ -977,6 +975,7 @@ function handlers.textDocument_completion(params) if word_prefix == "" or name:upper():find("^" .. word_prefix:upper(), 1, true) then table.insert(items, { label = "#" .. name, + filterText = name, kind = 13, detail = "Variable (" .. (info.type or "VAR") .. "): " .. (info.data_type or "unknown"), insertText = "#" .. name, @@ -1010,6 +1009,7 @@ function handlers.textDocument_completion(params) if word_prefix == "" or name:upper():find("^" .. word_prefix:upper(), 1, true) then table.insert(items, { label = "#" .. name, + filterText = name, kind = 13, detail = "Variable (" .. (info.type or "VAR") .. "): " .. (info.data_type or "unknown"), insertText = "#" .. name,