From ea5db1975df3a208798ce2c44dc71fb8123fabd3 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Wed, 20 Jun 2018 18:00:06 +0100 Subject: [PATCH] Close VFS when needed --- src/Language/Haskell/LSP/Test.hs | 10 ++++++++++ src/Language/Haskell/LSP/Test/Session.hs | 1 + 2 files changed, 11 insertions(+) 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 -- 2.30.2