Commit b325e9f
fix: match completion prefix against unescaped names (#460)
When using `complete ... descriptions=#true`, prefix matching was done
against escaped strings (e.g., `test\:integration`) instead of unescaped
names (`test:integration`). This caused completions to fail when user
input contained an unescaped colon.
Fix by moving the filter to after the map that unescapes the names.
This bug caused a problem with mise: there was no shell completion if
you entered `mise test:i<tab>` even if there was a `test:integration`
task. `mise run test:i<tab>` was *not* affected, that is treated
differently by `mise`'s `usage` spec.
------
I feel that the test could be more readable, I might do that in a
subsequent PR. I think all `complete_word` tests could use the fish
syntax instead of the zsh syntax, so e.g.
```rust
"test:unit\tRun unit tests\ntest:integration\tRun integration tests\nbuild\tBuild the project\n"
// instead of
"'test\\\\:unit'\\:'Run unit tests'\n'test\\\\:integration'\\:'Run integration tests'\n'build'\\:'Build the project'\n"
```
Let me know if you prefer I do that refactor first to make the diff here
more readable (but it's not *that* bad)
**Update:** Apparently, that'd also make Copilot happer. Here's a draft:
ilyagr@fish-refactor . Again, I'm happy
to reorder the commits so that the cleaner syntax comes first. The
biggest win from the refactor is in the test added in this PR, but
others are also easier to read IMO for somebody unfamiliar with either
shell's syntax.
------
This was mostly debugged by AI. If the fix is not correct, it could be
considered a bug report (but it seems good to me).
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Fixes completion prefix matching when `complete ...
descriptions=#true` by filtering after unescaping `name:description`
outputs.
>
> - In `complete_word.rs`, process command output lines first (unescape
and split) then filter by `ctoken`, so prefixes match unescaped names
containing colons
> - Adds test `complete_word_escaped_colons_in_completions` and example
`colon-in-completions.usage.kdl` to validate colon-containing
completions
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
e24490f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Ilya Grigoriev <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>1 parent 85378c5 commit b325e9f
File tree
3 files changed
+34
-1
lines changed- cli
- src/cli
- tests
- examples
3 files changed
+34
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
285 | 284 | | |
286 | 285 | | |
287 | 286 | | |
| |||
298 | 297 | | |
299 | 298 | | |
300 | 299 | | |
| 300 | + | |
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
255 | 279 | | |
256 | 280 | | |
257 | 281 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments