Skip to content

Commit

Permalink
Minor update brace match, place performance measure code in right place.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Nov 14, 2024
1 parent 3142994 commit 56ede7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
11 changes: 2 additions & 9 deletions scintilla/src/Document.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down
9 changes: 7 additions & 2 deletions scintilla/src/Editor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 56ede7f

Please sign in to comment.