Skip to content

Commit c457699

Browse files
authored
Use stale data in explicit imports lens (#383)
This prevents the lenses from disappearing while editing, which causes lots of unpleasant jumping
1 parent 1d1ab3b commit c457699

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Ide/Plugin/ImportLens.hs

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import qualified Data.Map.Strict as Map
2525
import Data.Maybe (catMaybes, fromMaybe)
2626
import qualified Data.Text as T
2727
import Development.IDE
28+
import Development.IDE.Core.Shake (useWithStale)
2829
import Development.IDE.GHC.Compat
2930
import GHC.Generics (Generic)
3031
import Ide.Plugin
@@ -84,11 +85,11 @@ provider _lspFuncs -- LSP functions, not used
8485
| Just nfp <- uriToNormalizedFilePath $ toNormalizedUri _uri
8586
= do
8687
-- Get the typechecking artifacts from the module
87-
tmr <- runIde state $ use TypeCheck nfp
88+
tmr <- runIde state $ useWithStale TypeCheck nfp
8889
-- We also need a GHC session with all the dependencies
89-
hsc <- runIde state $ use GhcSessionDeps nfp
90+
hsc <- runIde state $ useWithStale GhcSessionDeps nfp
9091
-- Use the GHC api to extract the "minimal" imports
91-
(imports, mbMinImports) <- extractMinimalImports hsc tmr
92+
(imports, mbMinImports) <- extractMinimalImports (fst <$> hsc) ( fst <$> tmr)
9293

9394
case mbMinImports of
9495
-- Implement the provider logic:

0 commit comments

Comments
 (0)