1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:27:35 +00:00

HackStudio: Highlight maching parentheses as well

This can just piggyback on the code I just wrote for curly braces.
This commit is contained in:
Andreas Kling 2019-11-18 19:13:46 +01:00
parent c8e02e60a6
commit d5afc58744

View file

@ -229,13 +229,28 @@ void Editor::cursor_did_change()
return; return;
} }
if (token_type == CppToken::Type::LeftParen && span.range.start() == cursor()) {
auto buddy = find_span_of_type(i, CppToken::Type::RightParen, CppToken::Type::LeftParen, Direction::Forward);
if (buddy != -1)
make_buddies(i, buddy);
return;
}
auto right_of_end = span.range.end(); auto right_of_end = span.range.end();
right_of_end.set_column(right_of_end.column() + 1); right_of_end.set_column(right_of_end.column() + 1);
if (token_type == CppToken::Type::RightCurly && right_of_end == cursor()) { if (token_type == CppToken::Type::RightCurly && right_of_end == cursor()) {
auto buddy = find_span_of_type(i, CppToken::Type::LeftCurly, CppToken::Type::RightCurly, Direction::Backward); auto buddy = find_span_of_type(i, CppToken::Type::LeftCurly, CppToken::Type::RightCurly, Direction::Backward);
if (buddy != -1) if (buddy != -1)
make_buddies(i, buddy); make_buddies(i, buddy);
return; return;
} }
if (token_type == CppToken::Type::RightParen && right_of_end == cursor()) {
auto buddy = find_span_of_type(i, CppToken::Type::LeftParen, CppToken::Type::RightParen, Direction::Backward);
if (buddy != -1)
make_buddies(i, buddy);
return;
}
} }
} }