@@ -826,7 +826,7 @@ data DiagInfo = DiagInfo {
826826 diagRange :: Maybe J. Range ,
827827 diagMsg :: String ,
828828 searchToken :: Maybe String -- ^ A token to search for to replace range
829- }
829+ } deriving Show
830830 -- WarnInfo (Maybe J.Range) (String, Maybe String)
831831 -- | ErrInfo J.Range String
832832
@@ -840,9 +840,18 @@ handleWarnings logger nuriCurrent parsedWarnings errorDiags = do
840840 let srcName = mkSrcName rootPath nuriCurrent
841841 let diagsWithFiles = [(Just filename, DiagInfo J. DsWarning rng msg pat) | (filename, rng, (msg, pat)) <- parsedWarnings ]
842842 -- Error diagnostics first to ensure they are included
843- forM_ (groupByFst $ errorDiags ++ diagsWithFiles) $
843+
844+ -- Merge the items with unknown location first
845+ canonicallyPathedDiags <- forM (groupByFst $ errorDiags ++ diagsWithFiles) $
844846 \ (relFile, diagInfo) -> do
847+ debugM logger " diagnostics for file" $ show relFile ++ " : " ++ show diagInfo
845848 nuri' <- liftIO $ maybe (pure nuriCurrent) (fmap toNuri . canonicalizePath) relFile
849+ debugM logger " canonical" $ show nuri'
850+ pure (nuri', diagInfo)
851+ -- Now, for each normailized uri:
852+ forM_ (groupByFst canonicallyPathedDiags) $
853+ \ (nuri', diagInfo') -> do
854+ let diagInfo = concat diagInfo'
846855 --
847856 mdoc <- getVirtualFile nuri'
848857 fileText <- case mdoc of
@@ -851,7 +860,7 @@ handleWarnings logger nuriCurrent parsedWarnings errorDiags = do
851860 debugM logger " foo" $ " Found file: " ++ take 100 (show fileText) ++ " ..."
852861 pure $ Just $ T. unpack fileText -- TODO: Make this more efficient
853862 Nothing -> do
854- debugM logger " foo" $ " Couldn't find file: " ++ show relFile
863+ debugM logger " foo" $ " Couldn't find file: " ++ show nuri'
855864 pure Nothing
856865 let diags = [diagFor srcName sev (guessRange rng ident fileText) msg | DiagInfo sev rng msg ident <- diagInfo]
857866 -- publishDiagnostics 100 nuri' Nothing (partitionBySource diags)
0 commit comments