@@ -28,7 +28,8 @@ import Development.IDE (GhcSession (..),
28
28
HscEnvEq (hscEnv ),
29
29
RuleResult , Rules , define ,
30
30
srcSpanToRange ,
31
- usePropertyAction )
31
+ usePropertyAction ,
32
+ useWithStale )
32
33
import Development.IDE.Core.Compile (TcModuleResult (.. ))
33
34
import Development.IDE.Core.Rules (IdeState , runAction )
34
35
import Development.IDE.Core.RuleTypes (GetBindings (GetBindings ),
@@ -108,10 +109,12 @@ codeLensProvider ideState pId CodeLensParams{_textDocument = TextDocumentIdentif
108
109
mode <- liftIO $ runAction " codeLens.config" ideState $ usePropertyAction # mode pId properties
109
110
fmap (Right . List ) $ case uriToFilePath' uri of
110
111
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)
115
118
116
119
diag <- atomically $ getDiagnostics ideState
117
120
hDiag <- atomically $ getHiddenDiagnostics ideState
0 commit comments