jwoudenberg / elm-pair

An artificial pair-programmer that helps you write Elm
https://elm-pair.com
GNU General Public License v3.0
109 stars 0 forks source link

Renaming seems sensitive to typing speed #12

Closed Janiczek closed 2 years ago

Janiczek commented 2 years ago

Sometimes the renaming refactor stops in the middle in diffs like:

 setCohortsSorting : UX.SortableTable.Sorting -> BookModel a -> BookModel a
-setCohortsSorting groupsSorting bookModel =
+setCohortsSorting Sorting bookModel =
     update (\model -> { model | groupsSorting = groupsSorting }) bookModel

followed by

 setCohortsSorting : UX.SortableTable.Sorting -> BookModel a -> BookModel a
-setCohortsSorting Sorting bookModel =
+setCohortsSorting coSorting bookModel =
     update (\model -> { model | groupsSorting = Sorting }) bookModel

resulting in

setCohortsSorting : UX.SortableTable.Sorting -> BookModel a -> BookModel a
setCohortsSorting coSorting bookModel =
    update (\model -> { model | groupsSorting = cSorting }) bookModel

(note the cSorting in expr compared to the coSorting in the fn argument)

while if I write slowly letter by letter (` ->c->coetc., instead of ->co`), it's all fine. Seems like big changes all at once confuse elm-pair?

https://user-images.githubusercontent.com/149425/152877481-5dcfde4f-90bf-41d1-8af3-33a905aceec5.mp4

jwoudenberg commented 2 years ago

Thank you for the detailed report, as usual! I think there's probably some race condition at play here. I plan to give this a look tomorrow!

jwoudenberg commented 2 years ago

I introduced this bug in the fix for the undo logic introduced in https://github.com/jwoudenberg/elm-pair/issues/10. The undo detection logic would report false positives in the middle of a rename, causing Elm-pair to loose the thread. I made a fix that approaches undo's in a simpler way. Undo still seems to work, and Elm-pair doesn't hang up anymore, at least not when I'm ramming onto my keyboard as quickly as I can :).

The fix is out as release 10, let me know how it works for you! And thank you again for bringing the issue!

Janiczek commented 2 years ago

Seems to work much better! Thank you @jwoudenberg :heart: