@@ -13,7 +13,9 @@ import Data.IORef
1313import Data.Text qualified as Text
1414import Data.Text.IO qualified as Text
1515import Ki qualified
16+ import System.Console.Haskeline (Settings (autoAddHistory ))
1617import System.Console.Haskeline qualified as Line
18+ import System.Console.Haskeline.History qualified as Line
1719import System.IO (hGetEcho , hPutStrLn , hSetEcho , stderr , stdin )
1820import System.IO.Error (isDoesNotExistError )
1921import U.Codebase.HashTags (CausalHash )
@@ -102,17 +104,27 @@ getUserInput codebase authHTTPClient currentPath numberedArgs =
102104 ws -> do
103105 liftIO (parseInput codebase currentPath numberedArgs IP. patternMap ws) >>= \ case
104106 Left msg -> do
107+ -- We still add history that failed to parse so the user can easily reload
108+ -- the input and fix it.
109+ Line. modifyHistory $ Line. addHistoryUnlessConsecutiveDupe $ l
105110 liftIO $ putPrettyLn msg
106111 go
107112 Right Nothing -> do
108113 -- Ctrl-c or some input cancel, re-run the prompt
109114 go
110115 Right (Just (expandedArgs, i)) -> do
116+ let expandedArgsStr = unwords expandedArgs
111117 when (expandedArgs /= ws) $ do
112- liftIO . putStrLn $ fullPrompt <> unwords expandedArgs
118+ liftIO . putStrLn $ fullPrompt <> expandedArgsStr
119+ Line. modifyHistory $ Line. addHistoryUnlessConsecutiveDupe $ unwords expandedArgs
113120 pure i
114121 settings :: Line. Settings IO
115- settings = Line. Settings tabComplete (Just " .unisonHistory" ) True
122+ settings =
123+ Line. Settings
124+ { complete = tabComplete,
125+ historyFile = Just " .unisonHistory" ,
126+ autoAddHistory = False
127+ }
116128 tabComplete = haskelineTabComplete IP. patternMap codebase authHTTPClient currentPath
117129
118130main ::
0 commit comments