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

Closed
3 tasks done
eric-wieser opened this issue Dec 15, 2024 · 3 comments · Fixed by #6597
Closed
3 tasks done

Trace nodes do not nest correctly in the infoview #6389

eric-wieser opened this issue Dec 15, 2024 · 3 comments · Fixed by #6597
Labels
bug Something isn't working P-high We will work on this issue

Comments

@eric-wieser
Copy link
Contributor

eric-wieser commented Dec 15, 2024

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
[baz] is incorrectly nested, and everything beneath it would also truncate to a two-space indent, no matter how deeply nested.

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.

@leanprover-bot leanprover-bot added the P-high We will work on this issue label Jan 10, 2025
github-merge-queue bot pushed a commit that referenced this issue Jan 13, 2025
This PR fixes the indentation of nested traces nodes in the info view.


![image](https://github.com/user-attachments/assets/c13ac2a2-e994-4900-9201-0d86889f6a1b)

Fixes #6389
@Kha Kha closed this as completed in #6597 Jan 13, 2025
luisacicolini pushed a commit to opencompl/lean4 that referenced this issue Jan 21, 2025
JovanGerb pushed a commit to JovanGerb/lean4 that referenced this issue Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-high We will work on this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants