Skip to content

Commit 79a43a0

Browse files
committed
extract attempt to load files from errors
1 parent 4c998bd commit 79a43a0

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

cabal.project

+5
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,8 @@ constraints:
4646
if impl(ghc >= 9.9)
4747
-- https://github.com/haskell/haskell-language-server/issues/4324
4848
benchmarks: False
49+
50+
source-repository-package
51+
type: git
52+
location: https://github.com/soulomoon/hie-bios.git
53+
tag: 93582c21372af573e5103bad198777a3317a2df2

ghcide/session-loader/Development/IDE/Session.hs

+5-3
Original file line numberDiff line numberDiff line change
@@ -680,17 +680,19 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
680680
return (([renderPackageSetupException cfp GhcVersionMismatch{..}], Nothing),Map.empty)
681681
-- Failure case, either a cradle error or the none cradle
682682
Left err -> do
683-
if (not $ null extraToLoads)
683+
let attemptToLoadFiles = (Set.delete cfp $ Set.fromList $ concatMap cradleErrorLoadingFiles err)
684+
`Set.difference` old_files
685+
if (not $ null attemptToLoadFiles)
684686
then do
685687
-- mark as less loaded files as failedLoadingFiles as possible
686688
-- limitation is that when we are loading files, and the dependencies of old_files
687689
-- are changed, and old_files are not valid anymore.
688690
-- but they will still be in the old_files, and will not move to error_loading_files.
689691
-- And make other files failed to load in batch mode.
690-
let failedLoadingFiles = (Set.insert cfp extraToLoads) `Set.difference` old_files
692+
let failedLoadingFiles = (Set.insert cfp attemptToLoadFiles)
691693
atomicModifyIORef' error_loading_files (\xs -> (failedLoadingFiles <> xs,()))
692694
-- retry without other files
693-
logWith recorder Info $ LogSessionReloadOnError cfp (Set.toList pendingFiles)
695+
logWith recorder Info $ LogSessionReloadOnError cfp (Set.toList attemptToLoadFiles)
694696
consultCradle hieYaml cfp
695697
else do
696698
dep_info <- getDependencyInfo ((maybeToList hieYaml) ++ concatMap cradleErrorDependencies err)

ghcide/session-loader/Development/IDE/Session/Diagnostics.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ data CradleErrorDetails =
2727
Depicts the cradle error in a user-friendly way.
2828
-}
2929
renderCradleError :: CradleError -> Cradle a -> NormalizedFilePath -> FileDiagnostic
30-
renderCradleError (CradleError deps _ec ms) cradle nfp
30+
renderCradleError (CradleError deps _ec ms _attemptToLoadFiles) cradle nfp
3131
| HieBios.isCabalCradle cradle =
3232
let (fp, showDiag, diag) = ideErrorWithSource (Just "cradle") (Just DiagnosticSeverity_Error) nfp $ T.unlines $ map T.pack userFriendlyMessage in
3333
(fp, showDiag, diag{_data_ = Just $ Aeson.toJSON CradleErrorDetails{cabalProjectFiles=absDeps}})

0 commit comments

Comments
 (0)