ScriptEditorServiceAPI - AutoComplete Help

  1. What do you want to achieve? Keep it simple and clear!
    I’m doing a plugin with various auto completions, and self-made. I’m currently trying to fix a bug I’m getting when it auto-completes.

  2. What is the issue? Include screenshots / videos if possible!
    When it auto-completes, the text you writed will remain there. Look it!

    video

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve already tried CompletionItemKind… Not working!

This is my current RequestFinished function:

function completionRequestFinished(Req : Request, Resp : Response): Response
	for i, v in pairs(require(script.Parent.Modules.Completions)) do
		local ScriptDocument = Req.textDocument.document
		if ScriptDocument:IsCommandBar() or not (ScriptDocument:IsCommandBar() ~= nil) then return Resp end
		local StartLine, StartCharacter = ScriptDocument:GetSelectionStart()
		local EndLine, EndCharacter = ScriptDocument:GetSelectionEnd()
		
		table.insert(Resp.items, {
			label = i, 
			codeSample = v.codeSample,
			detail = v.Description,
			kind = v.CompletionItemKind,
			textEdit = {
				newText = v.Code,
				replace = {
					start = {line = StartLine, character = StartCharacter},
					["end"] = {line = EndLine, character = EndCharacter}
				}
			}
		})
	end
	
	return Resp
end

If it’s needed I can give more part of the script.