Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add range check to highlightsFromCursor #187

Merged

Conversation

thecoolwinter
Copy link
Collaborator

Description

Fixes a bug found found by @cengelbart39 on discord where a parser would consume ranges already consumed by injected languages. This caused the injected ranges to be realized as plain text, when they should have been kept as their injected language's highlights.

This should have been avoided by the call to query.setRange(range) on line 43 in TreeSitterClient+Highlight.swift but it was found that for some reason in the case found by @cengelbart39 it just didn't work.

To fix, an additional check was added in highlightsFromCursor to only take any ranges that have indices in the intersection of it's range and the included range.

Related Issues

  • See discord link.

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

Before:

Screen_Recording_2023-05-04_at_11.00.00_AM.mov

After:

Screen.Recording.2023-05-07.at.2.04.46.PM.mov

@thecoolwinter
Copy link
Collaborator Author

The build error will be fixed when #186 is merged.

Copy link
Collaborator

@austincondiff austincondiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@thecoolwinter
Copy link
Collaborator Author

@austincondiff thanks! Just waiting for #186 to pin the STTextView version to fix the build error and this should be mergable.

@austincondiff austincondiff merged commit 521dd43 into CodeEditApp:main May 10, 2023
@thecoolwinter thecoolwinter deleted the fix/query-included-range branch July 12, 2023 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants