Skip to content

RFC: try-this widget: multiple replacemens, alternative text in InfoView #4551

Open

Description

@nomeata

Proposal

Multiple edits

I would be able to address #4546 in maybe the most preferable way if the the “Try this” functionality would allow multiple simultaneous replacements. In that issue, termination_by? on a function that is part of a mutually recursive clique should really add an termination_by annotation to every function in the group at once.

Alternative text in widget

And while I am at it: in other applications the replacement text became very large (dozens of lines), and I would have preferred control over the link text to be able to say, for example ((and 10 more lines…)) or something else completely.

Replacement links in MessageData instead of Widgets

(This is more brainststormy, but maybe worth considering at some point.)

Maybe there is even a way to make embed a try-this link part of MessageData that I can embed such actions right in the the corresponding logInfo or throwError. This would avoid the user seeing a message (under “Messages”) and a separate redundant thing (or many, as with tactics like apply?) under the new header “Try this” in the info view. It would also avoid the need of functions like addSuggestions that produce a list, and users can format multiple suggestions in whatever they prefer.

Having such a .editAction : (edits : Array (Syntax × String)) (label : MessageData) → MessageData is also a bit more “semantics“ than a Widget with embedded TypeScript code, so hopefully makes it easier to be supported by other editors, or to write tools that perform such edits. (I expect at some point we need a batch tool that updates the #guard_msgs docstrings in our test suite.)

Impact

Add 👍 to issues you consider important. If others benefit from the changes in this proposal being added, please ask them to add 👍 to it.

Activity

  1. added
    RFC
    on Jun 24, 2024
  2. Vtec234 commented on Jul 7, 2024

    @Vtec234
    Member

    if the “Try this” functionality would allow multiple simultaneous replacements
    I would have preferred control over the link text to be able to say, for example ((and 10 more lines…)) or something else completely.

    These two look like unnecessary limitations of the "Try this" implementation that should be easy to fix. Specifically, Suggestion seems to assume that the text to insert is the same as what's shown in the widget, and that there is only one edit to make. Lsp.TextDocumentEdit already supports multiple edits, and ProofWidgets.MakeEditLink is a lower-level component that has neither limitation.

    Maybe there is even a way to make embed a try-this link part of MessageData ...

    This was exactly the motivation for RFC #2064, which is now implemented. We should follow-up by using it in "Try this".

    Having such a .editAction : (edits : Array (Syntax × String)) (label : MessageData) → MessageData is also a bit more “semantics“ than a Widget with embedded TypeScript code, so hopefully makes it easier to be supported by other editors

    This was also part of the discussion on #2064. In practice, it is easy enough for other editors and tools to parse the JSON input that's passed to the "Try this" widget and extract the edit(s) and related data from there.

  3. added
    P-low
    on Jul 26, 2024
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-lowRFC

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions