CodeEditApp / CodeEditSourceEditor

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

Fix Undo/Redo, Bump Dependencies #204

Closed thecoolwinter closed 1 year ago

thecoolwinter commented 1 year ago

Description

Bumps both STTextView and TextFormation to their latest versions. This version of TextFormation changes how whitespaces are handled by filters, so there were some small modifications that needed to be made to accommodate. This also slightly adjusts the DeleteWhitespaceFilter to match other editor's functionality.

DeleteWhitespaceFilter now deletes only the leading whitespace, and only to the nearest column, instead of just a number of spaces. It will also jump to the rightmost side of the whitespace when deleting.

The other half of this PR is an implementation for undo/redo. This adds a CEUndoManager (with the prefix b/c AppKit declares that type) class that implements an undo/redo stack and operation grouping. It provides methods for performing undo/redo operations, registering text mutations from the editor, grouping operations, and clearing the undo stack. The class also automatically groups certain mutations. See the class documentation for more info there.

Related Issues

Checklist

Screenshots

https://github.com/CodeEditApp/CodeEditTextView/assets/35942988/35c64ed6-590d-493a-8f91-d918fef363a5