diff --git a/src/Idris/REPL/Common.idr b/src/Idris/REPL/Common.idr index 712cabb63..f30078201 100644 --- a/src/Idris/REPL/Common.idr +++ b/src/Idris/REPL/Common.idr @@ -1,7 +1,8 @@ module Idris.REPL.Common -import Core.Env import Core.Context.Log +import Core.Directory +import Core.Env import Core.InitPrimitives import Core.Metadata import Core.Primitives @@ -80,9 +81,19 @@ emitProblem a replDocCreator idemodeDocCreator getFC -- TODO: Display a better message when the error doesn't contain a location case map toNonEmptyFC (getFC a) of Nothing => iputStrLn msg - Just (file, startPos, endPos) => + Just (origin, startPos, endPos) => do + fname <- case origin of + PhysicalIdrSrc ident => do + -- recover the file name relative to the working directory. + -- (This is what idris2-mode expects) + let fc = MkFC (PhysicalIdrSrc ident) startPos endPos + catch (nsToSource fc ident) (const $ pure "(File-Not-Found)") + PhysicalPkgSrc fname => + pure fname + Virtual Interactive => + pure "(Interactive)" send f (SExpList [SymbolAtom "warning", - SExpList [toSExp (show file), + SExpList [toSExp {a = String} fname, toSExp (addOne startPos), toSExp (addOne endPos), toSExp !(renderWithoutColor msg),