From eb62107066b9514e360c9847a655e022c0b08353 Mon Sep 17 00:00:00 2001 From: Lazar Bulovan Date: Wed, 22 Jul 2026 13:56:08 +0200 Subject: [PATCH] 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). --- src/main.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.lua b/src/main.lua index fb7b2b9..cfcc9c9 100644 --- a/src/main.lua +++ b/src/main.lua @@ -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