Recover the original way of sending file contexts to idemode clients

This commit is contained in:
Ruslan Feizerakhmanov 2021-06-10 12:49:31 +03:00
parent f0af11ac7e
commit 9512683e96

View File

@ -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),