Perl: fix brackets, variables, string references and others
ClosedPublic

Authored by nibags on Sep 10 2018, 7:46 AM.

Details

Summary

Fix incorrect bracket closures in RegExp patterns

BUG: 364866

Recursive subgroups are added inside brackets {} and (), to avoid incorrect closures in RegExp patterns. This correction is in accordance with other text editors (VS Code, Atom, gedit & Sublime Text), which highlight the RegExp patterns in that way.

Allow strings as scalar references

BUG: 348765

Previously, the characters " and ' were escaped, which caused an erroneous highlight when using references such as \'string' (see ref. [1] and [2]).

Fix incorrect highlighting of variables that start with underscores

BUG: 355300

This error was caused by the order of the RegExpr rules to detect variables: [@\$][\+\-_] had priority over \$[#_][\w_] ($_ is a special variable) (ref. [3] & [4]).

Fix incorrect highlighting of characters in variables

BUG: 391577

Previously, characters such as ()[]} were highlighted after * in some variables, such as @*), causing incorrect closures of brackets.

Other fixes:

  • Add variables with carret, such as: ${^Foo} or $^V (ref. [3]).
  • Add special variables: %+, %-, %! & %^H (ref. [3]).
  • Missing escapes are added, such as \x{NN..}, \o{NN..} (full list in ref. [5]).

References:

FIXED-IN: 5.51.0

Diff Detail

Repository
R216 Syntax Highlighting
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
nibags created this revision.Sep 10 2018, 7:46 AM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptSep 10 2018, 7:46 AM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
nibags requested review of this revision.Sep 10 2018, 7:46 AM
nibags retitled this revision from Perl: fix brackets, variables, strings ref. and some improvements to Perl: fix brackets, variables, string references and others.Sep 10 2018, 7:58 AM
cullmann accepted this revision.Sep 10 2018, 8:15 AM

Nice, looks a lot better in the comparison screenshots.
I had this issues in my own scripts, too, but was too dumb to fix that myself, thanks ;=)

This revision is now accepted and ready to land.Sep 10 2018, 8:15 AM
nibags edited the summary of this revision. (Show Details)Sep 10 2018, 8:19 AM
This revision was automatically updated to reflect the committed changes.