Close VFS when needed
authorLuke Lau <luke_lau@icloud.com>
Wed, 20 Jun 2018 17:00:06 +0000 (18:00 +0100)
committerLuke Lau <luke_lau@icloud.com>
Wed, 20 Jun 2018 17:00:06 +0000 (18:00 +0100)
src/Language/Haskell/LSP/Test.hs
src/Language/Haskell/LSP/Test/Session.hs

index 48869b4b4d640c81aa3d39adf87cb6356caee44a..d3b1b65e4c5a7b9c2e9e5190897852e87a2ec018 100644 (file)
@@ -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 ()
index db8bef5513e2c1e5dad7462d11ff52d400aaa21e..9868b5c029a6f7a6d823c3b2522fc604f5376049 100644 (file)
@@ -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