@@ -28,7 +28,8 @@ import Development.IDE (GhcSession (..),
2828 HscEnvEq (hscEnv ),
2929 RuleResult , Rules , define ,
3030 srcSpanToRange ,
31- usePropertyAction )
31+ usePropertyAction ,
32+ useWithStale )
3233import Development.IDE.Core.Compile (TcModuleResult (.. ))
3334import Development.IDE.Core.Rules (IdeState , runAction )
3435import Development.IDE.Core.RuleTypes (GetBindings (GetBindings ),
@@ -108,10 +109,12 @@ codeLensProvider ideState pId CodeLensParams{_textDocument = TextDocumentIdentif
108109 mode <- liftIO $ runAction " codeLens.config" ideState $ usePropertyAction # mode pId properties
109110 fmap (Right . List ) $ case uriToFilePath' uri of
110111 Just (toNormalizedFilePath' -> filePath) -> liftIO $ do
111- env <- fmap hscEnv <$> runAction " codeLens.GhcSession" ideState (use GhcSession filePath)
112- tmr <- runAction " codeLens.TypeCheck" ideState (use TypeCheck filePath)
113- bindings <- runAction " codeLens.GetBindings" ideState (use GetBindings filePath)
114- gblSigs <- runAction " codeLens.GetGlobalBindingTypeSigs" ideState (use GetGlobalBindingTypeSigs filePath)
112+ -- Using stale results means that we can almost always return a value. In practice
113+ -- this means the lenses don't 'flicker'
114+ env <- fmap (hscEnv . fst ) <$> runAction " codeLens.GhcSession" ideState (useWithStale GhcSession filePath)
115+ tmr <- fmap fst <$> runAction " codeLens.TypeCheck" ideState (useWithStale TypeCheck filePath)
116+ bindings <- fmap fst <$> runAction " codeLens.GetBindings" ideState (useWithStale GetBindings filePath)
117+ gblSigs <- fmap fst <$> runAction " codeLens.GetGlobalBindingTypeSigs" ideState (useWithStale GetGlobalBindingTypeSigs filePath)
115118
116119 diag <- atomically $ getDiagnostics ideState
117120 hDiag <- atomically $ getHiddenDiagnostics ideState
0 commit comments