Skip to content

Fix python colon in strings#2193

Open
1ul1 wants to merge 2 commits into
lite-xl:masterfrom
1ul1:fix-python-colon-in-strings
Open

Fix python colon in strings#2193
1ul1 wants to merge 2 commits into
lite-xl:masterfrom
1ul1:fix-python-colon-in-strings

Conversation

@1ul1

@1ul1 1ul1 commented Dec 15, 2025

Copy link
Copy Markdown

The original Python syntax relied on block-header rules that terminated at the first colon, which broke highlighting when colons appeared inside strings.
After removing those patterns, a top-level type-annotation rule incorrectly treated block colons as type contexts, breaking keyword/function highlighting.
I removed these, and everything works as expected, except type hints which are treated as normal text. But this is the case even with the original plugin (line 41 in the photo), which only treated them correctly when inside blocks (line 43).
Additionally, removing these lines fixes another problem: print() and returns were colored weirdly (either as functions or as variables with no reason (lines 56 & 58).

I attached a picture that shows the results:

  • left side: Original plugin Lite-xl
  • middle: VsCode
  • right side: Plugin with those patterns removed Lite-xl
comparison

Thanks for looking over this!

Fixes #2190

1ul1 and others added 2 commits December 15, 2025 19:05
- Remove fragile one-liner patterns that scan to <<:>> and can terminate inside strings, causing the rest of the file to be registered as an unterminated string.
- Add a targeted pattern for catching comments <<#>> after <<:>>.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Syntax highlighting breaks when an if condition contains a comparison to ':'

1 participant