From d0e87af74c448e4a9439aa75b93afb7cbb6bf302 Mon Sep 17 00:00:00 2001 From: OwenMcGirr Date: Sat, 9 Mar 2024 10:00:26 +0000 Subject: [PATCH] Fix to escape row closes #207 --- .../service/scanning/tree/ScanTree.kt | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/enaboapps/switchify/service/scanning/tree/ScanTree.kt b/app/src/main/java/com/enaboapps/switchify/service/scanning/tree/ScanTree.kt index 4b4d188..c84aa30 100644 --- a/app/src/main/java/com/enaboapps/switchify/service/scanning/tree/ScanTree.kt +++ b/app/src/main/java/com/enaboapps/switchify/service/scanning/tree/ScanTree.kt @@ -195,22 +195,36 @@ class ScanTree( } /** - * This function checks if escaping the current row is necessary - * @return True if escaping the current row is necessary, false otherwise + * This function checks if the current row should be escaped + * @return Whether the current row should be escaped */ private fun shouldEscapeCurrentRow(): Boolean { // If at the last node, activate the escape row if (currentColumn == tree[currentRow].nodes.size - 1 && !shouldEscapeRow && scanDirection == ScanDirection.RIGHT) { shouldEscapeRow = true highlightCurrentRow() + + return true } else if (currentColumn == 0 && !shouldEscapeRow && scanDirection == ScanDirection.LEFT) { shouldEscapeRow = true highlightCurrentRow() + + return true } else if (shouldEscapeRow) { shouldEscapeRow = false unhighlightCurrentRow() + + // Ensure that the index is correct + currentColumn = if (scanDirection == ScanDirection.RIGHT) { + 0 + } else { + tree[currentRow].nodes.size - 1 + } + highlightCurrentNode() + + return true } - return shouldEscapeRow + return false } /**