MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / closeBracket

Function closeBracket

tools/shell/linenoise.cpp:1627–1652  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1625}
1626
1627static void closeBracket(std::vector<uint64_t>& brackets, std::vector<uint64_t>& cursor_brackets,
1628 uint64_t pos, uint64_t i, std::vector<uint64_t>& errors) {
1629 if (pos == i) {
1630 // cursor is on this closing bracket
1631 // clear any selected brackets - we always select this one
1632 cursor_brackets.clear();
1633 }
1634 if (brackets.empty()) {
1635 // closing bracket without matching opening bracket
1636 errors.push_back(i);
1637 } else {
1638 if (cursor_brackets.size() == 1) {
1639 if (cursor_brackets.back() == brackets.back()) {
1640 // this closing bracket matches the highlighted opening cursor bracket - highlight
1641 // both
1642 cursor_brackets.push_back(i);
1643 }
1644 } else if (cursor_brackets.empty() && (pos == i || (i + 1) == pos || (pos + 1) == i)) {
1645 // no cursor bracket selected yet and cursor is BEFORE or AFTER this bracket
1646 // add this bracket
1647 cursor_brackets.push_back(i);
1648 cursor_brackets.push_back(brackets.back());
1649 }
1650 brackets.pop_back();
1651 }
1652}
1653
1654static void HandleBracketErrors(const std::vector<uint64_t>& brackets,
1655 std::vector<uint64_t>& errors) {

Callers 1

addErrorHighlightingFunction · 0.85

Calls 5

clearMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected