Skip to content

Commit 1027229

Browse files
committed
Check that hiedb source files exist
1 parent ef19f2c commit 1027229

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

ghcide/src/Development/IDE/Spans/AtPoint.hs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,19 @@ defRowToLocation lookupModule (row:.info) = do
389389
let start = Position (fromIntegral $ defSLine row - 1) (fromIntegral $ defSCol row - 1)
390390
end = Position (fromIntegral $ defELine row - 1) (fromIntegral $ defECol row - 1)
391391
range = Range start end
392+
lookupMod = lookupModule (defSrc row) (modInfoName info) (modInfoUnit info) (modInfoIsBoot info)
392393
file <- case modInfoSrcFile info of
393-
Just src -> pure $ toUri src
394-
Nothing -> lookupModule (defSrc row) (modInfoName info) (modInfoUnit info) (modInfoIsBoot info)
394+
Just src -> do
395+
-- Checking that the file exists covers the case where a
396+
-- dependency file in .hls is in the database but got deleted
397+
-- for any reason.
398+
-- See the function `lookupMod` in Development.IDE.Core.Actions
399+
-- for where dependency files get created and indexed in hiedb.
400+
fileExists <- liftIO $ doesFileExist src
401+
if fileExists
402+
then pure $ toUri src
403+
else lookupMod
404+
Nothing -> lookupMod
395405
pure $ Location file range
396406

397407
toUri :: FilePath -> Uri

0 commit comments

Comments
 (0)