Skip to content

Commit

Permalink
allow new option creation in SearchSelect
Browse files Browse the repository at this point in the history
  • Loading branch information
ners committed Apr 6, 2024
1 parent 037b71f commit f6683d5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/System/Terminal/Widgets/SearchSelect.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ data SearchSelect a = SearchSelect
, options :: [SearchSelectOption a]
, selections :: [a]
, optionText :: a -> Text
, newOption :: Text -> Maybe a
, minSelect :: Int
, maxSelect :: Int
, minSearchLength :: Int
Expand Down Expand Up @@ -133,4 +134,5 @@ makeOptionsVisible s
(newVisible, newInvisible) = splitAt s.maxVisible $ sortOn (Down . Fuzzy.score) $ score <$> s.options
newOptions =
(newVisible <&> (\x -> x.original & #visible .~ (x.score >= 0)))
<> [ SearchSelectOption{value, visible = True} | Just value <- [s.newOption filterText]]
<> (newInvisible <&> ((.original) >>> #visible .~ False))

0 comments on commit f6683d5

Please sign in to comment.