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
)
| 159 | |
| 160 | |
| 161 | def _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 | |
| 182 | def _skip_cv_and_trailing_return( |
no outgoing calls
no test coverage detected