diff --git a/lib/ace/mode/rust_highlight_rules.js b/lib/ace/mode/rust_highlight_rules.js index 046a50af47..32250fb686 100644 --- a/lib/ace/mode/rust_highlight_rules.js +++ b/lib/ace/mode/rust_highlight_rules.js @@ -37,6 +37,7 @@ var oop = require("../lib/oop"); var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var stringEscape = /\\(?:[nrt0'"\\]|x[\da-fA-F]{2}|u\{[\da-fA-F]{6}\})/.source; +var wordPattern = /[a-zA-Z_\xa1-\uffff][a-zA-Z0-9_\xa1-\uffff]*/.source; var RustHighlightRules = function() { // regexp must not have capturing parentheses. Use (?:) instead. // regexps are ordered -> the first match is used @@ -46,11 +47,11 @@ var RustHighlightRules = function() { // `(?![\\\'])` to keep a lifetime name highlighting from continuing one character // past the name. The end `\'` will block this from matching for a character like // `'a'` (it should have character highlighting, not variable highlighting). - regex: '\'[a-zA-Z_][a-zA-Z0-9_]*(?![\\\'])' }, + regex: '\'' + wordPattern + '(?![\\\'])' }, { token: 'string.quoted.single.source.rust', regex: "'(?:[^'\\\\]|" + stringEscape + ")'" }, { token: 'identifier', - regex: /r#[a-zA-Z_][a-zA-Z0-9_]*\b/ }, + regex: "r#" + wordPattern + "\\b" }, { stateName: "bracketedComment", onMatch : function(value, currentState, stack){ @@ -90,8 +91,8 @@ var RustHighlightRules = function() { regex: stringEscape }, { defaultToken: 'string.quoted.double.source.rust' } ] }, { token: [ 'keyword.source.rust', 'text', 'entity.name.function.source.rust' ], - regex: '\\b(fn)(\\s+)((?:r#)?[a-zA-Z_][a-zA-Z0-9_]*)' }, - { token: 'support.constant', regex: '\\b[a-zA-Z_][\\w\\d]*::' }, + regex: '\\b(fn)(\\s+)((?:r#)?'+ wordPattern + ')' }, + { token: 'support.constant', regex: wordPattern + '::' }, { token: 'keyword.source.rust', regex: '\\b(?:abstract|alignof|as|async|await|become|box|break|catch|continue|const|crate|default|do|dyn|else|enum|extern|for|final|if|impl|in|let|loop|macro|match|mod|move|mut|offsetof|override|priv|proc|pub|pure|ref|return|self|sizeof|static|struct|super|trait|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\\b' }, { token: 'storage.type.source.rust',