Dont show hidden sub-commands during completion

This commit is contained in:
Kovid Goyal 2023-10-10 05:33:04 +05:30
parent 5d0dabe51c
commit 455d0a6048
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 2 additions and 3 deletions

View File

@ -92,9 +92,8 @@ def completion(self: TestCompletion, tdir: str):
self.assertEqual(cp.returncode, 0, f'kitten __complete__ failed with exit code: {cp.returncode}')
return json.loads(cp.stdout)
add('kitty ', has_words('@', '@ls', '+', '+open'))
add('kitty ', has_words('@', '+', '+open'))
add('kitty @ l', has_words('ls', 'last-used-layout', 'launch'))
add('kitty @l', has_words('@ls', '@last-used-layout', '@launch'))
def make_file(path, mode=None):
with open(os.path.join(tdir, path), mode='x') as f:

View File

@ -104,7 +104,7 @@ func complete_word(word string, completions *Completions, only_args_allowed bool
group.Title = "Sub-commands"
}
for _, sc := range cg.SubCommands {
if strings.HasPrefix(sc.Name, word) {
if !sc.Hidden && strings.HasPrefix(sc.Name, word) {
t := sc.ShortDescription
if t == "" {
t = sc.HelpText