modify (\s -> s { vfs = newVFS })
sendNotification' n
+-- | Close a virtual file if we send a close text document notification
+sendNotification TextDocumentDidClose params = do
+ let params' = fromJust $ decode $ encode params
+ n :: DidCloseTextDocumentNotification
+ n = NotificationMessage "2.0" TextDocumentDidClose params'
+ oldVFS <- vfs <$> get
+ newVFS <- liftIO $ closeVFS oldVFS n
+ modify (\s -> s { vfs = newVFS })
+ sendNotification' n
+
sendNotification method params = sendNotification' (NotificationMessage "2.0" method params)
sendNotification' :: (ToJSON a, ToJSON b) => NotificationMessage a b -> Session ()
let groupedParams = groupBy (\a b -> (a ^. textDocument == b ^. textDocument)) changeParams
mergedParams = map mergeParams groupedParams
+ -- TODO: Don't do this when replaying a session
forM_ mergedParams $ \p -> do
h <- serverIn <$> lift (lift Reader.ask)
let msg = NotificationMessage "2.0" TextDocumentDidChange p