Skip to content

Commit

Permalink
Revert "cleanup dirty trick"
Browse files Browse the repository at this point in the history
This reverts commit 14eff93.
  • Loading branch information
soulomoon committed Mar 26, 2024
1 parent 14eff93 commit abe68a1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ghcide/src/Development/IDE/LSP/LanguageServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,18 @@ handleInit recorder getHieDbLoc getIdeState lifetime exitClientMsg clearReqId wa
let root = LSP.resRootPath env
dir <- maybe getCurrentDirectory return root
dbLoc <- getHieDbLoc dir

-- The database needs to be open for the duration of the reactor thread, but we need to pass in a reference
-- to 'getIdeState', so we use this dirty trick
dbMVar <- newEmptyMVar
~(WithHieDbShield withHieDb,hieChan) <- unsafeInterleaveIO $ takeMVar dbMVar

ide <- getIdeState env root withHieDb hieChan

let initConfig = parseConfiguration params

logWith recorder Info $ LogRegisteringIdeConfig initConfig
registerIdeConfiguration (shakeExtras ide) initConfig

let handleServerException (Left e) = do
logWith recorder Error $ LogReactorThreadException e
Expand Down Expand Up @@ -236,10 +243,6 @@ handleInit recorder getHieDbLoc getIdeState lifetime exitClientMsg clearReqId wa
ReactorNotification act -> handle exceptionInHandler act
ReactorRequest _id act k -> void $ async $ checkCancelled _id act k
logWith recorder Info LogReactorThreadStopped

(WithHieDbShield withHieDb,hieChan) <- takeMVar dbMVar
ide <- getIdeState env root withHieDb hieChan
registerIdeConfiguration (shakeExtras ide) initConfig
pure $ Right (env,ide)


Expand Down

0 comments on commit abe68a1

Please sign in to comment.