File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -350,15 +350,17 @@ def term.parenthesizer : CategoryParenthesizer | prec => do
350
350
maybeParenthesize `term true wrapParens prec $
351
351
parenthesizeCategoryCore `term prec
352
352
where
353
- /-- Wraps the term `stx` in parentheses and then copies its `SourceInfo` to the result.
354
- The purpose of this is to copy synthetic delaborator positions from the `stx` node to the parentheses node,
355
- which causes the info view to view both of these nodes as referring to the same expression.
356
- If we did not copy info, the info view would consider the parentheses to belong to the outer term.
353
+ /-- Wraps the term `stx` in parentheses and then moves its `SourceInfo` to the result.
354
+ The purpose of this is to move synthetic delaborator positions from the `stx` node to the parentheses node,
355
+ which causes the info view to view the node with parentheses as referring to the parenthesized expression.
356
+ If we did not move info, the info view would consider the parentheses to belong to the outer term.
357
357
Note: we do not do `withRef stx` because that causes the "(" and ")" tokens to have source info as well,
358
358
causing the info view to highlight each parenthesis as an independent expression. -/
359
359
wrapParens (stx : Syntax) : Syntax := Unhygienic.run do
360
+ let stxInfo := SourceInfo.fromRef stx
361
+ let stx := stx.setInfo .none
360
362
let pstx ← `(($(⟨stx⟩)))
361
- return pstx.raw.setInfo (SourceInfo.fromRef stx)
363
+ return pstx.raw.setInfo stxInfo
362
364
363
365
@[builtin_category_parenthesizer tactic]
364
366
def tactic.parenthesizer : CategoryParenthesizer | prec => do
You can’t perform that action at this time.
0 commit comments