From 7c306eede7f57074e3bda91d8e3915c38555523f Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 7 Sep 2016 11:04:22 -0400 Subject: Fix up the bracket matching routine when going backwards exactly one space "()" for example. --- src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src-qt5') diff --git a/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp b/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp index 82b742ec..d79bdc5f 100644 --- a/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp @@ -164,6 +164,7 @@ void PlainTextEditor::highlightMatch(QChar ch, bool forward, int fromPos, QChar int nested = 1; //always start within the first nest (the primary nest) int tmpFromPos = fromPos; + //if(!forward){ tmpFromPos++; } //need to include the initial location QString doc = this->toPlainText(); while( nested>0 && tmpFromPos=fromPos && forward) || ( tmpFromPos<=fromPos && !forward ) ) ){ if(forward){ @@ -176,8 +177,10 @@ void PlainTextEditor::highlightMatch(QChar ch, bool forward, int fromPos, QChar }else{ QTextCursor cur = this->document()->find(ch, tmpFromPos, QTextDocument::FindBackward); if(!cur.isNull()){ - QString mid = doc.mid(cur.position()-1, tmpFromPos-cur.position()); - nested += mid.count(startch) - mid.count(ch); + QString mid = doc.mid(cur.position()-1, tmpFromPos-cur.position()+1); + //qDebug() << "Found backwards match:" << nested << startch << ch << mid; + //qDebug() << doc.mid(cur.position(),1) << doc.mid(tmpFromPos,1); + nested += (mid.count(startch) - mid.count(ch)); if(nested==0){ matchleft = cur.position(); } else{ tmpFromPos = cur.position()-1; } }else{ break; } -- cgit