CodeEditApp / CodeEditSourceEditor

A code editor view written in Swift powered by tree-sitter.
https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor
MIT License
504 stars 74 forks source link

🐞 Unexpected Undo behavior #203

Closed ryohajika closed 1 year ago

ryohajika commented 1 year ago

Description

When you edit text and undo changes you made, the undo(s) would be realized at some point but doesn't recover previous state and has some glitches in the text you didn't edit.

To Reproduce

  1. Open a file (.swift file in this case, and I realized the app doesn't support opening .xcodeproj file, which is not the point here though).
  2. Edit few lines like: Screenshot 2023-04-15 at 7 14 31 PM
  3. Perform Cmd+Z multiple times
  4. You get something like this: Screenshot 2023-04-15 at 7 14 52 PM

Expected Behavior

Bring back the previous state as it was originally.

Version Information

CodeEdit: 0.0.3-alpha-32 macOS: 13.3.1 (MBP "14 2021) Xcode: 14.3 (I did install the app from the released installer, not from source)

MrDevel0per commented 1 year ago

So the basic error here is that when you make changes that add newlines and then undo those changes with +Z, the newlines you created are not removed? Is that correct?

ryohajika commented 1 year ago

Hi @MrDevel0per ! This involves few errors: 1) although the lines/words you edit can be disappeared by Cmd+Z, newlines (blank lines) will still remain in the text, 2) while you perform multiple Cmd+Z, you see the editor modifies other lines randomly (like @main became @man, struct became strct in the screenshots I attached), 3) the cursor jumps around.

MrDevel0per commented 1 year ago

@ryohajika Got it - seems like there might be some errors with the CodeEditTextView's undo features. Good find!

ryohajika commented 1 year ago

Cool @MrDevel0per ! Let me know if there's anything I could help - apart from sending a PR on this 😂

thecoolwinter commented 1 year ago

I've got a fix for this ready. Waiting for a PR on STTextView to merge and this'll be fixed 👍