-- << LOCAL FUNCTION >>

local function selectSuggestion(props)
	local newInput = ""
	local suggestion = props.suggestionLabels["Label"..props.suggestionPos]
	if props.specificArg then
		newInput = suggestion.Name.." "
		--
		props.textBox.Text = newInput
		coroutine.wrap(function()
			for i = 1,10 do
				props.textBox:ReleaseFocus()
				wait()
			end
		end)()
		wait()
		props.textBox.Text = newInput
	else
		local newInputTable = {}
		local argPosCount = -1
		local firstChar = string.sub(props.textBox.Text,1,1)
		props.textBox.Text:gsub('([^'..main.pdata.SplitKey..']+)',function(c) argPosCount = argPosCount + 1 if argPosCount > suggestion.ArgPos-1 then return end table.insert(newInputTable, c.." ") end);
		if argPosCount == 0 and (firstChar == main.settings.UniversalPrefix or firstChar == main.pdata.Prefix) then
			newInput = firstChar
		end
		newInput = newInput..table.concat(newInputTable, "")
		newInput = newInput..suggestion.Name
		newInput = newInput..main.pdata.SplitKey
		--
		props.textBox.Text = newInput
		wait()
		props.textBox.Text = newInput
		props.textBox:CaptureFocus()
		props.textBox.CursorPosition = #newInput+1
	end
end


