From b8c389eac5f875fc7ae9a5ab9ac446d24a079448 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 28 Dec 2024 14:41:44 +0530 Subject: Fix issue with highlight index clamping --- TODO.norg | 1 - src/Chelleport/AppState.hs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/TODO.norg b/TODO.norg index c5902e6..41f40c7 100644 --- a/TODO.norg +++ b/TODO.norg @@ -1,5 +1,4 @@ * Current - - ( ) Sort ocr match result by position on screen (top to bottom, left to right) - ( ) TextStyle for drawText - ( ) Middle click - ( ) Separate state for hint modes into ModeHint constructor diff --git a/src/Chelleport/AppState.hs b/src/Chelleport/AppState.hs index 6c2de9c..4c8e0a8 100644 --- a/src/Chelleport/AppState.hs +++ b/src/Chelleport/AppState.hs @@ -77,7 +77,7 @@ update _ state (IncrementHighlightIndex n) = do action <- traverse (fmap MoveMousePosition . wordPosition) highlightedWord pure (state {stateRepetition = 1, stateMode = mode {searchHighlightedIndex = highlightedIndexClamped}}, action) where - highlightedWord = searchFilteredWords mode `itemAt` highlightedIndex + highlightedWord = searchFilteredWords mode `itemAt` highlightedIndexClamped highlightedIndex = searchHighlightedIndex mode + n highlightedIndexClamped = if highlightedIndex < 0 -- cgit v1.3.1