Skip to content

Commit 63de284

Browse files
committed
Add STM function to snapshot VFS
1 parent 404847a commit 63de284

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lsp/src/Language/LSP/Server.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ module Language.LSP.Server
3838
, persistVirtualFile
3939
, getVersionedTextDoc
4040
, reverseFileMap
41+
, snapshotVirtualFiles
4142

4243
-- * Diagnostics
4344
, publishDiagnostics

lsp/src/Language/LSP/Server/Core.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,13 @@ getVirtualFiles = vfsData <$> getsState resVFS
380380

381381
{-# INLINE getVirtualFiles #-}
382382

383+
-- | Take an atomic snapshot of the current state of the virtual file system.
384+
snapshotVirtualFiles :: LanguageContextEnv c -> STM VFS
385+
snapshotVirtualFiles env = vfsData <$> readTVar (resVFS $ resState env)
386+
387+
{-# INLINE snapshotVirtualFiles #-}
388+
389+
383390
-- | Dump the current text for a given VFS file to a temporary file,
384391
-- and return the path to the file.
385392
persistVirtualFile :: MonadLsp config m => NormalizedUri -> m (Maybe FilePath)

0 commit comments

Comments
 (0)