From: Luke Lau Date: Wed, 20 Jun 2018 17:00:06 +0000 (+0100) Subject: Close VFS when needed X-Git-Url: http://git.lukelau.me/?p=opengl.git;a=commitdiff_plain;h=ea5db1975df3a208798ce2c44dc71fb8123fabd3 Close VFS when needed --- diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index 48869b4..d3b1b65 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -219,6 +219,16 @@ sendNotification TextDocumentDidOpen params = do 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 () diff --git a/src/Language/Haskell/LSP/Test/Session.hs b/src/Language/Haskell/LSP/Test/Session.hs index db8bef5..9868b5c 100644 --- a/src/Language/Haskell/LSP/Test/Session.hs +++ b/src/Language/Haskell/LSP/Test/Session.hs @@ -130,6 +130,7 @@ processTextChanges (ReqApplyWorkspaceEdit r) = do 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