- where applyTextDocumentEdit (TextDocumentEdit docId (List edits)) = do
- oldVFS <- vfs <$> lift State.get
+ where checkIfNeedsOpened uri = do
+ oldVFS <- vfs <$> get
+ ctx <- ask
+
+ -- if its not open, open it
+ unless (uri `Map.member` oldVFS) $ do
+ let fp = fromJust $ uriToFilePath uri
+ contents <- liftIO $ T.readFile fp
+ let item = TextDocumentItem (filePathToUri fp) "" 0 contents
+ msg = NotificationMessage "2.0" TextDocumentDidOpen (DidOpenTextDocumentParams item)
+ liftIO $ B.hPut (serverIn ctx) $ addHeader (encode msg)
+
+ oldVFS <- vfs <$> get
+ newVFS <- liftIO $ openVFS oldVFS msg
+ modify (\s -> s { vfs = newVFS })
+
+ getParams (TextDocumentEdit docId (List edits)) =