From db33e2a93cc2b6614e479dc49dc7b444c82782cd Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Thu, 19 Apr 2007 14:39:54 +0000 Subject: [PATCH] improve the heuristics to pick the best breakpoint on a given line --- compiler/ghci/InteractiveUI.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index 1ab604c..3713c4c 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -1609,8 +1609,8 @@ findBreakByLine :: Int -> TickArray -> Maybe (BreakIndex,SrcSpan) findBreakByLine line arr | not (inRange (bounds arr) line) = Nothing | otherwise = - listToMaybe (sortBy leftmost complete) `mplus` - listToMaybe (sortBy leftmost incomplete) `mplus` + listToMaybe (sortBy leftmost_largest complete) `mplus` + listToMaybe (sortBy leftmost_smallest incomplete) `mplus` listToMaybe (sortBy rightmost ticks) where ticks = arr ! line @@ -1632,7 +1632,10 @@ findBreakByCoord (line, col) arr -- the ticks that span this coordinate contains = [ tick | tick@(nm,span) <- ticks, span `spans` (line,col) ] -leftmost (_,a) (_,b) = a `compare` b +leftmost_smallest (_,a) (_,b) = a `compare` b +leftmost_largest (_,a) (_,b) = (srcSpanStart a `compare` srcSpanStart b) + `thenCmp` + (srcSpanEnd b `compare` srcSpanEnd a) rightmost (_,a) (_,b) = b `compare` a spans :: SrcSpan -> (Int,Int) -> Bool -- 1.7.10.4