Skip to content

Commit abe68a1

Browse files
committed
Revert "cleanup dirty trick"
This reverts commit 14eff93.
1 parent 14eff93 commit abe68a1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

ghcide/src/Development/IDE/LSP/LanguageServer.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,18 @@ handleInit recorder getHieDbLoc getIdeState lifetime exitClientMsg clearReqId wa
195195
let root = LSP.resRootPath env
196196
dir <- maybe getCurrentDirectory return root
197197
dbLoc <- getHieDbLoc dir
198+
199+
-- The database needs to be open for the duration of the reactor thread, but we need to pass in a reference
200+
-- to 'getIdeState', so we use this dirty trick
198201
dbMVar <- newEmptyMVar
202+
~(WithHieDbShield withHieDb,hieChan) <- unsafeInterleaveIO $ takeMVar dbMVar
203+
204+
ide <- getIdeState env root withHieDb hieChan
199205

200206
let initConfig = parseConfiguration params
201207

202208
logWith recorder Info $ LogRegisteringIdeConfig initConfig
209+
registerIdeConfiguration (shakeExtras ide) initConfig
203210

204211
let handleServerException (Left e) = do
205212
logWith recorder Error $ LogReactorThreadException e
@@ -236,10 +243,6 @@ handleInit recorder getHieDbLoc getIdeState lifetime exitClientMsg clearReqId wa
236243
ReactorNotification act -> handle exceptionInHandler act
237244
ReactorRequest _id act k -> void $ async $ checkCancelled _id act k
238245
logWith recorder Info LogReactorThreadStopped
239-
240-
(WithHieDbShield withHieDb,hieChan) <- takeMVar dbMVar
241-
ide <- getIdeState env root withHieDb hieChan
242-
registerIdeConfiguration (shakeExtras ide) initConfig
243246
pure $ Right (env,ide)
244247

245248

0 commit comments

Comments
 (0)