Commit 8cf760e7 authored by twanvl's avatar twanvl

fixed regex escaping bug, keywords with params are now no longer recognized if...

fixed regex escaping bug, keywords with params are now no longer recognized if followed by an opening parenthesis
parent 0a70d5d3
......@@ -214,7 +214,7 @@ void Keyword::prepare(const vector<KeywordParamP>& param_types, bool force) {
}
}
regex += _("(") + regex_escape(text) + _(")");
regex = _("\\y") + regex + _("(?=$|[^a-zA-Z0-9])"); // only match whole words
regex = _("\\y") + regex + _("(?=$|[^a-zA-Z0-9\\(])"); // only match whole words
if (match_re.Compile(regex, wxRE_ADVANCED)) {
// not valid if it matches "", that would make MSE hang
valid = !match_re.Matches(_(""));
......
......@@ -422,9 +422,11 @@ String make_non_capturing(const String& re) {
String ret;
bool escape = false, bracket = false, capture = false;
FOR_EACH_CONST(c, re) {
if (capture && c != _('?')) {
// change this capture into a non-capturing "(" by appending "?:"
ret += _("?:");
if (capture) {
if (c != _('?')) {
// change this capture into a non-capturing "(" by appending "?:"
ret += _("?:");
}
capture = false;
}
if (escape) { // second char of escape sequence
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment