Set the POSIX flag in Scintilla regex find

The POSIX flag is passed to QScintilla for stardardisation of the regex
implementation. This only changes the syntax for sub-expressions. Before
this change it was '\( \)'. With the POSIX flag it is simply '( )' for
sub-expressions, consequently \( and \( have to be used for matching
parenthesis.

Both the Qt implementation (used in filters and REGEXP operator) and the
C++11 standard (possibly used in the future for the editor, if QScintilla
add support) use the the new syntax for sub-expressions.

References:
https://en.cppreference.com/w/cpp/regex/syntax_option_type
>    If no grammar is chosen, ECMAScript is assumed to be selected.

https://en.cppreference.com/w/cpp/regex/ecmascript
>    The Atom ( Disjunction ) is marked subexpression

Qt also uses subexpressions in the POSIX style.
http://doc.qt.io/qt-5/qregexp.html#capturing-parentheses

See issue #1625
This commit is contained in:
mgrojo
2018-11-25 18:42:35 +01:00
parent 58553647a5
commit 58f52f13cb
2 changed files with 10 additions and 3 deletions

View File

@@ -211,7 +211,8 @@ bool ExtendedScintilla::findText(QString text, bool regexp, bool caseSensitive,
setCursorPosition(lineFrom, indexFrom);
}
return findFirst(text, regexp, caseSensitive, words, wrap, forward);
return findFirst(text, regexp, caseSensitive, words, wrap, forward,
/* line */ -1, /* index */ -1, /* show */ true, /* posix */ true);
}
void ExtendedScintilla::clearSelection()

View File

@@ -52,7 +52,9 @@ bool FindReplaceDialog::findFirst(bool wrap, bool forward)
ui->regexpCheckBox->isChecked(),
ui->caseCheckBox->isChecked(),
ui->wholeWordsCheckBox->isChecked(),
forward);
forward,
/* show */ true,
/* posix */ true);
else
return m_scintilla->findFirst
(ui->findText->text(),
@@ -60,7 +62,11 @@ bool FindReplaceDialog::findFirst(bool wrap, bool forward)
ui->caseCheckBox->isChecked(),
ui->wholeWordsCheckBox->isChecked(),
wrap,
forward);
forward,
/* line */ -1,
/* index */ -1,
/* show */ true,
/* posix */ true);
}
bool FindReplaceDialog::findNext()