X-Git-Url: http://git.lukelau.me/?p=lsp-test.git;a=blobdiff_plain;f=src%2FLanguage%2FHaskell%2FLSP%2FTest.hs;h=60f13b1be25bdfe867e1d815fdb7668ae5a65630;hp=b648078b8c1fe14ece70330755867b25a6bb63c8;hb=776b8e1a475e2150797d432f0c13ccf685b1cd4b;hpb=35ce787a5458ffdce71923e40464448d6ea71801 diff --git a/src/Language/Haskell/LSP/Test.hs b/src/Language/Haskell/LSP/Test.hs index b648078..60f13b1 100644 --- a/src/Language/Haskell/LSP/Test.hs +++ b/src/Language/Haskell/LSP/Test.hs @@ -46,6 +46,7 @@ module Language.Haskell.LSP.Test , initializeResponse -- ** Documents , openDoc + , closeDoc , documentContents , getDocumentEdit , getDocUri @@ -308,6 +309,17 @@ openDoc file languageId = do 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