@@ -42,7 +42,6 @@ import Ide.Logger
42
42
import Language.LSP.Server (LanguageContextEnv ,
43
43
LspServerLog ,
44
44
type (<~> ))
45
- import System.IO.Unsafe (unsafeInterleaveIO )
46
45
data Log
47
46
= LogRegisteringIdeConfig ! IdeConfiguration
48
47
| LogReactorThreadException ! SomeException
@@ -197,18 +196,10 @@ handleInit recorder getHieDbLoc getIdeState lifetime exitClientMsg clearReqId wa
197
196
let root = LSP. resRootPath env
198
197
dir <- maybe getCurrentDirectory return root
199
198
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
-
208
199
let initConfig = parseConfiguration params
209
-
210
200
logWith recorder Info $ LogRegisteringIdeConfig initConfig
211
- registerIdeConfiguration (shakeExtras ide) initConfig
201
+ dbMVar <- newEmptyMVar
202
+
212
203
213
204
let handleServerException (Left e) = do
214
205
logWith recorder Error $ LogReactorThreadException e
@@ -245,6 +236,10 @@ handleInit recorder getHieDbLoc getIdeState lifetime exitClientMsg clearReqId wa
245
236
ReactorNotification act -> handle exceptionInHandler act
246
237
ReactorRequest _id act k -> void $ async $ checkCancelled _id act k
247
238
logWith recorder Info LogReactorThreadStopped
239
+
240
+ (WithHieDbShield withHieDb,hieChan) <- takeMVar dbMVar
241
+ ide <- getIdeState env root withHieDb hieChan
242
+ registerIdeConfiguration (shakeExtras ide) initConfig
248
243
pure $ Right (env,ide)
249
244
250
245
0 commit comments