aboutsummaryrefslogtreecommitdiff
path: root/src/Chelleport/AppState.hs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-26 21:53:49 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-26 21:54:13 +0530
commit3d461b234d0b30cb7085251390b264089f447a97 (patch)
tree06115a2e632baebc7516b7ef3d94719fe9c2b6df /src/Chelleport/AppState.hs
parent2819868eb398ebe7da0e59391367e5825f8fe2c5 (diff)
downloadchelleport-3d461b234d0b30cb7085251390b264089f447a97.tar.gz
chelleport-3d461b234d0b30cb7085251390b264089f447a97.zip
Add fuzzy search for search mode
Diffstat (limited to 'src/Chelleport/AppState.hs')
-rw-r--r--src/Chelleport/AppState.hs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/Chelleport/AppState.hs b/src/Chelleport/AppState.hs
index 697e9c4..72a1afe 100644
--- a/src/Chelleport/AppState.hs
+++ b/src/Chelleport/AppState.hs
@@ -11,6 +11,7 @@ import Control.Monad (replicateM_)
import Data.Char (toLower)
import Data.List (isInfixOf)
import Data.Maybe (fromMaybe, isJust)
+import qualified Text.Fuzzy as Fuzzy
initialState :: (Monad m) => m (State, Maybe AppAction)
initialState = do
@@ -67,7 +68,7 @@ update state@(State {stateMode = ModeSearch {searchWords, searchInputText}}) (Ha
mode = stateMode state
filterMatches text
| isEmpty text = searchWords
- | otherwise = filter (isInfixOf text . map toLower . matchText) searchWords
+ | otherwise = Fuzzy.original <$> Fuzzy.filter text searchWords "" "" matchText False
-- Increment highlighted index for search mode
update state (IncrementHighlightIndex n) = do