fix: isolate std streams for all commands in server mode

Fixes #475
This commit is contained in:
Sebastian Ullrich 2021-05-19 13:30:54 +02:00
parent 7c3101a51c
commit cd5dbc66ce
3 changed files with 21 additions and 5 deletions

View file

@ -103,11 +103,22 @@ def compileNextCmd (contents : String) (snap : Snapshot) : IO (Sum Snapshot Mess
fileName := inputCtx.fileName
fileMap := inputCtx.fileMap
}
EIO.toIO ioErrorFromEmpty $
Elab.Command.catchExceptions
(Elab.Command.elabCommand cmdStx)
cmdCtx cmdStateRef
let postCmdState ← cmdStateRef.get
let (output, _) ← IO.FS.withIsolatedStreams do
EIO.toIO ioErrorFromEmpty do
Elab.Command.catchExceptions
(Elab.Command.elabCommand cmdStx)
cmdCtx cmdStateRef
let mut postCmdState ← cmdStateRef.get
if !output.isEmpty then
postCmdState := {
postCmdState with
messages := postCmdState.messages.add {
fileName := inputCtx.fileName
severity := MessageSeverity.information
pos := inputCtx.fileMap.toPosition snap.endPos
data := output
}
}
let postCmdSnap : Snapshot := {
beginPos := cmdPos
stx := cmdStx

View file

@ -0,0 +1,5 @@
import Lean
elab "foo" : command => IO.println "hi"
#eval "ho"
foo