File tree 1 file changed +6
-1
lines changed
plugins/hls-cabal-plugin/src/Ide/Plugin
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -314,7 +314,9 @@ completion recorder ide _ complParams = do
314
314
mVf <- lift $ getVirtualFile $ toNormalizedUri uri
315
315
case (,) <$> mVf <*> uriToFilePath' uri of
316
316
Just (cnts, path) -> do
317
- mFields <- liftIO $ runIdeAction " cabal-plugin.fields" (shakeExtras ide) $ useWithStaleFast ParseCabalFields $ toNormalizedFilePath path
317
+ -- We decide on `useWithStale` here, since `useWithStaleFast` often leads to the wrong completions being suggested.
318
+ -- In case it fails, we still will get some completion results instead of an error.
319
+ mFields <- liftIO $ runAction " cabal-plugin.fields" ide $ useWithStale ParseCabalFields $ toNormalizedFilePath path
318
320
case mFields of
319
321
Nothing ->
320
322
pure . InR $ InR Null
@@ -335,6 +337,9 @@ completion recorder ide _ complParams = do
335
337
let completer = Completions. contextToCompleter ctx
336
338
let completerData = CompleterTypes. CompleterData
337
339
{ getLatestGPD = do
340
+ -- We decide on useWithStaleFast here, since we mostly care about the file's meta information,
341
+ -- thus, a quick response gives us the desired result most of the time.
342
+ -- The `withStale` option is very important here, since we often call this rule with invalid cabal files.
338
343
mGPD <- runIdeAction " cabal-plugin.modulesCompleter.gpd" (shakeExtras ide) $ useWithStaleFast ParseCabalFile $ toNormalizedFilePath fp
339
344
pure $ fmap fst mGPD
340
345
, cabalPrefixInfo = prefInfo
You can’t perform that action at this time.
0 commit comments