fix: . trigger branch now takes priority over completed # prefix

When the user has typed something like #instTestTimer., has_hash_prefix
was true and the # trigger branch ran instead of the . branch, so dot
completion (IN/PT/Q/ET) never appeared. Changed the condition from
'if trigger == "#" or has_hash_prefix' to 'if trigger == "#"' so
the . branch always wins when trigger is ..
This commit is contained in:
2026-07-22 20:14:57 +02:00
parent 8b400054c6
commit 3ca63d278b
+2 -6
View File
@@ -831,11 +831,10 @@ function handlers.textDocument_completion(params)
end
end
if trigger == "#" or has_hash_prefix then
if trigger == "#" then
if doc.variables then
local prefix = has_hash_prefix and line_before:match("#([%w_]*)$") or word_prefix
for name, info in pairs(doc.variables) do
if prefix == "" or name:upper():sub(1, #prefix) == prefix:upper() then
if word_prefix == "" or name:upper():sub(1, #word_prefix) == word_prefix:upper() then
table.insert(items, {
label = "#" .. name,
filterText = "#" .. name,
@@ -848,9 +847,6 @@ function handlers.textDocument_completion(params)
end
end
elseif trigger == "." then
-- Extract word before cursor, handling both cases:
-- 1) . IS in doc: cursor is after ., scan from col-1
-- 2) . NOT in doc yet: cursor is at word end, scan from col
local scan_end = col
local c = col > 0 and line:sub(col, col) or ""
if c == "" or c == "." then