MCPcopy Create free account
hub / github.com/FastLED/FastLED / _find_balanced_close_paren_from

Function _find_balanced_close_paren_from

ci/refactor/add_fl_noexcept.py:161–179  ·  view source on GitHub ↗

Find the balanced closing ')' starting from '(' at (start_line, start_col). Returns (line_index, col_index) of the matching ')' or (-1, -1).

(
    lines: list[str], start_line: int, start_col: int
)

Source from the content-addressed store, hash-verified

159
160
161def _find_balanced_close_paren_from(
162 lines: list[str], start_line: int, start_col: int
163) -> tuple[int, int]:
164 """Find the balanced closing ')' starting from '(' at (start_line, start_col).
165
166 Returns (line_index, col_index) of the matching ')' or (-1, -1).
167 """
168 depth = 0
169 for li in range(start_line, min(start_line + 30, len(lines))):
170 begin = start_col if li == start_line else 0
171 for ci in range(begin, len(lines[li])):
172 ch = lines[li][ci]
173 if ch == "(":
174 depth += 1
175 elif ch == ")":
176 depth -= 1
177 if depth == 0:
178 return (li, ci)
179 return (-1, -1)
180
181
182def _skip_cv_and_trailing_return(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected