porcupine
porcupine copied to clipboard
Syntax highlighter: single-character optimization
https://github.com/Akuli/porcupine/blob/df7919c8f85a54db796ff39c404f1351b59ff039/porcupine/plugins/highlight.py#L150-L158
Here change.end
is the old end (see #1118) and [0]
finds the line number from a [line, column]
pair.
I don't think this works as intended when you press enter:
- There is exactly one
change
, whosestart
andend
are both at the end of the previous line. - The range to highlight becomes from start to end of that line, excluding the newly typed newline character.
- The syntax highlighter will pick a root state mark at the start of the line or before it, and highlight from there until it reaches a root state or the end of the line, whichever comes last. If there is a root state mark at the cursor position, the highlighting stops at the end of the line and we skip the newly added newline character.
There's another potential problem with this. What if there is a root state mark within the text you deleted (or at the cursor when inserting new text)? Presumably it would cause the highlighting to begin at the cursor instead of the previous root state mark.