CodeEditApp / CodeEditSourceEditor

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

Fix Ambiguous Highlights #275

Closed thecoolwinter closed 1 week ago

thecoolwinter commented 1 week ago

Description

Fixes some bad syntax highlighting caused by overlapping captures returned from tree-sitter. Previously the last value returned took precedence, but with the new highlighting system that's not the case. This filters highlights on duplicate ranges, and prioritizes the best capture for any range so this is no longer dependent on the highlighting system's semantics.

Related Issues

Checklist

Screenshots

Disambiguated highlights:

Screenshot 2024-11-17 at 2 50 28 PM

Ambiguous highlights:

Screenshot 2024-11-17 at 2 52 04 PM

thecoolwinter commented 1 week ago

Nice work, and very well documented! I found a few potential issues. Let me know your thoughts.

@austincondiff most of these changes are from #273 so I think we need to wait to review this until that is merged so the actual changes are visible here. Sorry I made it convoluted. The things you commented on are from that PR

tom-ludwig commented 1 week ago

Would it be better to set the #273 branch as the target and merge into it instead?

thecoolwinter commented 1 week ago

I think actually I'll just remake this PR entirely once #273 is merged. I'd rather not muck up that PR anymore since it's so large. Leaving this open and as a draft for now just to bookmark it.

thecoolwinter commented 1 week ago

Okay the changes shown here now reflect the actual diff. I'm not too worried about the messy commit history since we squash PRs anyways. Ready for review now!