Skip to content

Commit 413c04e

Browse files
committed
fix: minor highlightItem regression
1 parent 567c6dd commit 413c04e

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/Action/Search.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ targetResultDisplay link color qs Target{..} = unHTML $ unwords $
8888
highlightFull = hyperlinkCode targetURL . ansiHighlight qs
8989

9090
ansiHighlight :: [Query] -> String -> String
91-
ansiHighlight = highlightItem id ((dull ++) . (++ rst)) ((bold ++) . (++ rst))
91+
ansiHighlight = highlightItem id id ((dull ++) . (++ rst)) ((bold ++) . (++ rst))
9292
where
9393
dull = setSGRCode [SetColor Foreground Dull Yellow]
9494
bold = setSGRCode [SetColor Foreground Vivid Yellow]

src/Action/Server.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ showURL _ _ x = x
257257

258258

259259
displayItem :: [Query] -> String -> Markup
260-
displayItem = highlightItem H.preEscapedString H.string (H.b . H.string)
260+
displayItem = highlightItem H.string H.preEscapedString H.string (H.b . H.string)
261261

262262
action_server_test_ :: IO ()
263263
action_server_test_ = do

src/Input/Item.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,22 +190,22 @@ item_test = testing "Input.Item.Target JSON (encode . decode = id) " $ do
190190
(Left e ) -> False
191191
(Right t') -> t == t'
192192

193-
highlightItem:: Monoid m => (String -> m) -> (String -> m) -> (String -> m) -> [Query] -> String -> m
194-
highlightItem plain dull bold qs x
193+
highlightItem:: Monoid m => (String -> m) -> (String -> m) -> (String -> m) -> (String -> m) -> [Query] -> String -> m
194+
highlightItem plain safe dull bold qs x
195195
| Just (pre,x) <- stripInfix "<s0>" x, Just (name,post) <- stripInfix "</s0>" x
196-
= plain pre <> highlight (unescapeHTML name) <> plain post
196+
= safe pre <> highlight (unescapeHTML name) <> safe post
197197
| otherwise = plain x
198198
where
199-
highlight = mconcatMap (\xs@((b,_):_) -> let s = map snd xs in if b then bold s else dull s) .
200-
groupOn fst . (\x -> zip (mapIsInQueries x) x)
199+
highlight x = mconcatMap (\xs@((b,_):_) -> let s = map snd xs in if b then bold s else dull s) $
200+
groupOn fst $ zip (findQueries x) x
201201
where
202202
-- generates a bool mask, which is only true for charachters that compose given queries
203203
-- e.g. [ "query" "ya" ] -> [ "AqUeRyAA" ] -> 01111110
204-
mapIsInQueries :: String -> [Bool]
205-
mapIsInQueries (x:xs) | m > 0 = replicate m True ++ (mapIsInQueries $ drop (m - 1) xs)
204+
findQueries :: String -> [Bool]
205+
findQueries (x:xs) | m > 0 = replicate m True ++ drop (m - 1) (findQueries xs)
206206
where m = maximum $ 0 : [length y | QueryName y <- qs, lower y `isPrefixOf` lower (x:xs)]
207-
mapIsInQueries (x:xs) = False : mapIsInQueries xs
208-
mapIsInQueries [] = []
207+
findQueries (x:xs) = False : findQueries xs
208+
findQueries [] = []
209209

210210
---------------------------------------------------------------------
211211
-- HSE CONVERSION

0 commit comments

Comments
 (0)