@@ -42,7 +42,6 @@ import Ide.Logger
4242import Language.LSP.Server (LanguageContextEnv ,
4343 LspServerLog ,
4444 type (<~> ))
45- import System.IO.Unsafe (unsafeInterleaveIO )
4645data Log
4746 = LogRegisteringIdeConfig ! IdeConfiguration
4847 | LogReactorThreadException ! SomeException
@@ -197,18 +196,10 @@ handleInit recorder getHieDbLoc getIdeState lifetime exitClientMsg clearReqId wa
197196 let root = LSP. resRootPath env
198197 dir <- maybe getCurrentDirectory return root
199198 dbLoc <- getHieDbLoc dir
200-
201- -- The database needs to be open for the duration of the reactor thread, but we need to pass in a reference
202- -- to 'getIdeState', so we use this dirty trick
203- dbMVar <- newEmptyMVar
204- ~ (WithHieDbShield withHieDb,hieChan) <- unsafeInterleaveIO $ takeMVar dbMVar
205-
206- ide <- getIdeState env root withHieDb hieChan
207-
208199 let initConfig = parseConfiguration params
209-
210200 logWith recorder Info $ LogRegisteringIdeConfig initConfig
211- registerIdeConfiguration (shakeExtras ide) initConfig
201+ dbMVar <- newEmptyMVar
202+
212203
213204 let handleServerException (Left e) = do
214205 logWith recorder Error $ LogReactorThreadException e
@@ -245,6 +236,10 @@ handleInit recorder getHieDbLoc getIdeState lifetime exitClientMsg clearReqId wa
245236 ReactorNotification act -> handle exceptionInHandler act
246237 ReactorRequest _id act k -> void $ async $ checkCancelled _id act k
247238 logWith recorder Info LogReactorThreadStopped
239+
240+ (WithHieDbShield withHieDb,hieChan) <- takeMVar dbMVar
241+ ide <- getIdeState env root withHieDb hieChan
242+ registerIdeConfiguration (shakeExtras ide) initConfig
248243 pure $ Right (env,ide)
249244
250245
0 commit comments