lean4-htt/tests/lean/run/5993.lean
Marc Huisinga f180eee7bf
feat: use widget message for "try this" (#9966)
This PR adjusts the "try this" widget to be rendered as a widget message
under 'Messages', not a separate widget under a 'Suggestions' section.
The main benefit of this is that the message of the widget is not
duplicated between 'Messages' and 'Suggestions'.

Since widget message suggestions were already implemented by @jrr6 for
the new hint infrastructure, this PR replaces the old "try this"
implementation with the new hint infrastructure. In doing so, the
`style?` field of suggestions is deprecated, since the hint
infrastructure highlights hints using diff colors, and `style?` also
never saw much use downstream. Additionally, since the message and the
suggestion are now the same component, the `messageData?` field of
suggestions is deprecated as well. Notably, the "Try this:" message
string now also contains a newline and indentation to separate the
suggestion from the rest of the message more clearly and the `postInfo?`
field of the suggestion is now part of the message.

Finally, this PR changes the diff colors used by the hint infrastructure
to be more color-blindness-friendly (insertions are now blue, not green,
and text that remains unchanged is now using the editor foreground color
instead of blue).

### Breaking changes
Tests that use `#guard_msgs` to test the "Try this:" message may need to
be adjusted for the new formatting of the message.
2025-08-26 12:15:32 +00:00

39 lines
953 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-!
# Avoid delaborating with field notation if object is a metavariable application.
https://github.com/leanprover/lean4/issues/5993
-/
set_option pp.mvars false
/-!
No field notation notation here. Used to print `refine ?_.succ` and `refine ?_.snd`.
-/
/--
info: Try this:
refine Nat.succ ?_
---
info: found a partial proof, but the corresponding tactic failed:
(expose_names; refine Prod.snd ?_)
It may be possible to correct this proof by adding type annotations, explicitly specifying implicit arguments, or eliminating unnecessary function abstractions.
-/
#guard_msgs in
example : Nat := by
show_term refine Nat.succ ?_
show_term refine Prod.snd (α := Int) ?_
exact default
/-!
No field notation even under binders. (That is, be aware of delayed assignment metavariables.)
-/
/--
info: Try this:
refine fun x => Nat.succ ?_
-/
#guard_msgs in
example : Nat → Nat := by
show_term refine fun _ => Nat.succ ?_
exact default