Skip to content

Commit 14eff93

Browse files
committed
cleanup dirty trick
1 parent b3476c2 commit 14eff93

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,18 +195,11 @@ 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
201198
dbMVar <- newEmptyMVar
202-
~(WithHieDbShield withHieDb,hieChan) <- unsafeInterleaveIO $ takeMVar dbMVar
203-
204-
ide <- getIdeState env root withHieDb hieChan
205199

206200
let initConfig = parseConfiguration params
207201

208202
logWith recorder Info $ LogRegisteringIdeConfig initConfig
209-
registerIdeConfiguration (shakeExtras ide) initConfig
210203

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

248245

0 commit comments

Comments
 (0)