diff options
author | Ken Moore <ken@pcbsd.org> | 2016-09-07 11:04:22 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2016-09-07 11:04:22 -0400 |
commit | 7c306eede7f57074e3bda91d8e3915c38555523f (patch) | |
tree | d6d18fdf352bbccbf9e0758d5b36c02aa4f6d8ca /src-qt5/desktop-utils/lumina-textedit | |
parent | Fix up another multi-line syntax highlighting routine. (diff) | |
download | lumina-7c306eede7f57074e3bda91d8e3915c38555523f.tar.gz lumina-7c306eede7f57074e3bda91d8e3915c38555523f.tar.bz2 lumina-7c306eede7f57074e3bda91d8e3915c38555523f.zip |
Fix up the bracket matching routine when going backwards exactly one space "()" for example.
Diffstat (limited to 'src-qt5/desktop-utils/lumina-textedit')
-rw-r--r-- | src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
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<doc.length() && ( (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; } |