Skip to content

Commit 49911c7

Browse files
committed
fix: minor highlightItem regression
1 parent 57b8dd7 commit 49911c7

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/Action/Search.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ targetResultDisplay link color qs Target{..} = unHTML $ unwords $
8181
["-- " ++ targetURL | link]
8282

8383
ansiHighlight :: [Query] -> String -> String
84-
ansiHighlight = highlightItem id ((dull ++) . (++ rst)) ((bold ++) . (++ rst))
84+
ansiHighlight = highlightItem id id ((dull ++) . (++ rst)) ((bold ++) . (++ rst))
8585
where
8686
dull = setSGRCode [SetColor Foreground Dull Yellow]
8787
bold = setSGRCode [SetColor Foreground Vivid Yellow]

src/Action/Server.hs

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

257257

258258
displayItem :: [Query] -> String -> Markup
259-
displayItem = highlightItem H.preEscapedString H.string (H.b . H.string)
259+
displayItem = highlightItem H.string H.preEscapedString H.string (H.b . H.string)
260260

261261
action_server_test_ :: IO ()
262262
action_server_test_ = do

src/Input/Item.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,20 +190,20 @@ 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
199199
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)
200+
groupOn fst . (\x -> zip (findQueries x) x)
201201
where
202-
mapIsInQueries :: String -> [Bool]
203-
mapIsInQueries (x:xs) | m > 0 = replicate m True ++ (mapIsInQueries $ drop (m - 1) xs)
202+
findQueries :: String -> [Bool]
203+
findQueries (x:xs) | m > 0 = replicate m True ++ drop (m - 1) (findQueries xs)
204204
where m = maximum $ 0 : [length y | QueryName y <- qs, lower y `isPrefixOf` lower (x:xs)]
205-
mapIsInQueries (x:xs) = False : mapIsInQueries xs
206-
mapIsInQueries [] = []
205+
findQueries (x:xs) = False : findQueries xs
206+
findQueries [] = []
207207

208208
---------------------------------------------------------------------
209209
-- HSE CONVERSION

0 commit comments

Comments
 (0)