Ticket #9089: ghci_history_patch.2.diff

File ghci_history_patch.2.diff, 2.2 KB (added by jcristovao, 11 months ago)

Proper diff (code)

  • ghc/InteractiveUI.hs

    diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
    index 0a56799..bc07536 100644
    a b interactiveUI config srcs maybe_exprs = do 
    385385   _ <- GHC.setProgramDynFlags $ 
    386386      progDynFlags { log_action = ghciLogAction lastErrLocationsRef } 
    387387 
     388 
    388389  
    389390   liftIO $ when (isNothing maybe_exprs) $ do 
    390391        -- Only for GHCi (not runghc and ghc -e): 
    interactiveUI config srcs maybe_exprs = do 
    428429                   long_help          = fullHelpText config, 
    429430                   lastErrorLocations = lastErrLocationsRef 
    430431                 } 
     432 
    431433     
    432434   return () 
    433435 
    runGHCi paths maybe_exprs = do 
    473475      Right home -> return (Just (home </> ".ghci")) 
    474476      _ -> return Nothing 
    475477 
    476    canonicalizePath' :: FilePath -> IO (Maybe FilePath) 
    477    canonicalizePath' fp = liftM Just (canonicalizePath fp) 
    478                 `catchIO` \_ -> return Nothing 
    479  
    480478   sourceConfigFile :: (FilePath, Bool) -> GHCi () 
    481479   sourceConfigFile (file, check_perms) = do 
    482480     exists <- liftIO $ doesFileExist file 
    runGHCi paths maybe_exprs = do 
    562560  -- and finally, exit 
    563561  liftIO $ when (verbosity dflags > 0) $ putStrLn "Leaving GHCi." 
    564562 
     563canonicalizePath' :: FilePath -> IO (Maybe FilePath) 
     564canonicalizePath' fp = liftM Just (canonicalizePath fp) 
     565            `catchIO` \_ -> return Nothing 
     566 
    565567runGHCiInput :: InputT GHCi a -> GHCi a 
    566568runGHCiInput f = do 
    567569    dflags <- getDynFlags 
    568     histFile <- if gopt Opt_GhciHistory dflags 
    569                 then liftIO $ withGhcAppData (\dir -> return (Just (dir </> "ghci_history"))) 
    570                                              (return Nothing) 
    571                 else return Nothing 
     570    current_dir <- liftIO $ canonicalizePath' ".ghci_history" 
     571    app_user_dir <- liftIO $ withGhcAppData (\dir -> return (Just (dir </> "ghci_history"))) 
     572                                            (return Nothing) 
     573    let ghciHistory = current_dir <|> app_user_dir 
     574 
     575    histFile <- liftIO . return $ if gopt Opt_GhciHistory dflags 
     576                    then ghciHistory 
     577                    else Nothing 
     578 
    572579    runInputT 
    573580        (setComplete ghciCompleteWord $ defaultSettings {historyFile = histFile}) 
    574581        f