fix(completion): close shell completion review gaps

This commit is contained in:
Tam Nhu Tran
2026-04-03 01:40:45 -04:00
parent ffe3082528
commit 0da7598a84
3 changed files with 18 additions and 1 deletions
+1 -1
View File
@@ -137,7 +137,7 @@ $ ccs auth show <TAB>
work personal team --json
$ ccs api <TAB>
create discover copy export import remove
create list discover copy export import remove
```
### Backend Contract
+3
View File
@@ -7,6 +7,9 @@ function __fish_ccs_complete
end
set -l current (commandline -ct)
if test -n "$current"; and test (count $tokens_before_current) -gt 0; and test "$tokens_before_current[-1]" = "$current"
set -e tokens_before_current[-1]
end
set -l script_file (status filename)
set -l repo_root (realpath (dirname $script_file)/../.. 2>/dev/null)
@@ -1,3 +1,6 @@
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { describe, it, expect, beforeAll, beforeEach, afterEach, mock } from 'bun:test';
type ShellTarget = 'bash' | 'zsh' | 'fish' | 'powershell' | null;
@@ -139,4 +142,15 @@ describe('shell-completion command', () => {
true
);
});
it('fish completion strips a duplicated partial token before delegating to __complete', () => {
const fishScript = readFileSync(
join(import.meta.dir, '../../../scripts/completion/ccs.fish'),
'utf8'
);
expect(fishScript).toContain('set -l current (commandline -ct)');
expect(fishScript).toContain('test "$tokens_before_current[-1]" = "$current"');
expect(fishScript).toContain('set -e tokens_before_current[-1]');
});
});