-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: filter duplicate subexpressions #4786
fix: filter duplicate subexpressions #4786
Conversation
Mathlib CI status (docs):
|
One question before thinking about the details of filtering: why do this here rather than somewhere earlier? Perhaps it should be viewed a bug in the delaborator or somewhere in the pretty-printer that it produces both of these rather than just one? |
Here's where the parenthesizer adds parentheses and copies source position from the syntax being parenthesized: https://github.com/leanprover/lean4/blob/master/src/Lean/PrettyPrinter/Parenthesizer.lean#L353-L361 The reason it doesn't delete source position from the syntax is because it's using On the other hand, the filtering approach in the PR might be a way to address that comment in the linked code about why it doesn't use withRef — this PR would keep each parenthesis from being individually hoverable, right? |
This reverts commit 5e47f96.
Hovering over the parenthesis will highlight the parentheses and the term inside of it. Hovering on the head of the term inside of it will also highlight the parentheses, whereas before it would only highlight the term, not the parentheses. |
I believe something like the following would also accomplish the same thing as this PR if I am not mistaken:
What do you think? |
@mhuisi I think that's an improvement to I'd say that if this change to the parenthesizer appears to work, let's go for it. |
32d60c5
to
696f70b
Compare
(Kyle signed this off in a PM) |
For every parenthesized expression
(foo)
, the InfoView produces an interactive component both for(foo)
itself and its subexpressionfoo
because the correspondingTaggedText
in the language server is duplicated as well. Both of these subexpressions have the same subexpression position and so they are identical w.r.t. interactive features.Removing this duplication would help reduce the size of the DOM of the InfoView and ensure that the UI for InfoView features is consistent for
(foo)
andfoo
(e.g. hovers would always highlight(foo)
, not either(foo)
orfoo
depending on whether the mouse cursor is on the bracket or not). It would also help resolve a bug where selecting a subexpression will yield selection highlighting both for(foo)
andfoo
, as we use the subexpression position to identify which terms to highlight.This PR adjusts the parenthesizer to move the corresponding info instead of duplicating it.