Skip to content

Commit 9739cfe

Browse files
authored
Merge pull request #4907 from unisonweb/cp/expand-fzf-args-in-history
Add history lines AFTER numbered arg and fzf expansion
2 parents b5cbbf4 + 49809ea commit 9739cfe

File tree

1 file changed

+14
-2
lines changed
  • unison-cli/src/Unison/CommandLine

1 file changed

+14
-2
lines changed

unison-cli/src/Unison/CommandLine/Main.hs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import Data.IORef
1313
import Data.Text qualified as Text
1414
import Data.Text.IO qualified as Text
1515
import Ki qualified
16+
import System.Console.Haskeline (Settings (autoAddHistory))
1617
import System.Console.Haskeline qualified as Line
18+
import System.Console.Haskeline.History qualified as Line
1719
import System.IO (hGetEcho, hPutStrLn, hSetEcho, stderr, stdin)
1820
import System.IO.Error (isDoesNotExistError)
1921
import 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

118130
main ::

0 commit comments

Comments
 (0)