intellij-arend icon indicating copy to clipboard operation
intellij-arend copied to clipboard

Bug: "Replace with constructor" removes code after hole

Open marat-rkh opened this issue 3 years ago • 2 comments

\open Nat (+)

\func example : Nat => {?} + {?}

Call "Replace with constructor" on the first hole, select "zero", press Enter.

Expected:

\func example : Nat => zero + {?}

Actual:

\func example : Nat => zero

As you can see, + {?} was removed, which is incorrect.

marat-rkh avatar Sep 06 '21 07:09 marat-rkh

It's a bug in BasePass. At line 195 we pass expr.textRange to replaceExprSmart, but that's incorrect since we need to compute the actual deleted range. I think this functionality was already implemented in https://github.com/JetBrains/intellij-arend/pull/281. So, we need to wait until it's merged.

valis avatar Sep 07 '21 20:09 valis

org.arend.util.ArendBinOpUtilsKt#getBounds might help with this issue.

marat-rkh avatar Feb 22 '22 16:02 marat-rkh