Clear error indicators when there is no error

This commit is contained in:
Zane U. Ji 2012-09-21 00:53:05 +08:00
parent 70292fe84a
commit bc99b579db
2 changed files with 9 additions and 7 deletions

View File

@ -3354,6 +3354,7 @@ bool MyFrame::openFile ( wxString& fileName, bool largeFile )
int newPosition = doc->PositionFromLine ( posPair.first ); int newPosition = doc->PositionFromLine ( posPair.first );
doc->SetSelection ( newPosition, newPosition ); doc->SetSelection ( newPosition, newPosition );
doc->SetFocus(); doc->SetFocus();
doc->setErrorIndicator ( posPair.first, posPair.second );
} }
else else
{ {

View File

@ -1999,15 +1999,16 @@ std::string XmlCtrl::myGetTextRaw()
void XmlCtrl::setErrorIndicator ( int line, int column ) void XmlCtrl::setErrorIndicator ( int line, int column )
{ {
int startPos, endPos; int startPos, endPos, endStyled;
startPos = PositionFromLine ( line ) + column; startPos = PositionFromLine ( line ) + column;
endPos = GetLineEndPosition ( line ); endPos = GetLineEndPosition ( line );
StartStyling ( startPos, wxSTC_INDIC2_MASK ); endStyled = GetEndStyled();
if ( endPos > endStyled ) endPos = endStyled;
int length = endPos - startPos; int length = endPos - startPos;
if ( length > 0 && length + startPos < GetLength() )
if ( length == 0 || ( length > 0 && length + startPos < GetLength() ) )
{ {
StartStyling ( startPos, wxSTC_INDIC2_MASK );
SetStyling ( length, wxSTC_INDIC2_MASK ); SetStyling ( length, wxSTC_INDIC2_MASK );
} }
} }
@ -2021,11 +2022,11 @@ void XmlCtrl::clearErrorIndicators ( int maxLine )
if ( !length ) if ( !length )
return; return;
StartStyling ( 0, wxSTC_INDIC2_MASK );
int end = GetEndStyled(); int end = GetEndStyled();
length = ( maxLine ) ? GetLineEndPosition ( maxLine ) : length; 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 ); SetStyling ( length, 0 );
} }