Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit e5e7009

Browse files
authored
Merge pull request #1 from wz1000/master
Fix issue with caching module
2 parents e69555d + 666cb86 commit e5e7009

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ hie-8.2.2:
1818
&& cp ~/.local/bin/hie-8.2.2 ~/.local/bin/hie-8.2
1919
.PHONY: hie-8.2.2
2020

21+
test:
22+
stack --stack-yaml=stack-8.0.2.yaml test \
23+
&& stack --stack-yaml=stack-8.2.1.yaml test \
24+
&& stack --stack-yaml=stack.yaml test
25+
.PHONY: test
26+
2127
build-copy-compiler-tool:
2228
stack --stack-yaml=stack-8.0.2.yaml build --copy-compiler-tool \
2329
&& stack --stack-yaml=stack-8.2.1.yaml build --copy-compiler-tool \

hie-plugin-api/Haskell/Ide/Engine/ModuleCache.hs

+15
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,21 @@ withCachedModuleAndData uri noCache callback = do
130130
cacheModule :: (Monad m, GM.MonadIO m, HasGhcModuleCache m)
131131
=> FilePath -> CachedModule -> m ()
132132
cacheModule uri cm = do
133+
uri' <- liftIO $ canonicalizePath uri
134+
modifyCache (\gmc ->
135+
gmc { uriCaches = Map.insert
136+
uri'
137+
(UriCache cm Map.empty)
138+
(uriCaches gmc)
139+
}
140+
)
141+
where
142+
143+
-- | Saves a module to the cache without clearing the associated cache data - use only if you are
144+
-- sure that the cached data associated with the module doesn't change
145+
cacheModuleNoClear :: (Monad m, GM.MonadIO m, HasGhcModuleCache m)
146+
=> FilePath -> CachedModule -> m ()
147+
cacheModuleNoClear uri cm = do
133148
uri' <- liftIO $ canonicalizePath uri
134149
modifyCache (\gmc ->
135150
gmc { uriCaches = Map.insertWith

src/Haskell/Ide/Engine/Transport/LspStdio.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ updatePositionMap uri changes = pluginGetFile "updatePositionMap: " uri $ \file
257257
(n2o' <=< newToOld r txt, oldToNew r txt <=< o2n')
258258
go _ _ = (const Nothing, const Nothing)
259259
let cm' = cm {newPosToOld = n2o, oldPosToNew = o2n}
260-
cacheModule file cm'
260+
cacheModuleNoClear file cm'
261261
return $ IdeResponseOk ()
262262
Nothing ->
263263
return $ IdeResponseOk ()

0 commit comments

Comments
 (0)