From 58f52f13cb6700e4503f667c9e49718f653906de Mon Sep 17 00:00:00 2001 From: mgrojo Date: Sun, 25 Nov 2018 18:42:35 +0100 Subject: [PATCH] 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 --- src/ExtendedScintilla.cpp | 3 ++- src/FindReplaceDialog.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ExtendedScintilla.cpp b/src/ExtendedScintilla.cpp index c615008c..ec3fc086 100644 --- a/src/ExtendedScintilla.cpp +++ b/src/ExtendedScintilla.cpp @@ -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() diff --git a/src/FindReplaceDialog.cpp b/src/FindReplaceDialog.cpp index 0d4ddbb5..7fe762e0 100644 --- a/src/FindReplaceDialog.cpp +++ b/src/FindReplaceDialog.cpp @@ -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()