Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trace nodes do not nest correctly in the infoview #6389

Open
3 tasks done
eric-wieser opened this issue Dec 15, 2024 · 3 comments
Open
3 tasks done

Trace nodes do not nest correctly in the infoview #6389

eric-wieser opened this issue Dec 15, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@eric-wieser
Copy link
Contributor

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

Nested trace nodes are not indented correctly in the widget-based infoview.
They are fine on the command line

Context

This makes set_option trace.Meta.synthInstance true very hard to read the output of.

Zulip thread

Steps to Reproduce

Run

import Lean

#eval Lean.logInfo <|
  .trace { cls := `foo } m!"Foo" #[
    .trace { cls := `bar } m!"Bar 1" #[
      .trace { cls := `baz } m!"Baz" #[
        m!"Log message"
      ]
    ],
    .trace { cls := `bar } m!"Bar 2" #[
      m!"Log message"
    ]
  ]

Expected behavior: Trace nodes are properly nested, as they are on the command line / in #guard_msgs:

[foo] Foo
  [bar] Bar 1
    [baz] Baz
      Log message
  [bar] Bar 2
    Log message

Actual behavior: Infoview shows
image

Versions

4.15.0-rc1

Additional Information

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@eric-wieser eric-wieser added the bug Something isn't working label Dec 15, 2024
@eric-wieser
Copy link
Contributor Author

eric-wieser commented Dec 15, 2024

This (mostly) worked in Lean 4.8.0, where the infoview output is:

image

The bug appeared in 4.9.0.

(This also hopefully exonerates the vscode extension, since the latest extension works ok with old Lean 4.8.0)

@eric-wieser
Copy link
Contributor Author

I experimented with a patch along the lines of

--- a/src/Lean/Widget/InteractiveDiagnostic.lean
+++ b/src/Lean/Widget/InteractiveDiagnostic.lean
@@ -175,7 +175,9 @@ where
       else
         pure (.strict (← children.mapM (go nCtx ctx)))
     let e := .trace data.cls header data.collapsed nodes
-    return .tag (← pushEmbed e) default
+    -- Trace nodes occupy a full line in the widget view, so ensure the formatter considers them
+    -- as such.
+    return .nest 2 <| .tag (← pushEmbed e) "\n"

which ensures that the TaggedText actually populates the indent correctly; but then the infoview seems to insert extra newlines and indents.

@eric-wieser
Copy link
Contributor Author

As a workaround when using set_option trace.Meta.synthInstance true, you can use #guard_msgs to force the trace to be rendered as correctly-indented text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant