Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this is a rewrite of the syntax highlighting code. overall it's a salmon-colored patch (deleted more than added), the code is easier to follow, and it fixes some long-standing bugs. as noted in the readme, there was a bug involving overlapping rules. the most annoying instance of this bug was with strings containing a `/*` such as in glob patterns. for example: ``` "match/this/path/*" ``` with `syn_generic` applied, we used to interpret `/*` as the beginning of a multi-line comment, and therefore the rest of the file (or until there happened to be a closing `*/` somewhere). this bothered me for a very long time. this bug was due to how we used to apply rules. each rule would get applied one after the other, each from the beginning of the line. the last rule to style any given span of text superseded any previous rules that matched. in the rewrite, once a rule matches a span of text, we don't try to style that span anymore (until the text is edited of course). the one downside is that this seems to be slightly less performant. on my machine, applying `syn_generic` is about 5% slower, but it's still generally fast enough that you'd only start to notice the difference if you were opening massive files, tens or hundreds of megabytes large, with syntax highlighting on. a memo field was added (`smemo_t`) which drastically improved perf. there are probably further perf optimizations to be had. i added a couple more functional tests, on top of the existing ones, to exercise some edge cases of syntax highlighting. as always please report bugs if you find any.
- Loading branch information