From 9512683e968b893f04a1d35bf84b2e99972b333e Mon Sep 17 00:00:00 2001 From: Ruslan Feizerakhmanov Date: Thu, 10 Jun 2021 12:49:31 +0300 Subject: [PATCH] Recover the original way of sending file contexts to idemode clients --- src/Idris/REPL/Common.idr | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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),