Warning, /frameworks/syntax-highlighting/autotests/folding/test.diff.fold is written in an unsupported language. File is not indexed.
0001 commit 2b16665838c8afeaa0f065cafc747438de35876b 0002 Author: Volker Krause <vkrause@kde.org> 0003 Date: Sat Oct 8 13:31:51 2016 +0200 0004 0005 Implement dynamic DetectChar rules 0006 0007 Needed for Perl highlighting. 0008 0009 <beginfold id='1'>diff</beginfold id='1'> --git a/src/lib/rule.cpp b/src/lib/rule.cpp 0010 index f588985..c4c3b92 100644 0011 --- a/src/lib/rule.cpp 0012 +++ b/src/lib/rule.cpp 0013 <beginfold id='1'>@@</beginfold id='1'> -308,12 +308,22 @@ bool DetectChar::doLoad(QXmlStreamReader& reader) 0014 if (s.isEmpty()) 0015 return false; 0016 m_char = s.at(0); 0017 + if (isDynamic()) { 0018 + m_captureIndex = m_char.digitValue(); 0019 + } 0020 return true; 0021 } 0022 0023 MatchResult DetectChar::doMatch(const QString& text, int offset, const QStringList &captures) 0024 { 0025 - Q_UNUSED(captures); // TODO 0026 + if (isDynamic()) { 0027 + if (captures.size() <= m_captureIndex || captures.at(m_captureIndex).isEmpty()) 0028 + return offset; 0029 + if (text.at(offset) == captures.at(m_captureIndex).at(0)) 0030 + return offset + 1; 0031 + return offset; 0032 + } 0033 + 0034 if (text.at(offset) == m_char) 0035 return offset + 1; 0036 return offset; 0037 <endfold id='1'></endfold id='1'><endfold id='1'></endfold id='1'><beginfold id='1'>diff</beginfold id='1'> --git a/src/lib/rule_p.h b/src/lib/rule_p.h 0038 index d8862ae..d9cedbf 100644 0039 --- a/src/lib/rule_p.h 0040 +++ b/src/lib/rule_p.h 0041 <beginfold id='1'>@@</beginfold id='1'> -103,6 +103,7 @@ protected: 0042 0043 private: 0044 QChar m_char; 0045 + int m_captureIndex; 0046 }; 0047 0048 class Detect2Char : public Rule