documentContents :: TextDocumentIdentifier -> Session T.Text
documentContents doc = do
vfs <- vfs <$> get
- let file = vfs Map.! toNormalizedUri (doc ^. uri)
+ let file = vfsMap vfs Map.! toNormalizedUri (doc ^. uri)
return $ Rope.toText $ Language.Haskell.LSP.VFS._text file
-- | Parses an ApplyEditRequest, checks that it is for the passed document
n :: DidOpenTextDocumentNotification
n = NotificationMessage "2.0" TextDocumentDidOpen params'
oldVFS <- vfs <$> get
- newVFS <- liftIO $ openVFS oldVFS n
+ let (newVFS,_) = openVFS oldVFS n
modify (\s -> s { vfs = newVFS })
sendMessage n
n :: DidCloseTextDocumentNotification
n = NotificationMessage "2.0" TextDocumentDidClose params'
oldVFS <- vfs <$> get
- newVFS <- liftIO $ closeVFS oldVFS n
+ let (newVFS,_) = closeVFS oldVFS n
modify (\s -> s { vfs = newVFS })
sendMessage n
n :: DidChangeTextDocumentNotification
n = NotificationMessage "2.0" TextDocumentDidChange params'
oldVFS <- vfs <$> get
- newVFS <- liftIO $ changeFromClientVFS oldVFS n
+ let (newVFS,_) = changeFromClientVFS oldVFS n
modify (\s -> s { vfs = newVFS })
sendMessage n
-- | Adds the current version to the document, as tracked by the session.
getVersionedDoc :: TextDocumentIdentifier -> Session VersionedTextDocumentIdentifier
getVersionedDoc (TextDocumentIdentifier uri) = do
- fs <- vfs <$> get
+ fs <- vfsMap . vfs <$> get
let ver =
case fs Map.!? toNormalizedUri uri of
- Just (VirtualFile v _ _) -> Just v
+ Just (VirtualFile v _) -> Just v
_ -> Nothing
return (VersionedTextDocumentIdentifier uri ver)
mainThreadId <- myThreadId
let context = SessionContext serverIn absRootDir messageChan reqMap initRsp config caps
- initState = SessionState (IdInt 0) mempty mempty 0 False Nothing
- runSession' = runSession context initState
+ initState vfs = SessionState (IdInt 0) vfs
+ mempty 0 False Nothing
+ runSession' ses = initVFS $ \vfs -> runSession context (initState vfs) ses
errorHandler = throwTo mainThreadId :: SessionException -> IO()
serverListenerLauncher =
forM_ bumpedVersions $ \(VersionedTextDocumentIdentifier uri v) ->
modify $ \s ->
let oldVFS = vfs s
- update (VirtualFile oldV t mf) = VirtualFile (fromMaybe oldV v) t mf
- newVFS = Map.adjust update (toNormalizedUri uri) oldVFS
+ update (VirtualFile oldV t) = VirtualFile (fromMaybe oldV v) t
+ newVFS = updateVFS (Map.adjust update (toNormalizedUri uri)) oldVFS
in s { vfs = newVFS }
where checkIfNeedsOpened uri = do
ctx <- ask
-- if its not open, open it
- unless (toNormalizedUri uri `Map.member` oldVFS) $ do
+ unless (toNormalizedUri uri `Map.member` (vfsMap oldVFS)) $ do
let fp = fromJust $ uriToFilePath uri
contents <- liftIO $ T.readFile fp
let item = TextDocumentItem (filePathToUri fp) "" 0 contents
liftIO $ B.hPut (serverIn ctx) $ addHeader (encode msg)
modifyM $ \s -> do
- newVFS <- liftIO $ openVFS (vfs s) msg
+ let (newVFS,_) = openVFS (vfs s) msg
return $ s { vfs = newVFS }
getParams (TextDocumentEdit docId (List edits)) =