MCPcopy Create free account
hub / github.com/SpartanJ/eepp / getMatchingBracket

Method getMatchingBracket

src/eepp/ui/doc/textdocument.cpp:3887–3916  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3885}
3886
3887TextPosition TextDocument::getMatchingBracket( TextPosition sp,
3888 const String::StringBaseType& openBracket,
3889 const String::StringBaseType& closeBracket,
3890 MatchDirection dir, bool allowDepth, Time timeout ) {
3891 SyntaxHighlighter* highlighter = getHighlighter();
3892 int depth = 0;
3893 Clock c;
3894 while ( sp.isValid() && ( timeout == Time::Zero || c.getElapsedTime() < timeout ) ) {
3895 auto byte = getCharFromUnsanitizedPosition( sp );
3896 if ( byte == openBracket ) {
3897 changeDepth( highlighter, depth, sp, 1 );
3898 if ( depth == 0 )
3899 return sp;
3900 if ( !allowDepth && depth > 1 )
3901 return {};
3902 } else if ( byte == closeBracket ) {
3903 changeDepth( highlighter, depth, sp, -1 );
3904 if ( depth == 0 )
3905 return sp;
3906 if ( !allowDepth && depth > 1 )
3907 return {};
3908 }
3909
3910 auto prevPos = sp;
3911 sp = positionOffset( sp, dir == MatchDirection::Forward ? 1 : -1, false );
3912 if ( sp == prevPos )
3913 return {};
3914 }
3915 return {};
3916}
3917
3918TextRange TextDocument::getMatchingBracket( TextPosition start, const String& openBracket,
3919 const String& closeBracket, MatchDirection dir,

Callers 3

updateMatchMethod · 0.80
checkMatchingBracketsMethod · 0.80

Calls 8

changeDepthFunction · 0.85
findFunction · 0.85
getElapsedTimeMethod · 0.80
normalizedMethod · 0.80
isValidMethod · 0.45
sizeMethod · 0.45
startMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected