I’m creating a shorthand autocomplete plugin that allows developers to define commands with arguments that then autocomplete out to custom code blocks.
The issue I’ve ran into is that after an argument reaches a certain length, the autocomplete option disappears. The option reappears once the next argument is made, and the most peculiar thing is that the length where the option cuts off seems to be based on the characters used in the argument - for example, ‘aaaaaa’ as an argument requires six As to cut off, but ‘bb’ as an argument also cuts off with just 2 characters.
I’ve taken a look through the documentation for custom autocomplete and this devforum but found nothing relevant.
Here’s the snippet of code responsible for these custom commands:
local commands = require(commands_module)
for command : string, replacement_function : ({string}) -> string in pairs(commands) do
local command_args = string.split(true_line, "/")
local command_name : string = command:sub(1, string.len(command_args[1]))
if command_name ~= command_args[1] then continue end
table.remove(command_args, 1)
local replacement = replacement_function(command_args)
print('adding response item for', command)
table.insert(response.items, {
label = "Command: " .. command,
kind = Enum.CompletionItemKind.Folder,
details = "Adds text according to the command specified.",
preselect = true,
codeSample = "",
textEdit = {
newText = replacement,
replace = {
start = {line = current_line, character = 1},
["end"] = {line = current_line, character = #replacement + 1}
}
}
})
end
In short, the autocomplete option is not showing up when the text has too many characters, even though I’ve made sure it’s in the table of options.
Any and all help is greatly appreciated.