From ea80233f6586aa6a585653bb174c96c8cdbacf66 Mon Sep 17 00:00:00 2001 From: donho Date: Thu, 17 Jul 2008 12:17:47 +0000 Subject: [PATCH] [BUG_FIXED] Fix crash bug for tags match highlighting. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@291 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Notepad_plus.cpp | 1 + .../src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 13bcfc3c6..1421004dd 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2221,6 +2221,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) XmlMatchedTagsHighlighter xmlTagMatchHiliter(_pEditView); xmlTagMatchHiliter.tagMatch(nppGUI._enableTagAttrsHilite); } + markSelectedText(); updateStatusBar(); AutoCompletion * autoC = isFromPrimary?&_autoCompleteMain:&_autoCompleteSub; diff --git a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp index 5744f0480..cbf1a2031 100644 --- a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp +++ b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp @@ -110,6 +110,11 @@ bool XmlMatchedTagsHighlighter::getMatchedTagPos(int searchStart, int searchEnd, bool direction = searchEnd > searchStart; + if ((direction == search2Left) && (searchStart <= searchEnd)) + return false; + else if ((direction == search2Right) && (searchStart >= searchEnd)) + return false; + pair foundPos; int ltPosOnR = getFirstTokenPosFrom(searchStart, searchEnd, tag2find, foundPos); if (ltPosOnR == -1) @@ -119,7 +124,7 @@ bool XmlMatchedTagsHighlighter::getMatchedTagPos(int searchStart, int searchEnd, int idStyle = _pEditView->execute(SCI_GETSTYLEAT, ltPosOnR); if (idStyle >= SCE_HJ_START) { - int start = foundPos.first; + int start = (direction == search2Left)?foundPos.first:foundPos.second; int end = searchEnd; return getMatchedTagPos(start, end, tag2find, oppositeTag2find, oppositeTagFound, tagsPos); }