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

Function _find_balanced_close_paren

ci/refactor/add_fl_noexcept.py:138–158  ·  view source on GitHub ↗

Find the balanced closing ')' starting from start_line. Scans from the first '(' on start_line forward across lines. Returns (line_index, col_index) of the matching ')' or (-1, -1).

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

Source from the content-addressed store, hash-verified

136
137
138def _find_balanced_close_paren(lines: list[str], start_line: int) -> tuple[int, int]:
139 """Find the balanced closing ')' starting from start_line.
140
141 Scans from the first '(' on start_line forward across lines.
142 Returns (line_index, col_index) of the matching ')' or (-1, -1).
143 """
144 depth = 0
145 found_open = False
146
147 for li in range(start_line, min(start_line + 30, len(lines))):
148 line = lines[li]
149 for ci, ch in enumerate(line):
150 if ch == "(":
151 depth += 1
152 found_open = True
153 elif ch == ")":
154 depth -= 1
155 if found_open and depth == 0:
156 return (li, ci)
157
158 return (-1, -1)
159
160
161def _find_balanced_close_paren_from(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected