diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx index 8dafe52a28..69a1d4b619 100644 --- a/scintilla/src/Document.cxx +++ b/scintilla/src/Document.cxx @@ -2950,11 +2950,9 @@ Sci::Position Document::BraceMatch(Sci::Position position, Sci::Position /*maxRe const int styBrace = StyleIndexAt(position); const int direction = (chBrace < chSeek) ? 1 : -1; const unsigned char safeChar = (direction >= 0) ? asciiForwardSafeChar : asciiBackwardSafeChar; - int depth = 1; position = useStartPos ? startPos : NextPosition(position, direction); - //startPos = position; - //const ElapsedPeriod period; const Sci::Position length = LengthNoExcept(); + int depth = 1; while (IsValidIndex(position, length)) { const unsigned char chAtPos = CharAt(position); if (chAtPos == chBrace || chAtPos == chSeek) { @@ -2968,16 +2966,11 @@ Sci::Position Document::BraceMatch(Sci::Position position, Sci::Position /*maxRe } else if (chAtPos <= safeChar) { position += direction; } else { - const Sci::Position positionBeforeMove = position; - position = NextPosition(position, direction); - if (position == positionBeforeMove) { + if (!NextCharacter(position, direction)) { break; } } } - //const double duration = period.Duration(); - //printf("%s (%d, %zd, %zd / %zd): %.6f\n", __func__, direction, startPos, GetEndStyled(), length, duration); - //return depth ? -1 : position; return -1; } diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index 3d3a8649ff..3599a3af79 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -8086,10 +8086,15 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { } break; - case Message::BraceMatch: + case Message::BraceMatch: { // wParam is position of char to find brace for, // lParam is maximum amount of text to restyle to find it - return pdoc->BraceMatch(PositionFromUPtr(wParam), lParam, 0, false); + // const ElapsedPeriod period; + const Sci::Position position = pdoc->BraceMatch(PositionFromUPtr(wParam), lParam, 0, false); + // const double duration = period.Duration()*1e3; + // printf("BraceMatch %zu / %zd, %zd / %zd, %f\n", wParam, position, pdoc->GetEndStyled(), pdoc->LengthNoExcept(), duration); + return position; + } case Message::BraceMatchNext: return pdoc->BraceMatch(PositionFromUPtr(wParam), 0, lParam, true);