Skip to content

Commit beffb29

Browse files
committed
fix: remove the Indexing progress message when exeption in withHieDb
If any exception was happening in `withHieDb`, the `post` action was never called, leading to a stale `Indexing` message in the client. By using `bracket`, we ensure that the `post` message is called in the event of an exception, cleaning the confusing message in the client. It does not change the well behaving of the indexing (i.e. if it was crashing, it is still crashing), but at least user won't be confused by a stale `Indexing` message.
1 parent 1edb489 commit beffb29

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ghcide/src/Development/IDE/Core/Compile.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,9 +901,10 @@ indexHieFile se mod_summary srcPath !hash hf = do
901901
-- If the hash in the pending list doesn't match the current hash, then skip
902902
Just pendingHash -> pendingHash /= hash
903903
unless newerScheduled $ do
904-
pre optProgressStyle
905-
withHieDb (\db -> HieDb.addRefsFromLoaded db targetPath (HieDb.RealFile $ fromNormalizedFilePath srcPath) hash hf')
906-
post
904+
-- Using bracket, so even if an exception happen during withHieDb call,
905+
-- the `post` (which clean the progress indicator) will still be called.
906+
bracket_ (pre optProgressStyle) post $
907+
withHieDb (\db -> HieDb.addRefsFromLoaded db targetPath (HieDb.RealFile $ fromNormalizedFilePath srcPath) hash hf')
907908
where
908909
mod_location = ms_location mod_summary
909910
targetPath = Compat.ml_hie_file mod_location

0 commit comments

Comments
 (0)