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

fix(python): properly highlight docstrings, f-strings, and escapes #724

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

egelja
Copy link
Contributor

@egelja egelja commented Aug 28, 2024

This fixes python highlighting for docstrings, f-strings, and escape sequences.

Before

image

After

image


Closes #169

@jcs090218
Copy link
Member

I'm a bit confused here. How does switching the LOC solve the issue? 🤔

@egelja
Copy link
Contributor Author

egelja commented Sep 2, 2024

I figured this out by trial and error, so I can't give you a definitive answer, but my guess is that rules earlier in the file are matched before rules later in the file, and the first rule that matches "wins". So by switching the lines, we're switching the order that rules are matched in.

I think the main issue was that the (string) @string rule was grabbing all strings, and so the specific docstring and f-string rules were never being matched. By moving that rule down, it first tries to match the docstring and f-string rules before falling back to generic (string) @string.

@jcs090218 jcs090218 merged commit 7007cbc into emacs-tree-sitter:master Sep 2, 2024
6 checks passed
@jcs090218
Copy link
Member

Thank you for your explanation! That makes sense! :)

@egelja egelja deleted the patch-1 branch September 2, 2024 18:03
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.

broken multiline string highlight in python
2 participants