CodeEditApp / CodeEditSourceEditor

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

Integrate TextFormation #135

Closed thecoolwinter closed 1 year ago

thecoolwinter commented 1 year ago

Description

This PR integrates the TextFormation library from the awesome @mattmassicotte and @ChimeHQ. It implements the necessary type conformances for STTextView, and adds the correct delegate methods in STTextViewController to handle edits.

Details:

Related Issues

Screenshots

Newlines:

https://user-images.githubusercontent.com/35942988/215297117-4eb68a67-9059-4022-bd6a-cd9f4ca1b437.mov

Bracket Pairs:

https://user-images.githubusercontent.com/35942988/215297139-42b61021-78b7-4426-8355-6dd95a21ef7b.mov

Tabulation:

https://user-images.githubusercontent.com/35942988/215297144-2d8502ec-e239-4632-8dde-03fd8ff20bdb.mov

^ It's not clear but when it only goes left by a couple characters I'm using my arrow keys not the delete button.

thecoolwinter commented 1 year ago

I'm not linking to #80 yet because that issue I think also covers the need to let users use a tab character. That's outside the scope of this PR though.

thecoolwinter commented 1 year ago

I'll wait for one more review before merging since this is a large change.

austincondiff commented 1 year ago

Way to go @thecoolwinter, great work! This makes CodeEdit feel so much more like what you would expect out of any editor.

mattmassicotte commented 1 year ago

@thecoolwinter wow awesome!

I'm very interested in investigating what's up with NewlineFilter. Almost sounds like a line endings issue.

matthijseikelenboom commented 1 year ago

@thecoolwinter Very nice work man! Only comment that I have is that the order of struct properties and functions is a bit all over the place.

thecoolwinter commented 1 year ago

@thecoolwinter wow awesome!

I'm very interested in investigating what's up with NewlineFilter. Almost sounds like a line endings issue.

Yes and I was going to open an issue on TextFormation. For some reason it's recognizing the beginning of the previous line as the end of the line, but only every other newline. I found that removing the line ending logic fixed it temporarily.

thecoolwinter commented 1 year ago

@thecoolwinter Very nice work man! Only comment that I have is that the order of struct properties and functions is a bit all over the place.

Yeah you're right. I can clean that up a little more real quick

mattmassicotte commented 1 year ago

Yes and I was going to open an issue on TextFormation. For some reason it's recognizing the beginning of the previous line as the end of the line, but only every other newline. I found that removing the line ending logic fixed it temporarily.

https://github.com/ChimeHQ/TextFormation/issues/4

mattmassicotte commented 1 year ago

Looks nice! 👍

Kudos also to @mattmassicotte for his work on the whole Chime suite 😉

I'm so glad you are finding all of this useful. Something that could be interesting is turning the STTextView + TextFormation integration itself into a package. Just food for thought.

We're working though the newline whitespace issue, and I think it's figured out, but not 100% sure.