From bc99b579dbce56019cc6ea8365943481aa6bdd79 Mon Sep 17 00:00:00 2001 From: "Zane U. Ji" Date: Fri, 21 Sep 2012 00:53:05 +0800 Subject: [PATCH] Clear error indicators when there is no error --- src/xmlcopyeditor.cpp | 1 + src/xmlctrl.cpp | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/xmlcopyeditor.cpp b/src/xmlcopyeditor.cpp index c16e38a..384ca6f 100755 --- a/src/xmlcopyeditor.cpp +++ b/src/xmlcopyeditor.cpp @@ -3354,6 +3354,7 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile ) int newPosition = doc->PositionFromLine ( posPair.first ); doc->SetSelection ( newPosition, newPosition ); doc->SetFocus(); + doc->setErrorIndicator ( posPair.first, posPair.second ); } else { diff --git a/src/xmlctrl.cpp b/src/xmlctrl.cpp index 226189d..cd5c158 100755 --- a/src/xmlctrl.cpp +++ b/src/xmlctrl.cpp @@ -1999,15 +1999,16 @@ std::string XmlCtrl::myGetTextRaw() void XmlCtrl::setErrorIndicator ( int line, int column ) { - int startPos, endPos; + int startPos, endPos, endStyled; startPos = PositionFromLine ( line ) + column; endPos = GetLineEndPosition ( line ); - StartStyling ( startPos, wxSTC_INDIC2_MASK ); + endStyled = GetEndStyled(); + if ( endPos > endStyled ) endPos = endStyled; int length = endPos - startPos; - - if ( length == 0 || ( length > 0 && length + startPos < GetLength() ) ) + if ( length > 0 && length + startPos < GetLength() ) { + StartStyling ( startPos, wxSTC_INDIC2_MASK ); SetStyling ( length, wxSTC_INDIC2_MASK ); } } @@ -2021,11 +2022,11 @@ void XmlCtrl::clearErrorIndicators ( int maxLine ) if ( !length ) return; - StartStyling ( 0, wxSTC_INDIC2_MASK ); - int end = GetEndStyled(); length = ( maxLine ) ? GetLineEndPosition ( maxLine ) : length; - if ( length > end ) length = end; + if ( end > 0 && length > end ) length = end; + + StartStyling ( 0, wxSTC_INDIC2_MASK ); SetStyling ( length, 0 ); }