Weird ScriptEditorService error?

Im trying to write my own autocomplete plugin with the ScriptEditorService API, however i keep getting this strange error when typing with the plugin enabled.

ScriptEditorService: Parsing failed with error Failed to read key "isIncomplete", value is not an object, but array, sending default response

The type that i took from the documentation does not include an isIncomplete key and the documentation also doesnt state that you should add one.
I tried printing the response and request arguments to see if an isIncomplete key was included but it wasnt.
Im trying to read the documentation to find what im missing but its not very helpful.

Plugin Script (Initializer)
local PluginHandler = require(script.PluginHandler)

PluginHandler.Init(plugin)
Plugin Handler Module
local SES = game:GetService("ScriptEditorService")

local PluginHandler = {}
PluginHandler.__index = PluginHandler

local Plugin: Plugin

type RegisterAutoCompleteRequest = {
	position: {
		line: number,
		character: number
	},
	textDocument: {
		document: ScriptDocument?,
		script: LuaSourceContainer?
	}
}

type RegisterAutoCompleteResponseItem = {
	label: string, -- The label
	kind: Enum.CompletionItemKind?,
	tags: {Enum.CompletionItemTag}?,
	detail: string?,
	documentation: {
		value: string,
	}?,
	overloads: number?,
	learnMoreLink: string?,
	codeSample: string?,
	preselect: boolean?,
	textEdit: {
		newText: string,
		insert: { start: { line: number, character: number }, ["end"]: { line: number, character: number } },
		replace: { start: { line: number, character: number }, ["end"]: { line: number, character: number } },
	}?
}

type RegisterAutoCompleteResponse = {
	items: {RegisterAutoCompleteResponseItem}
}

function PluginHandler.Init(plugin)
	local self = setmetatable({}, PluginHandler)
	Plugin = plugin
	self.toolbar = plugin:CreateToolbar("snip")
	self.toolbarButtons = {
		toggle = self.toolbar:CreateButton("toggle", "Toggles the plugin.", "rbxassetid://115610459646566")
	}
	self.enabled = false
	
	self:Start()
	return self
end

function PluginHandler:Start()
	print(":RUNUNRUNURNURNR")
	local toolbarButtons: {[string]: PluginToolbarButton} = self.toolbarButtons
	
	toolbarButtons.toggle.Click:Connect(function()
		self.enabled = not self.enabled
		print(`Plugin Enabled: {self.enabled}`)
		
		if self.enabled then
			SES:RegisterAutocompleteCallback("Snip", 1, function(request: RegisterAutoCompleteRequest, response: RegisterAutoCompleteResponse)
				print("WE ARE RUNNING", request, response)
				response.items = {}
				local item: RegisterAutoCompleteResponseItem = {
					label = "foo", 
					preselect = true, 
				}
				table.insert(response.items, item)
				return response
			end)
		else
			SES:DeregisterAutocompleteCallback("Snip")
		end
	end)
end


return PluginHandler
1 Like

Bump
Ive tried looking at the source code for other plugins doing the same thing and i dont understand at all what i am doing wrong
I am going completely insane trying to fix this issue

1 Like

the documentation shows this having an array called items, maybe isIncomplete is added by default

type Response = {
isIncomplete = idk -- added by default
  items: {
    {
      label: string, -- The label
      kind: Enum.CompletionItemKind?,
      tags: {Enum.CompletionItemTag}?,
      detail: string?,
      documentation: {
        value: string,
      }?,
      overloads: number?,
      learnMoreLink: string?,
      codeSample: string?,
      preselect: boolean?,
      textEdit: {
        newText: string,
        insert: { start: { line: number, character: number }, ["end"]: { line: number, character: number } },
        replace: { start: { line: number, character: number }, ["end"]: { line: number, character: number } },
      }?
    }
  }
}```
1 Like

thats what i thought at first but i printed the response and it wasnt there

i restarted studio and it suddenly works???

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.