Need help improving my input buffer code

I’m working on an input buffer system for my game and I’ll admit I’m not super knowledgeable about it so it’s been a bit difficult to make it. Anyways, I at least have it working (kind of) the biggest issue is it’s not very accurate.

I have these 2 moves that have similar inputs instead of Right it’s DownRight. So the problem is if I try to input Tatsumaki the buffer ends up performing Shoryuken instead or vice versa or just something else entirely.

		{
			actionName = "Shoryuken",
			actionPriority = 1,
			inputs = {inputCommands.Left,inputCommands.Down,inputCommands.DownRight,inputCommands.Attack},
			command = nil,
		},
		{
			actionName = "Tatsumaki",
			actionPriority = 1,
			inputs = {inputCommands.Left,inputCommands.Down,inputCommands.Right,inputCommands.Attack},
			command = nil,
		},

The only thing I can think of is how I handle diagonal input it’s a bit hacky so it probably ruins things.

	local directions = {
		Up = {x = 0, y = -1},
		UpRight = {x = 1, y = -1},
		Right = {x = 1, y = 0},
		DownRight = {x = 1, y = 1},
		Down = {x = 0, y = 1},
		DownLeft = {x = -1, y = 1},
		Left = {x = -1, y = 0},
		UpLeft = {x = -1, y = -1},
	}
	local currentDirection = {x = 0, y = 0}		
	
	local function update(deltaTime)
		currentDirection.x = character.horizontalInput
		currentDirection.y = character.verticalInput

		for directionName, directionVector in pairs(directions) do
			if directionVector.x == currentDirection.x and directionVector.y == currentDirection.y then
				self.addCommand(inputCommands[directionName])
			end
		end				
		
		findBestActionMatch()
	end

Lastly this is the core of it all I’d say it’s what matches input to a move.

	local function findBestActionMatch()
		local actionIndex
		local inputIndex
		local commandBufferIndex
		local matchedInputCount

		for actionIndex = 1, #actions do
			commandBufferIndex = #commands
			matchedInputCount = 0
			--Walk backwards through input on list and find in command buffer
			for inputIndex = #actions[actionIndex].inputs, 1, -1 do
				while commandBufferIndex > 0 do
					if not commands or #commands == 0 then print("return 1") return end
					if not commands[commandBufferIndex] then print("return 2") return end
					--Consume commandBuffer until we find our target input (or run out of buffer)
					if actions[actionIndex].inputs[inputIndex] == commands[commandBufferIndex].inputCommand then
						matchedInputCount = matchedInputCount + 1
						break
					end
					commandBufferIndex = commandBufferIndex - 1
				end
			end

			--If we matched all inputs in an action, record that action and stop searching
			--Also clear the command buffer since it's all processed
			if matchedInputCount == #actions[actionIndex].inputs then
				lastMatchIndex = actionIndex
				commands = {}
				local command = actions[actionIndex].command
				if command then command.execute(client) else print(getBestMatchAsString()) end
				break
			end
		end
	end