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:
+5
-5
@@ -759,7 +759,7 @@ end
|
|||||||
local function add_param_items(items, params, prefix_filter)
|
local function add_param_items(items, params, prefix_filter)
|
||||||
for _, inp in ipairs(params.inputs or {}) do
|
for _, inp in ipairs(params.inputs or {}) do
|
||||||
local label = inp.name .. " := "
|
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, {
|
table.insert(items, {
|
||||||
label = label,
|
label = label,
|
||||||
kind = 13,
|
kind = 13,
|
||||||
@@ -771,7 +771,7 @@ local function add_param_items(items, params, prefix_filter)
|
|||||||
end
|
end
|
||||||
for _, out in ipairs(params.outputs or {}) do
|
for _, out in ipairs(params.outputs or {}) do
|
||||||
local label = out.name .. " => "
|
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, {
|
table.insert(items, {
|
||||||
label = label,
|
label = label,
|
||||||
kind = 13,
|
kind = 13,
|
||||||
@@ -835,7 +835,7 @@ function handlers.textDocument_completion(params)
|
|||||||
if doc.variables then
|
if doc.variables then
|
||||||
local prefix = has_hash_prefix and line_before:match("#([%w_]*)$") or word_prefix
|
local prefix = has_hash_prefix and line_before:match("#([%w_]*)$") or word_prefix
|
||||||
for name, info in pairs(doc.variables) do
|
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, {
|
table.insert(items, {
|
||||||
label = "#" .. name,
|
label = "#" .. name,
|
||||||
filterText = "#" .. name,
|
filterText = "#" .. name,
|
||||||
@@ -972,7 +972,7 @@ function handlers.textDocument_completion(params)
|
|||||||
-- Add declared variables (label without # so client-side matching works)
|
-- Add declared variables (label without # so client-side matching works)
|
||||||
if doc.variables then
|
if doc.variables then
|
||||||
for name, info in pairs(doc.variables) do
|
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, {
|
table.insert(items, {
|
||||||
label = name,
|
label = name,
|
||||||
filterText = name,
|
filterText = name,
|
||||||
@@ -1006,7 +1006,7 @@ function handlers.textDocument_completion(params)
|
|||||||
-- Add declared variables in general context too
|
-- Add declared variables in general context too
|
||||||
if doc.variables then
|
if doc.variables then
|
||||||
for name, info in pairs(doc.variables) do
|
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, {
|
table.insert(items, {
|
||||||
label = name,
|
label = name,
|
||||||
filterText = name,
|
filterText = name,
|
||||||
|
|||||||
Reference in New Issue
Block a user