X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fghci%2FInteractiveUI.hs;h=055b7164dee550f8bdb8d57041c392ea52ae07c8;hb=bf64104355b284aa7513ba0ff160a2f0df942ea9;hp=78b65bfbc51654af130683fdd65b28b9ddefceb2;hpb=180e4344fab89e3e2c1aaaaaf1509c79f4bdb562;p=ghc-hetmet.git diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index 78b65bf..055b716 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -70,6 +70,7 @@ import System.Exit ( exitWith, ExitCode(..) ) import System.Directory import System.IO import System.IO.Error as IO +import System.FilePath import Data.Char import Data.Dynamic import Data.Array @@ -555,6 +556,7 @@ runCommandEval c = ghciHandle handleEval (doCommand c) runStmt :: String -> SingleStep -> GHCi Bool runStmt stmt step | null (filter (not.isSpace) stmt) = return False + | ["import", mod] <- words stmt = keepGoing setContext ('+':mod) | otherwise = do st <- getGHCiState session <- getSession @@ -1677,7 +1679,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 +1692,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) @@ -1769,7 +1776,8 @@ listModuleLine modl line = do -- If the highlight flag is True, also highlight the span using -- start_bold/end_bold. listAround span do_highlight = do - contents <- BS.readFile (unpackFS file) + pwd <- getEnv "PWD" + contents <- BS.readFile (pwd unpackFS file) let lines = BS.split '\n' contents these_lines = take (line2 - line1 + 1 + pad_before + pad_after) $