This PR makes the server consistently not report newlines between trace nodes to the info view, enabling it to render them on dedicates lines without extraneous spacing between them in all circumstances. The info view code will separately need to be adjusted to this new behavior, until then this change will make adjacent trace node leafs consistently be rendered *on the same line* if there is sufficient space. The cmdline should be unaffected in any case.
62 lines
1.6 KiB
Text
62 lines
1.6 KiB
Text
import Lean.CoreM
|
|
|
|
/-!
|
|
Tests formatting of traces in various combinations, on the cmdline automatically via `#guard_msgs`
|
|
and in the info view via manual testing.
|
|
-/
|
|
|
|
open Lean
|
|
|
|
def withNode (cls : Name) (msg : MessageData) (k : CoreM Unit) (collapsed := true) (tag := "") : CoreM Unit := do
|
|
let oldTraces ← getTraces
|
|
modifyTraces fun _ => {}
|
|
k
|
|
let ref ← getRef
|
|
let mut data := { cls, collapsed, tag }
|
|
let msg := .trace data msg ((← getTraces).toArray.map (·.msg))
|
|
modifyTraces fun _ =>
|
|
oldTraces.push { ref, msg }
|
|
|
|
/--
|
|
info: [test] top-level leaf
|
|
[test] top-level leaf
|
|
[test] node with single leaf
|
|
[test] leaf
|
|
[test] node with adjacent leafs
|
|
[test] leaf
|
|
[test] leaf
|
|
[test] nested nodes
|
|
[test] leaf
|
|
[test] node
|
|
[test] leaf
|
|
[test] leaf
|
|
[test] uncollapsed node
|
|
[test] leaf
|
|
[test] node
|
|
[test] leaf
|
|
[test] leaf
|
|
[test] node with nested newline
|
|
[test] line1
|
|
line2
|
|
-/
|
|
#guard_msgs in
|
|
#eval show CoreM Unit from do
|
|
addTrace `test "top-level leaf"
|
|
addTrace `test "top-level leaf"
|
|
withNode `test "node with single leaf" do
|
|
addTrace `test "leaf"
|
|
withNode `test "node with adjacent leafs" do
|
|
addTrace `test "leaf"
|
|
addTrace `test "leaf"
|
|
withNode `test "nested nodes" do
|
|
addTrace `test "leaf"
|
|
withNode `test "node" do
|
|
addTrace `test "leaf"
|
|
addTrace `test "leaf"
|
|
withNode `test "uncollapsed node" (collapsed := false) do
|
|
addTrace `test "leaf"
|
|
withNode `test "node" do
|
|
addTrace `test "leaf"
|
|
addTrace `test "leaf"
|
|
withNode `test "node with nested newline" do
|
|
addTrace `test "line1\nline2"
|