@@ -50,9 +50,6 @@ module Unison.Cli.Monad
50
50
runTransactionWithRollback ,
51
51
runTransactionWithRollback2 ,
52
52
53
- -- * Internal
54
- setMostRecentProjectPath ,
55
-
56
53
-- * Misc types
57
54
LoadSourceResult (.. ),
58
55
)
@@ -169,6 +166,8 @@ data Env = Env
169
166
generateUniqueName :: IO Parser. UniqueName ,
170
167
-- | How to load source code.
171
168
loadSource :: SourceName -> IO LoadSourceResult ,
169
+ -- | Notify the LSP that this ProjectPathIds might be different from the last (e.g. on branch update, switch, etc).
170
+ lspCheckForChanges :: PP. ProjectPathIds -> IO () ,
172
171
-- | How to write source code. Bool = make new fold?
173
172
writeSource :: SourceName -> Text -> Bool -> IO () ,
174
173
-- | What to do with output for the user.
@@ -388,19 +387,24 @@ getProjectPathIds = do
388
387
389
388
cd :: Path. Absolute -> Cli ()
390
389
cd path = do
390
+ env <- ask
391
391
pp <- getProjectPathIds
392
392
let newPP = pp & PP. absPath_ .~ path
393
- setMostRecentProjectPath newPP
393
+ runTransaction ( Codebase. setCurrentProjectPath newPP)
394
394
# projectPathStack %= NonEmpty. cons newPP
395
+ liftIO (env. lspCheckForChanges newPP)
395
396
396
397
switchProject :: ProjectAndBranch ProjectId ProjectBranchId -> Cli ()
397
398
switchProject pab@ (ProjectAndBranch projectId branchId) = do
398
- Env {codebase} <- ask
399
+ env <- ask
399
400
let newPP = PP. ProjectPath projectId branchId Path. absoluteEmpty
400
401
# projectPathStack %= NonEmpty. cons newPP
401
- runTransaction $ do Q. setMostRecentBranch projectId branchId
402
- setMostRecentProjectPath newPP
403
- liftIO $ Codebase. preloadProjectBranch codebase pab
402
+ runTransaction do
403
+ Q. setMostRecentBranch projectId branchId
404
+ Codebase. setCurrentProjectPath newPP
405
+ liftIO do
406
+ Codebase. preloadProjectBranch env. codebase pab
407
+ env. lspCheckForChanges newPP
404
408
405
409
-- | Pop the latest path off the stack, if it's not the only path in the stack.
406
410
--
@@ -411,14 +415,13 @@ popd = do
411
415
case List.NonEmpty. uncons (projectPathStack state) of
412
416
(_, Nothing ) -> pure False
413
417
(_, Just paths) -> do
414
- setMostRecentProjectPath (List.NonEmpty. head paths)
418
+ let path = List.NonEmpty. head paths
419
+ runTransaction (Codebase. setCurrentProjectPath path)
415
420
State. put state {projectPathStack = paths}
421
+ env <- ask
422
+ liftIO (env. lspCheckForChanges path)
416
423
pure True
417
424
418
- setMostRecentProjectPath :: PP. ProjectPathIds -> Cli ()
419
- setMostRecentProjectPath loc =
420
- runTransaction $ Codebase. setCurrentProjectPath loc
421
-
422
425
respond :: Output -> Cli ()
423
426
respond output = do
424
427
Env {notify} <- ask
0 commit comments