Skip to content

Commit 0f0f918

Browse files
committed
Merge branch 'fix-stuck-at-exit' into add-core-plugin
2 parents 5a28bd8 + dc53035 commit 0f0f918

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,12 @@ setupLSP ::
128128
-> (FilePath -> IO FilePath) -- ^ Map root paths to the location of the hiedb for the project
129129
-> LSP.Handlers (ServerM config)
130130
-> (LSP.LanguageContextEnv config -> Maybe FilePath -> WithHieDb -> IndexQueue -> IO IdeState)
131+
-> Chan ReactorMessage
131132
-> MVar ()
132133
-> IO (LSP.LanguageContextEnv config -> TRequestMessage Method_Initialize -> IO (Either err (LSP.LanguageContextEnv config, IdeState)),
133134
LSP.Handlers (ServerM config),
134135
(LanguageContextEnv config, IdeState) -> ServerM config <~> IO)
135-
setupLSP recorder getHieDbLoc userHandlers getIdeState clientMsgVar = do
136-
-- Send everything over a channel, since you need to wait until after initialise before
137-
-- LspFuncs is available
138-
clientMsgChan :: Chan ReactorMessage <- newChan
136+
setupLSP recorder getHieDbLoc userHandlers getIdeState clientMsgChan clientMsgVar = do
139137

140138
-- An MVar to control the lifetime of the reactor loop.
141139
-- The loop will be stopped and resources freed when it's full

ghcide/src/Development/IDE/Main.hs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ module Development.IDE.Main
1111
,Log(..)
1212
) where
1313

14-
import Control.Concurrent.Extra (withNumCapabilities)
14+
import Control.Concurrent.Extra (Chan, newChan,
15+
withNumCapabilities,
16+
writeChan)
1517
import Control.Concurrent.MVar (newEmptyMVar,
1618
putMVar, tryReadMVar)
1719
import Control.Concurrent.STM.Stats (dumpSTMStats)
@@ -63,6 +65,7 @@ import Development.IDE.Graph (action)
6365
import Development.IDE.LSP.LanguageServer (runLanguageServer,
6466
setupLSP)
6567
import qualified Development.IDE.LSP.LanguageServer as LanguageServer
68+
import Development.IDE.LSP.Server
6669
import Development.IDE.Main.HeapStats (withHeapStats)
6770
import qualified Development.IDE.Main.HeapStats as HeapStats
6871
import qualified Development.IDE.Monitoring.EKG as EKG
@@ -356,19 +359,26 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
356359
putMVar ideStateVar ide
357360
pure ide
358361

359-
let setup = setupLSP (cmapWithPrio LogLanguageServer recorder) argsGetHieDbLoc (pluginHandlers plugins) getIdeState
362+
-- Send everything over a channel, since you need to wait until after initialise before
363+
-- LspFuncs is available
364+
clientMsgChan :: Chan ReactorMessage <- newChan
365+
366+
let setup = setupLSP (cmapWithPrio LogLanguageServer recorder) argsGetHieDbLoc (pluginHandlers plugins) getIdeState clientMsgChan
360367
-- See Note [Client configuration in Rules]
361368
onConfigChange cfg = do
362369
-- TODO: this is nuts, we're converting back to JSON just to get a fingerprint
363370
let cfgObj = J.toJSON cfg
364-
mide <- liftIO $ tryReadMVar ideStateVar
365-
case mide of
366-
Nothing -> pure ()
367-
Just ide -> liftIO $ do
368-
let msg = T.pack $ show cfg
369-
logDebug (Shake.ideLogger ide) $ "Configuration changed: " <> msg
370-
modifyClientSettings ide (const $ Just cfgObj)
371-
setSomethingModified Shake.VFSUnmodified ide [toKey Rules.GetClientSettings emptyFilePath] "config change"
371+
let configChangeIO = do
372+
mide <- liftIO $ tryReadMVar ideStateVar
373+
case mide of
374+
Nothing -> pure ()
375+
Just ide -> liftIO $ do
376+
let msg = T.pack $ show cfg
377+
logDebug (Shake.ideLogger ide) $ "Configuration changed: " <> msg
378+
modifyClientSettings ide (const $ Just cfgObj)
379+
setSomethingModified Shake.VFSUnmodified ide [toKey Rules.GetClientSettings emptyFilePath] "config change"
380+
liftIO $ writeChan clientMsgChan $ ReactorNotification configChangeIO
381+
372382

373383
runLanguageServer (cmapWithPrio LogLanguageServer recorder) options inH outH argsDefaultHlsConfig argsParseConfig onConfigChange setup
374384
dumpSTMStats

0 commit comments

Comments
 (0)