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)
| 136 | |
| 137 | |
| 138 | def _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 | |
| 161 | def _find_balanced_close_paren_from( |
no outgoing calls
no test coverage detected