WML: fix infinite loop in contexts switch & only highlight tags with valid names

Authored by nibags on Dec 31 2018, 8:03 PM.



BUG: 402720

In the wml.xml file an infinite context switch between section and error is generated, through lineEndContext: in a line break, the section context sends to error and then this is #poped in the line break, causing an infinite cycle. This causes that Kate freezes.

This is reproducible by typing the [ character and then a line break.

This bug is reproducible only in KSyntaxHighlighting, since in KF5.48 there is no problem. It's probably necessary to add a guard that avoids infinite context changes.

Also, the WML highlighter is a little old and I have seen some problems in sample files. The highlighter considers all content between [ and ] as tag. According to the documentation [1]:

Also, tag and key names follow a special format. They will contain only alphanumeric characters and underscores; in particular, they will not contain +, -, or whitespace.

Considering this, and based on the VSCode highlighter, I modified the code so that only tags with valid names are highlighted.


Diff Detail

R216 Syntax Highlighting
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
nibags created this revision.Dec 31 2018, 8:03 PM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptDec 31 2018, 8:03 PM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
nibags requested review of this revision.Dec 31 2018, 8:03 PM
nibags updated this revision to Diff 48465.Dec 31 2018, 9:20 PM
  • Fix RegExp of tag name
dhaumann accepted this revision.Jan 1 2019, 11:13 AM

Good patch. More improvements are of course welcome :)

Minor comment: we prefer to delete commented code, usually commented code is more confusing than helpful.

Other comment: kateversion still says 2.3. Maybe it's time for an overhaul to use new default styles and raise kateversion to 5.0?

This revision is now accepted and ready to land.Jan 1 2019, 11:13 AM
nibags updated this revision to Diff 48510.Jan 2 2019, 7:47 AM
  • Update

I asked in the thread of the Wesnoth forum, that appears in the wml.xml file (http://www.wesnoth.org/forum/viewtopic.php?f=21&t=13781), if the changes are OK and someone has suggested to me that the array indices (array[0]) aren't highlighted as tags, as well that I included it


  • kateversion to 5.0
  • Delete commented code
  • Don't highlight tags if there is an alphanumeric character, underscore or "]" before, to avoid highlighting array indices as tags.
nibags updated this revision to Diff 48617.Jan 3 2019, 6:31 PM
  • Update test file
This revision was automatically updated to reflect the committed changes.