Repository navigation
Conversation
PR summary a0c68dba51Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
joneugster
left a comment
There was a problem hiding this comment.
Thanks! Seems to work nicely.
maintainer merge
| - Otherwise, for example if the cursor is after a `by` or a `=>`, | ||
| simply insert it at the cursor position. | ||
|
|
||
| TODO: we might want to add support for inserting in the middle of a `rw [...]` sequence. |
There was a problem hiding this comment.
(review note) this isn't currently supported either, it inserts rw[..., rw[suggested_lemma], ...], so this is just documenting an existing issue and is not a regression.
There was a problem hiding this comment.
I've observed a bug where the text was something like
lemma ...
... := by
induction ...
and click-suggestion wrote
lemma ...
... := by
rw [...]induction ...
without a new line, but I am unable to reproduce this again...
There was a problem hiding this comment.
since I can't reproduce this, I'm happy to ignore it :)
There was a problem hiding this comment.
Could it be this?
module
public import Mathlib.Tactic.ClickSuggestions
public import ProofWidgets.Component.HtmlDisplay
#click_suggestions
example (n : Nat) : n + 0 = n := by
induction n <;> simpThen put the cursor at the start of the line with induction n <;> simp.
Now, Shift-click n + 0 and click any(?) suggestion, such as rw [add_zero] to get to
example (n : Nat) : n + 0 = n := by
rw [Nat.add_zero] induction n <;> simpThere was a problem hiding this comment.
Indeed, when the cursor is before the first tactic in a by block (or if there is no tactic in the by block yet) then the syntax associated to that position is the by token itself, which means that the syntax doesn't allow us to determine the correct alignment with the other tactics.
In that scenario, we simply do the insertion at the cursor position, which indeed can be wrong.
There was a problem hiding this comment.
This behaviour is also visible in the tests. I should add a comment there pointing this out.
|
🚀 Pull request has been placed on the maintainer queue by joneugster. |
This PR makes
#click_suggestionsinsert its suggestions in the correct place, even if the cursor is not in the place where the tactic should go.In particular, if the cursor is placed after a tactic, or at the start of a tactic, then the position of the insertion is made to align with that tactic syntax, instead of using the cursor position.
What is more difficult is to determine the appropriate indentation level after a loose
by. So, the user still needs to manually add the newline after abybefore using#click_suggestions. This might be improved in a future PR.This PR adds a test file that tests the insertion behaviour. In addition to testing the new behaviour, we also tests some other behaviours that weren't previously tested.