All completion tests pass again
This commit is contained in:
parent
262e2fb7a3
commit
3bd4fd999a
5 changed files with 7 additions and 3 deletions
|
|
@ -58,6 +58,7 @@ def generate_kittens_completion() -> None:
|
|||
wof = get_kitten_wrapper_of(kitten)
|
||||
if wof:
|
||||
print(f'{kn}.ArgCompleter = cli.CompletionForWrapper("{serialize_as_go_string(wof)}")')
|
||||
print(f'{kn}.OnlyArgsAllowed = true')
|
||||
continue
|
||||
kcd = get_kitten_cli_docs(kitten)
|
||||
if kcd:
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ def is_delegate(num_to_remove: int = 0, command: str = ''):
|
|||
|
||||
def t(self, result):
|
||||
d = result['delegate']
|
||||
self.assertEqual(d, q)
|
||||
self.assertEqual(d, q, f'Command line: {self.current_cmd!r}')
|
||||
return t
|
||||
|
||||
|
||||
|
|
@ -157,6 +157,7 @@ def make_file(path, mode=None):
|
|||
add('kitty + kitten themes --', has_words('--cache-age'))
|
||||
add('kitty + kitten themes D', has_words('Default'))
|
||||
add('kitty + kitten hyperlinked_grep ', is_delegate(3, 'rg'))
|
||||
add('kitty +kitten hyperlinked_grep ', is_delegate(2, 'rg'))
|
||||
|
||||
add('clone-in-kitty --ty', has_words('--type'))
|
||||
make_file('editable.txt')
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ type Command struct {
|
|||
ArgCompleter CompletionFunc
|
||||
// Stop completion processing at this arg num
|
||||
StopCompletingAtArg int
|
||||
// Consider all args as non-options args
|
||||
OnlyArgsAllowed bool
|
||||
// Specialised arg aprsing
|
||||
ParseArgsForCompletion func(cmd *Command, args []string, completions *Completions)
|
||||
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ func completion_parse_args(cmd *Command, words []string, completions *Completion
|
|||
cmd = sc
|
||||
arg_num = 0
|
||||
completions.CurrentWordIdxInParent = 0
|
||||
only_args_allowed = false
|
||||
only_args_allowed = cmd.OnlyArgsAllowed
|
||||
if cmd.ParseArgsForCompletion != nil {
|
||||
cmd.ParseArgsForCompletion(cmd, words[i+1:], completions)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ func ChainCompleters(completers ...CompletionFunc) CompletionFunc {
|
|||
|
||||
func CompletionForWrapper(wrapped_cmd string) func(completions *Completions, word string, arg_num int) {
|
||||
return func(completions *Completions, word string, arg_num int) {
|
||||
completions.Delegate.NumToRemove = completions.CurrentWordIdx + 1
|
||||
completions.Delegate.NumToRemove = completions.CurrentWordIdx
|
||||
completions.Delegate.Command = wrapped_cmd
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue