@@ -26,7 +26,6 @@ files in the client workspace by operating on the "VFS" in "LspFuncs".
26
26
module Language.LSP.VFS (
27
27
VFS (.. ),
28
28
vfsMap ,
29
- vfsTempDir ,
30
29
VirtualFile (.. ),
31
30
lsp_version ,
32
31
file_version ,
@@ -36,7 +35,7 @@ module Language.LSP.VFS (
36
35
VfsLog (.. ),
37
36
38
37
-- * Managing the VFS
39
- initVFS ,
38
+ emptyVFS ,
40
39
openVFS ,
41
40
changeFromClientVFS ,
42
41
changeFromServerVFS ,
@@ -92,7 +91,6 @@ import Language.LSP.Protocol.Types qualified as J
92
91
import System.Directory
93
92
import System.FilePath
94
93
import System.IO
95
- import System.IO.Temp
96
94
97
95
-- ---------------------------------------------------------------------
98
96
{-# ANN module ("hlint: ignore Eta reduce" :: String) #-}
@@ -113,8 +111,6 @@ data VirtualFile = VirtualFile
113
111
114
112
data VFS = VFS
115
113
{ _vfsMap :: ! (Map. Map J. NormalizedUri VirtualFile )
116
- , _vfsTempDir :: ! FilePath
117
- -- ^ This is where all the temporary files will be written to
118
114
}
119
115
deriving (Show )
120
116
@@ -152,8 +148,8 @@ virtualFileVersion vf = _lsp_version vf
152
148
153
149
---
154
150
155
- initVFS :: ( VFS -> IO r ) -> IO r
156
- initVFS k = withSystemTempDirectory " haskell-lsp " $ \ temp_dir -> k ( VFS mempty temp_dir)
151
+ emptyVFS :: VFS
152
+ emptyVFS = VFS mempty
157
153
158
154
-- ---------------------------------------------------------------------
159
155
@@ -311,13 +307,13 @@ virtualFileName prefix uri (VirtualFile _ file_ver _) =
311
307
in replicate (n - length numString) ' 0' ++ numString
312
308
in prefix </> basename ++ " -" ++ padLeft 5 file_ver ++ " -" ++ show (hash uri_raw) <.> takeExtensions basename
313
309
314
- -- | Write a virtual file to a temporary file if it exists in the VFS.
315
- persistFileVFS :: (MonadIO m ) => LogAction m (WithSeverity VfsLog ) -> VFS -> J. NormalizedUri -> Maybe (FilePath , m () )
316
- persistFileVFS logger vfs uri =
310
+ -- | Write a virtual file to a file in the given directory if it exists in the VFS.
311
+ persistFileVFS :: (MonadIO m ) => LogAction m (WithSeverity VfsLog ) -> FilePath -> VFS -> J. NormalizedUri -> Maybe (FilePath , m () )
312
+ persistFileVFS logger dir vfs uri =
317
313
case vfs ^. vfsMap . at uri of
318
314
Nothing -> Nothing
319
315
Just vf ->
320
- let tfn = virtualFileName (vfs ^. vfsTempDir) uri vf
316
+ let tfn = virtualFileName dir uri vf
321
317
action = do
322
318
exists <- liftIO $ doesFileExist tfn
323
319
unless exists $ do
0 commit comments