, initializeResponse
-- ** Documents
, openDoc
+ , closeDoc
, documentContents
, getDocumentEdit
, getDocUri
contents <- liftIO $ T.readFile fp
return $ TextDocumentItem (filePathToUri fp) (T.pack languageId) 0 contents
+-- | Closes a text document and sends a notification to the client.
+closeDoc :: TextDocumentIdentifier -> Session ()
+closeDoc docId = do
+ let params = DidCloseTextDocumentParams (TextDocumentIdentifier (docId ^. uri))
+ sendNotification TextDocumentDidClose params
+
+ oldVfs <- vfs <$> get
+ let notif = NotificationMessage "" TextDocumentDidClose params
+ newVfs <- liftIO $ closeVFS oldVfs notif
+ modify $ \s -> s { vfs = newVfs }
+
-- | Gets the Uri for the file corrected to the session directory.
getDocUri :: FilePath -> Session Uri
getDocUri file = do
formatRange doc (FormattingOptions 4 True) (Range (Position 1 10) (Position 2 10))
documentContents doc >>= liftIO . (`shouldNotBe` oldContents)
+ describe "closeDoc" $
+ it "works" $
+ let sesh =
+ runSession "hie --lsp" "test/data" $ do
+ doc <- openDoc "Format.hs" "haskell"
+ closeDoc doc
+ -- need to evaluate to throw
+ documentContents doc >>= liftIO . print
+ in sesh `shouldThrow` anyException
+
mkRange sl sc el ec = Range (Position sl sc) (Position el ec)
didChangeCaps :: ClientCapabilities