@@ -195,7 +195,7 @@ data ShakeExtras = ShakeExtras
195
195
,state :: Values
196
196
,diagnostics :: Var DiagnosticStore
197
197
,hiddenDiagnostics :: Var DiagnosticStore
198
- ,publishedDiagnostics :: Var ( HMap. HashMap NormalizedUri [Diagnostic ])
198
+ ,publishedDiagnostics :: STM. Map NormalizedUri [Diagnostic ]
199
199
-- ^ This represents the set of diagnostics that we have published.
200
200
-- Due to debouncing not every change might get published.
201
201
,positionMapping :: Var (HMap. HashMap NormalizedUri (Map TextDocumentVersion (PositionDelta , PositionMapping )))
@@ -505,7 +505,7 @@ shakeOpen lspEnv defaultConfig logger debouncer
505
505
state <- STM. newIO
506
506
diagnostics <- newVar mempty
507
507
hiddenDiagnostics <- newVar mempty
508
- publishedDiagnostics <- newVar mempty
508
+ publishedDiagnostics <- STM. newIO
509
509
positionMapping <- newVar HMap. empty
510
510
knownTargetsVar <- newVar $ hashed HMap. empty
511
511
let restartShakeSession = shakeRestart ideState
@@ -1162,16 +1162,15 @@ updateFileDiagnostics fp k ShakeExtras{logger, diagnostics, hiddenDiagnostics, p
1162
1162
let uri = filePathToUri' fp
1163
1163
let delay = if null newDiags then 0.1 else 0
1164
1164
registerEvent debouncer delay uri $ do
1165
- join $ mask_ $ modifyVar publishedDiagnostics $ \ published -> do
1166
- let lastPublish = HMap. lookupDefault [] uri published
1167
- ! published' = HMap. insert uri newDiags published
1168
- action = when (lastPublish /= newDiags) $ case lspEnv of
1165
+ join $ mask_ $ do
1166
+ lastPublish <- atomically $ STM. focus (Focus. lookupWithDefault [] <* Focus. insert newDiags) uri publishedDiagnostics
1167
+ let action = when (lastPublish /= newDiags) $ case lspEnv of
1169
1168
Nothing -> -- Print an LSP event.
1170
1169
logInfo logger $ showDiagnosticsColored $ map (fp,ShowDiag ,) newDiags
1171
1170
Just env -> LSP. runLspT env $
1172
1171
LSP. sendNotification LSP. STextDocumentPublishDiagnostics $
1173
1172
LSP. PublishDiagnosticsParams (fromNormalizedUri uri) ver (List newDiags)
1174
- return (published', action)
1173
+ return action
1175
1174
1176
1175
newtype Priority = Priority Double
1177
1176
0 commit comments