fix: find with plain=true makes ^ literal, breaking all prefix matching

Nine sites used name:upper():find('^' .. prefix:upper(), 1, true).
With plain=true, '^' is treated as a literal character, so the prefix
was never found and no variables/params ever matched the typed text.

Replaced all with substring comparison:
  name:upper():sub(1, #prefix) == prefix:upper()

This fixes:
- Variable completion without # prefix (instTestTimer never matched)
- Function parameter filtering by typed prefix (IN never matched IN)
- # trigger variable filtering
This commit is contained in:
2026-07-22 15:09:53 +02:00
parent 3abb0f5d9a
commit 2184007cf6
+5 -5
View File
@@ -759,7 +759,7 @@ end
local function add_param_items(items, params, prefix_filter)
for _, inp in ipairs(params.inputs or {}) do
local label = inp.name .. " := "
if prefix_filter == "" or inp.name:upper():find("^" .. prefix_filter:upper(), 1, true) then
if prefix_filter == "" or inp.name:upper():sub(1, #prefix_filter) == prefix_filter:upper() then
table.insert(items, {
label = label,
kind = 13,
@@ -771,7 +771,7 @@ local function add_param_items(items, params, prefix_filter)
end
for _, out in ipairs(params.outputs or {}) do
local label = out.name .. " => "
if prefix_filter == "" or out.name:upper():find("^" .. prefix_filter:upper(), 1, true) then
if prefix_filter == "" or out.name:upper():sub(1, #prefix_filter) == prefix_filter:upper() then
table.insert(items, {
label = label,
kind = 13,
@@ -835,7 +835,7 @@ function handlers.textDocument_completion(params)
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():find("^" .. prefix:upper(), 1, true) then
if prefix == "" or name:upper():sub(1, #prefix) == prefix:upper() then
table.insert(items, {
label = "#" .. name,
filterText = "#" .. name,
@@ -972,7 +972,7 @@ function handlers.textDocument_completion(params)
-- Add declared variables (label without # so client-side matching works)
if doc.variables then
for name, info in pairs(doc.variables) do
if word_prefix == "" or name:upper():find("^" .. word_prefix:upper(), 1, true) then
if word_prefix == "" or name:upper():sub(1, #word_prefix) == word_prefix:upper() then
table.insert(items, {
label = name,
filterText = name,
@@ -1006,7 +1006,7 @@ function handlers.textDocument_completion(params)
-- Add declared variables in general context too
if doc.variables then
for name, info in pairs(doc.variables) do
if word_prefix == "" or name:upper():find("^" .. word_prefix:upper(), 1, true) then
if word_prefix == "" or name:upper():sub(1, #word_prefix) == word_prefix:upper() then
table.insert(items, {
label = name,
filterText = name,