Skip to content

Trace nodes do not nest correctly in the infoview #6389

Closed

Description

@eric-wieser

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.

Activity

  1. added
    bug
    on Dec 15, 2024
  2. eric-wieser commented on Dec 15, 2024

    @eric-wieser
    ContributorAuthor

    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)

  3. eric-wieser commented on Dec 15, 2024

    @eric-wieser
    ContributorAuthor

    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.

  4. eric-wieser commented on Dec 23, 2024

    @eric-wieser
    ContributorAuthor

    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.

  5. added
    P-high
    on Jan 10, 2025
  6. added a commit that references this issue on Jan 13, 2025
    5f41cc7
  7. added a commit that references this issue on Jan 21, 2025
    15faf4e
  8. added a commit that references this issue on Jan 21, 2025
    fb66358
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P-highbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions