@@ -91,20 +91,24 @@ getFileExists fp = use_ GetFileExists fp
91
91
-- Provides a fast implementation if client supports dynamic watched files.
92
92
-- Creates a global state as a side effect in that case.
93
93
fileExistsRules :: IO LspId -> ClientCapabilities -> VFSHandle -> Rules ()
94
- fileExistsRules getLspId ClientCapabilities {_workspace} vfs
95
- | Just WorkspaceClientCapabilities {_didChangeWatchedFiles} <- _workspace
96
- , Just DidChangeWatchedFilesClientCapabilities {_dynamicRegistration} <- _didChangeWatchedFiles
97
- , Just True <- _dynamicRegistration
98
- = fileExistsRulesFast getLspId vfs
99
- | otherwise = do
100
- logger <- logger <$> getShakeExtrasRules
101
- liftIO $ logDebug logger " Warning: Client does not support watched files. Falling back to OS polling"
102
- fileExistsRulesSlow vfs
94
+ fileExistsRules getLspId ClientCapabilities {_workspace} vfs = do
95
+ -- Create the global always, although it should only be used if we have fast rules.
96
+ -- But there's a chance someone will send unexpected notifications anyway,
97
+ -- e.g. https://github.com/digital-asset/ghcide/issues/599
98
+ addIdeGlobal . FileExistsMapVar =<< liftIO (newVar [] )
99
+ case () of
100
+ _ | Just WorkspaceClientCapabilities {_didChangeWatchedFiles} <- _workspace
101
+ , Just DidChangeWatchedFilesClientCapabilities {_dynamicRegistration} <- _didChangeWatchedFiles
102
+ , Just True <- _dynamicRegistration
103
+ -> fileExistsRulesFast getLspId vfs
104
+ | otherwise -> do
105
+ logger <- logger <$> getShakeExtrasRules
106
+ liftIO $ logDebug logger " Warning: Client does not support watched files. Falling back to OS polling"
107
+ fileExistsRulesSlow vfs
103
108
104
109
-- Requires an lsp client that provides WatchedFiles notifications.
105
110
fileExistsRulesFast :: IO LspId -> VFSHandle -> Rules ()
106
- fileExistsRulesFast getLspId vfs = do
107
- addIdeGlobal . FileExistsMapVar =<< liftIO (newVar [] )
111
+ fileExistsRulesFast getLspId vfs =
108
112
defineEarlyCutoff $ \ GetFileExists file -> do
109
113
isWf <- isWorkspaceFile file
110
114
if isWf
0 commit comments