From e560c6b5a0c2ef4437ebca0c78c1775a09ba31c9 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Fri, 18 May 2007 13:45:56 +0000 Subject: [PATCH] improve break-by-coordinate when setting a breakpoint by coordinate, if there are no spans covering the specified coordinate, then we take the leftmost of the spans to the right of the coordinate. This means that ':break c' will work if c is not a function, because the first span will be on c's right hand side. --- compiler/ghci/InteractiveUI.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index 78b65bf..486d403 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -1677,7 +1677,8 @@ findBreakByCoord :: Maybe FastString -> (Int,Int) -> TickArray findBreakByCoord mb_file (line, col) arr | not (inRange (bounds arr) line) = Nothing | otherwise = - listToMaybe (sortBy rightmost contains) + listToMaybe (sortBy rightmost contains) `mplus` + listToMaybe (sortBy leftmost_smallest after_here) where ticks = arr ! line @@ -1689,6 +1690,10 @@ findBreakByCoord mb_file (line, col) arr | Just f <- mb_file = GHC.srcSpanFile span == f | otherwise = True + after_here = [ tick | tick@(nm,span) <- ticks, + GHC.srcSpanStartLine span == line, + GHC.srcSpanStartCol span >= col ] + leftmost_smallest (_,a) (_,b) = a `compare` b leftmost_largest (_,a) (_,b) = (GHC.srcSpanStart a `compare` GHC.srcSpanStart b) -- 1.7.10.4