Skip to content

Commit 004fe25

Browse files
authored
Merge pull request #6045 from unisonweb/cp/fix-paging
2 parents 83f808c + ce5c2fc commit 004fe25

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

unison-cli/src/Unison/Codebase/Editor/Output.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module Unison.Codebase.Editor.Output
1515
ShareError (..),
1616
isFailure,
1717
isNumberedFailure,
18+
outputShouldUsePager,
1819
)
1920
where
2021

@@ -534,6 +535,15 @@ data UndoFailureReason = CantUndoPastStart | CantUndoPastMerge deriving (Show)
534535

535536
type SourceFileContents = Text
536537

538+
outputShouldUsePager :: Output -> Bool
539+
outputShouldUsePager o = case o of
540+
-- These are typically non-interactive outputs, so we don't page them.
541+
LoadingFile {} -> False
542+
Typechecked {} -> False
543+
Evaluated {} -> False
544+
EvaluationFailure {} -> False
545+
_ -> True
546+
537547
isFailure :: Output -> Bool
538548
isFailure o = case o of
539549
DeleteFailure {} -> True

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import Unison.Codebase qualified as Codebase
3333
import Unison.Codebase.Branch (Branch)
3434
import Unison.Codebase.Editor.HandleInput qualified as HandleInput
3535
import Unison.Codebase.Editor.Input (Event (UnisonFileChanged), Input (..))
36-
import Unison.Codebase.Editor.Output (NumberedArgs, Output)
36+
import Unison.Codebase.Editor.Output (NumberedArgs, Output, outputShouldUsePager)
3737
import Unison.Codebase.Editor.UCMVersion (UCMVersion)
3838
import Unison.Codebase.ProjectPath qualified as PP
3939
import Unison.Codebase.Watch qualified as Watch
@@ -225,8 +225,6 @@ main dir welcome ppIds initialInputs runtime sbRuntime codebase serverBaseUrl uc
225225

226226
let initialState = Cli.loopState0 ppIds
227227
initialInputsRef <- newIORef $ Welcome.run welcome ++ initialInputs ++ invalidProjectNamesInputs
228-
pageOutput <- newIORef True
229-
230228
initialEcho <- hGetEcho stdin
231229
let restoreEcho = (\currentEcho -> when (currentEcho /= initialEcho) $ hSetEcho stdin initialEcho)
232230
let getInput :: Cli.LoopState -> IO Input
@@ -243,14 +241,11 @@ main dir welcome ppIds initialInputs runtime sbRuntime codebase serverBaseUrl uc
243241
getProjectRoot
244242
(loopState ^. #numberedArgs)
245243
let notify :: Output -> IO ()
246-
notify =
247-
notifyUser (pure dir) fetchIssueFromGitHub
248-
>=> ( \o ->
249-
ifM
250-
(readIORef pageOutput)
251-
(putPrettyNonempty o)
252-
(putPrettyLnUnpaged o)
253-
)
244+
notify o = do
245+
rendered <- notifyUser (pure dir) fetchIssueFromGitHub o
246+
if outputShouldUsePager o
247+
then putPrettyNonempty rendered
248+
else putPrettyLnUnpaged rendered
254249

255250
let awaitInput :: Cli.LoopState -> IO (Either Event Input)
256251
awaitInput loopState = do
@@ -267,11 +262,11 @@ main dir welcome ppIds initialInputs runtime sbRuntime codebase serverBaseUrl uc
267262
[ do
268263
event <- Ki.await fileEventThread
269264
pure do
270-
writeIORef pageOutput False
271265
pure (Left event),
272266
do
273267
input <- Ki.await userInputThread
274-
pure (pure (Right input))
268+
pure do
269+
pure (Right input)
275270
]
276271
action
277272

0 commit comments

Comments
 (0)