on master help sign in
Fix repetition in Idris Highlights.

Dumped highlighting information contains a lot of duplication. When sending highlighting information make sure it is unique. This fix simply nubs the list based on file position and output annotation to ensure uniqness. Otherwise the Eq instance for FC defaults to true and removes everything.

commit90683e317fdb093fe46d3dfbef105ac51460b646 authorJan de Muijnck-Hughes <jan.deMuijnck-Hughes@glasgow.ac.uk> dateWed 30 May 2018, 21:26 (8 years ago) parent02f0ec3
1 file changed+6−5
src/Idris/Output.hs+6−5
src/Idris/Output.hs+6−5
@@ -38,7 +38,7 @@ import Prelude hiding ((<$>))
3838
3939import Control.Arrow (first)
4040import Control.Monad.Trans.Except (ExceptT(ExceptT), runExceptT)
41−import Data.List (intersperse, nub)
41+import Data.List (intersperse, nub, nubBy)
4242import Data.Maybe (fromJust, fromMaybe, isJust, listToMaybe)
4343import System.Console.Haskeline.MonadException (MonadException(controlIO),
4444 RunIO(RunIO))
@@ -372,12 +372,12 @@ sendHighlighting highlights =
372372 case idris_outputmode ist of
373373 RawOutput _ -> updateIState $
374374 \ist -> ist { idris_highlightedRegions =
375− highlights ++ idris_highlightedRegions ist }
375+ nubBy canNub $ highlights ++ idris_highlightedRegions ist }
376376 IdeMode n h ->
377377 let fancier = [ toSExp (fc, fancifyAnnots ist False annot)
378− | (fc, annot) <- highlights, fullFC fc
379− ]
380− in case fancier of
378+ | (fc, annot) <- nubBy canNub highlights, fullFC fc
379+ ] in
380+ case fancier of
381381 [] -> return ()
382382 _ -> runIO . hPutStrLn h $
383383 convSExp "output"
@@ -386,6 +386,7 @@ sendHighlighting highlights =
386386
387387 where fullFC (FC _ _ _) = True
388388 fullFC _ = False
389+ canNub (fA,x) (fB,y) = show fA == show fB && x == y
389390
390391-- | Write the highlighting information to a file, for use in external tools
391392-- or in editors that don't support the IDE protocol