From c73d5b5bdebf86223c1556279e19a7352c9bbd99 Mon Sep 17 00:00:00 2001 From: Daimona Eaytoy Date: Fri, 29 Mar 2019 10:44:02 +0100 Subject: [PATCH] Restore highlighting of all keywords, functions, etc. Short explanation on phab. Ace stops at the first regex match, so we must use a function to specify the token type. Bug: T219593 Change-Id: If7e6e98de81ce7e1be334732518425c8115e4aea --- modules/mode-abusefilter.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/mode-abusefilter.js b/modules/mode-abusefilter.js index 3d5a0f39b..624388146 100644 --- a/modules/mode-abusefilter.js +++ b/modules/mode-abusefilter.js @@ -13,7 +13,8 @@ ace.define( 'ace/mode/abusefilter_highlight_rules', [ 'require', 'exports', 'mod 'support.function': cfg.functions, 'constant.language': constants }, - 'identifier' + // Null as default used in isKeywordOrVariable + null ), variables = this.createKeywordMapper( { @@ -24,6 +25,13 @@ ace.define( 'ace/mode/abusefilter_highlight_rules', [ 'require', 'exports', 'mod 'identifier', true ), + isKeywordOrVariable = function ( value ) { + if ( keywords( value ) !== null ) { + return keywords( value ); + } else { + return variables( value ); + } + }, integer = '(?:(?:[1-9]\\d*)|(?:0))', fraction = '(?:\\.\\d+)', intPart = '(?:\\d+)', @@ -50,10 +58,7 @@ ace.define( 'ace/mode/abusefilter_highlight_rules', [ 'require', 'exports', 'mod token: 'constant.numeric', regex: integer + '\\b' }, { - token: variables, - regex: '[a-zA-Z_][a-zA-Z0-9_]*\\b' - }, { - token: keywords, + token: isKeywordOrVariable, regex: '[a-zA-Z_][a-zA-Z0-9_]*\\b' }, { token: 'keyword.operator',