Skip to content

Commit 01ee1db

Browse files
author
Jaro Reinders
committed
Merge branch 'friendly-fuzzy' of https://github.com/stites/yi
2 parents 3b237c3 + d7904f0 commit 01ee1db

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

yi-fuzzy-open/src/Yi/Fuzzy.hs

+13-15
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,13 @@ data FuzzyItem
6464

6565
instance Show FuzzyItem where
6666
show :: FuzzyItem -> String
67-
show i = case i of
68-
FileItem _ -> "File " <> itemAsStr i
69-
BufferItem _ -> "Buffer " <> itemAsStr i
67+
show i@(FileItem _) = "File " <> itemAsStr i
68+
show i@(BufferItem _) = "Buffer " <> itemAsStr i
7069

7170
itemAsTxt :: FuzzyItem -> Text
72-
itemAsTxt f = case f of
73-
FileItem x -> x
74-
BufferItem (MemBuffer x) -> x
75-
BufferItem (FileBuffer x) -> T.pack x
71+
itemAsTxt (FileItem x) = x
72+
itemAsTxt (BufferItem (MemBuffer x)) = x
73+
itemAsTxt (BufferItem (FileBuffer x)) = T.pack x
7674

7775
itemAsStr :: FuzzyItem -> String
7876
itemAsStr = T.unpack . itemAsTxt
@@ -197,13 +195,14 @@ changeIndex :: (PointedList FuzzyItem -> Maybe (PointedList FuzzyItem)) -> Fuzzy
197195
changeIndex dir fs = fs { items = items fs >>= dir }
198196

199197
renderE :: FuzzyState -> EditorM ()
200-
renderE (FuzzyState maybeZipper s) = do
198+
renderE (FuzzyState maybeZipper s) =
201199
case mcontent of
202200
Nothing -> printMsg "No match found"
203201
Just content -> setStatus (toList content, defaultStyle)
204202
where
205203
tshow :: Show s => s -> Text
206204
tshow = T.pack . show
205+
207206
mcontent :: Maybe (NonEmpty Text)
208207
mcontent = do
209208
zipper <- maybeZipper
@@ -238,13 +237,12 @@ openRoutine preOpenAction = do
238237
action f
239238
where
240239
action :: FuzzyItem -> YiM ()
241-
action fi = case fi of
242-
FileItem x -> void (editFile (T.unpack x))
243-
BufferItem x -> withEditor $ do
244-
bufs <- gets (M.assocs . buffers)
245-
case filter ((==x) . ident . attributes . snd) bufs of
246-
[] -> error ("Couldn't find " <> show x)
247-
(bufRef, _):_ -> switchToBufferE bufRef
240+
action (FileItem x) = void (editFile (T.unpack x))
241+
action (BufferItem x) = withEditor $ do
242+
bufs <- gets (M.assocs . buffers)
243+
case filter ((==x) . ident . attributes . snd) bufs of
244+
[] -> error ("Couldn't find " <> show x)
245+
(bufRef, _):_ -> switchToBufferE bufRef
248246

249247

250248
insertChar :: Keymap

0 commit comments

Comments
 (0)