Commit 9622285
authored
[ty] Autocomplete arguments if in arguments node (#24167)
<!--
Thank you for contributing to Ruff/ty! To help us out with reviewing,
please consider the following:
- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title? (Please prefix
with `[ty]` for ty pull
requests.)
- Does this pull request include references to any relevant issues?
-->
## Summary
Addresses [this
comment](astral-sh/ty#3087 (comment)).
Fixes astral-sh/ty#3087.
I initially did the same ancestor walking check in both places but then
I tried to come up with another way that does not iterate multiple
times.
Since in `add_argument_completions` we are already iterating over node
ancestors of the node the cursor is in, we can determine if cursor is in
an arguments node.
So I did that instead of duplicating the
`cursor.covering_node.ancestors() ...` code.
<!-- What's the purpose of the change? What does it do, and why? -->
## Test Plan
Added the test case that would panic in debug build without this fix.
<!-- How was it tested? -->1 parent d812662 commit 9622285
1 file changed
Lines changed: 21 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1397 | 1397 | | |
1398 | 1398 | | |
1399 | 1399 | | |
| 1400 | + | |
1400 | 1401 | | |
1401 | 1402 | | |
1402 | | - | |
1403 | | - | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
1404 | 1408 | | |
1405 | 1409 | | |
1406 | 1410 | | |
| |||
5465 | 5469 | | |
5466 | 5470 | | |
5467 | 5471 | | |
| 5472 | + | |
| 5473 | + | |
| 5474 | + | |
| 5475 | + | |
| 5476 | + | |
| 5477 | + | |
| 5478 | + | |
| 5479 | + | |
| 5480 | + | |
| 5481 | + | |
| 5482 | + | |
| 5483 | + | |
| 5484 | + | |
| 5485 | + | |
| 5486 | + | |
5468 | 5487 | | |
5469 | 5488 | | |
5470 | 5489 | | |
| |||
0 commit comments