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