File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
plugins/hls-cabal-plugin/src/Ide/Plugin Expand file tree Collapse file tree 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
314314 mVf <- lift $ getVirtualFile $ toNormalizedUri uri
315315 case (,) <$> mVf <*> uriToFilePath' uri of
316316 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
318320 case mFields of
319321 Nothing ->
320322 pure . InR $ InR Null
@@ -335,6 +337,9 @@ completion recorder ide _ complParams = do
335337 let completer = Completions. contextToCompleter ctx
336338 let completerData = CompleterTypes. CompleterData
337339 { 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.
338343 mGPD <- runIdeAction " cabal-plugin.modulesCompleter.gpd" (shakeExtras ide) $ useWithStaleFast ParseCabalFile $ toNormalizedFilePath fp
339344 pure $ fmap fst mGPD
340345 , cabalPrefixInfo = prefInfo
You can’t perform that action at this time.
0 commit comments