fix: show function call parameters immediately on ( trigger

The word_prefix calculation was scanning backwards from col-1, so after
instTestTimer( it would pick up 'instTestTimer' and cause the client to
filter out all parameters (none start with the function name). Fixed to
scan from col so delimiters like ( stop the scan, giving word_prefix=''.

Also added fallback in else branch when ( is not yet in the document line
(timing issue where completion arrives before didChange is processed).
This commit is contained in:
2026-07-22 13:56:08 +02:00
parent 00cf1b0074
commit eb62107066
+6 -2
View File
@@ -808,11 +808,12 @@ function handlers.textDocument_completion(params)
local line_before = col > 1 and line:sub(1, col - 1) or ""
-- Get word prefix being typed (for filtering)
local prefix_start = col - 1
-- Start from col (not col-1) so delimiters like ( stop the scan
local prefix_start = col
while prefix_start > 0 and line:sub(prefix_start, prefix_start):match("[%w_]") do
prefix_start = prefix_start - 1
end
local word_prefix = line:sub(prefix_start + 1, col - 1)
local word_prefix = col > prefix_start and line:sub(prefix_start + 1, col) or ""
-- Check if typing after # prefix (e.g., #myVar)
local has_hash_prefix = line_before:match("#[%w_]*$")
@@ -932,6 +933,9 @@ 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