You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Select the {"a" "1" "b" "2"} map and do the Introduce Variable (Ctrl+Alt+V) refactoring for both functions. In the good function the variable is created without problems, but in the bad function it produces broken code.
There are other longstanding bugs like this related to Parinfer and refactoring, for example #2106.
I think Cursive should do something like this behind the scenes to avoid breaking code: when any refactoring is triggered, (1) disable Parinfer, (2) do the code changes, (3) fix the indentation, (4) enable Parinfer.
Thanks for the excellent reproduction case. I'm looking at this now.
FWIW, Cursive does actually do what you suggest. However, there's something about the sequence of changes which Parinfer sees due to the second refactoring which is different, and the bug is actually in the parinfer algorithm. It's tricky to completely reliably disable Parinfer in the case of inline refactorings like this one though, since there are various steps to the refactoring and it's not completely modal (i.e. the user could conceivably do something in another editor in the middle of the inline refactor which might affect it). I'm still trying to figure it out.
So your comment prompted me to revisit how this works, and I re-worked the disabling infrastructure to be more robust. This case now works correctly, and I'm hopeful some others will do too. Thanks for the nudge in that direction!
Given Parinfer is enabled and we have the following code. (The only difference between the functions is a longer name in
:aaa
vs:aaaa
.)Select the
{"a" "1" "b" "2"}
map and do the Introduce Variable (Ctrl+Alt+V) refactoring for both functions. In thegood
function the variable is created without problems, but in thebad
function it produces broken code.The resulting code:
Demonstration:
cursive.formatting.bug.mp4
IntelliJ IDEA 2023.1
Cursive plugin 1.12.8-2023.1
The text was updated successfully, but these errors were encountered: