diff --git a/DevTools/HackStudio/Editor.cpp b/DevTools/HackStudio/Editor.cpp index 81d991a028..921416ede0 100644 --- a/DevTools/HackStudio/Editor.cpp +++ b/DevTools/HackStudio/Editor.cpp @@ -229,13 +229,28 @@ void Editor::cursor_did_change() 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(); right_of_end.set_column(right_of_end.column() + 1); + 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); if (buddy != -1) make_buddies(i, buddy); 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; + } } }