Skip to content

Commit f140a2a

Browse files
committed
refactor error handling in loadSessionWithOptions to improve clarity and logic
1 parent 21dd233 commit f140a2a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -782,16 +782,16 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
782782
-- what if the error to load file is one of old_files ?
783783
let attemptToLoadFiles = Set.delete cfp $ Set.fromList $ concatMap cradleErrorLoadingFiles err
784784
old_files <- readIORef (cradle_files sessionState)
785-
let errorToLoadNewFiles = attemptToLoadFiles `Set.difference` old_files
786-
if not (null errorToLoadNewFiles)
785+
let errorToLoadNewFiles = cfp : Set.toList (attemptToLoadFiles `Set.difference` old_files)
786+
if length errorToLoadNewFiles > 1
787787
then do
788788
-- we are loading more files and failed, we need to retry
789789
-- mark as less loaded files as failedLoadingFiles as possible
790790
-- limitation is that when we are loading files, and the dependencies of old_files
791791
-- are changed, and old_files are not valid anymore.
792792
-- but they will still be in the old_files, and will not move to error_loading_files.
793793
-- And make other files failed to load in batch mode.
794-
addErrorLoadingFiles sessionState (Set.toList errorToLoadNewFiles)
794+
addErrorLoadingFiles sessionState errorToLoadNewFiles
795795
-- retry without other files
796796
logWith recorder Info $ LogSessionReloadOnError cfp (Set.toList attemptToLoadFiles)
797797
consultCradle hieYaml cfp

0 commit comments

Comments
 (0)