From 3ca63d278b0c2c2497bdf6a92a6317a8c8602e76 Mon Sep 17 00:00:00 2001 From: Lazar Bulovan Date: Wed, 22 Jul 2026 20:14:57 +0200 Subject: [PATCH] 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 .. --- src/main.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main.lua b/src/main.lua index fb8a951..d894d5d 100644 --- a/src/main.lua +++ b/src/main.lua @@ -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