@@ -453,10 +453,8 @@ jumpToDir fn = modifyHS_ $ \st -> if size st == 0 then st else
453453
454454------------------------------------------------------------------------
455455
456- --
457456-- a bit of bounded parametric polymorphism so we can abstract over record selectors
458457-- in the regex search stuff below
459- --
460458class Lookup a where extract :: a -> RawFilePath
461459instance Lookup Dir where extract = takeFileName . dname
462460instance Lookup File where extract = fbase
@@ -479,25 +477,20 @@ genericJumpToMatch :: Lookup a
479477 -> (HState -> (Array Int a , Int , Int ))
480478 -> (Int -> HState -> Int )
481479 -> IO ()
482-
483480genericJumpToMatch re sw k sel = do
484- found <- modifyHS $ \ st -> do
485- let mre = case re of
486- Nothing -> case regex st of
487- Nothing -> Nothing
488- Just (r, d) -> Just (r, d== sw)
489- Just s -> case compileM (P. pack s) [caseless, utf8] of
490- Left _ -> Nothing
491- Right v -> Just (v, sw)
492- flip (maybe (st, False )) mre \ (p, forwards) -> do
481+ found <- modifyHS \ st -> let
482+ mre = case re of
483+ Nothing -> (\ (r, d) -> (st, r, d == sw)) <$> regex st
484+ Just s -> case compileM (P. pack s) [caseless, utf8] of
485+ Left _ -> Nothing
486+ Right v -> Just (st { regex = Just (v, sw) }, v, sw)
487+ in flip (maybe (st, False )) mre \ (st', p, forwards) -> do
493488 let (fs, cur, m) = k st
494489 l = if forwards then [cur+ 1 .. m- 1 ] ++ [0 .. cur]
495490 else [cur- 1 ,cur- 2 .. 0 ] ++ [m- 1 ,m- 2 .. cur]
496- st' = st { regex = Just (p, forwards== sw) }
497491 case [ i | i <- l, isJust $ match p (extract (fs ! i)) [] ] of
498492 i: _ -> (st' { cursor = sel i st }, True )
499493 _ -> (st', False )
500-
501494 unless found $ putMessage $ Fast " No match found." defaultSty
502495
503496------------------------------------------------------------------------
0 commit comments