leanprover / leanprover/lean4

Widgets not displaying on some terms

Open
#3,956 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-medium
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Description

In the following snippet, the widget should display on both lines, but it only displays on one of them.

import Lean.Widget.UserWidget
open Lean

@[widget_module]
def HelloWidget : Widget.Module where
  javascript := r#"
    import React from 'react'
    export default function() {
      return React.createElement('h2', {}, 'Hello world')
    }
  "#

syntax "foo" term : term
elab_rules : term
| `(term| foo%$stx $t) => do
  Widget.savePanelWidgetInfo HelloWidget.javascriptHash (return .null) stx
  Elab.Term.elabTerm t none

example : Nat := foo 1 -- widget
example : Nat := foo (by exact 1) -- no widget
Context

Reported by @eric-wieser on Zulip.

Steps to Reproduce
  1. Run the above snippet.

Expected behavior: The widget is displayed when placing the cursor on either line.

Actual behavior: It only shows up on the first one.

Versions

4.7.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the provided Lean 4.7.0 snippet first and compare widget behavior for foo 1 and foo (by exact 1). Start at the Widget.savePanelWidgetInfo call in the foo elaboration rule and determine why the widget is attached to only one term form; done means the widget displays when the cursor is placed on either example.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.