Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow to access output of default completion in custom completion #1878

Merged
merged 2 commits into from Feb 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/completion.ts
Expand Up @@ -193,7 +193,8 @@ export class Completion implements CompletionInstance {
return (this.customCompletionFunction as FallbackCompletionFunction)(
current,
argv,
() => this.defaultCompletion(args, argv, current, done),
(onCompleted = done) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a test:

it('allows custom completion to be combined with default completion, using filter').

this.defaultCompletion(args, argv, current, onCompleted),
completions => {
done(null, completions);
}
Expand Down Expand Up @@ -278,7 +279,7 @@ interface FallbackCompletionFunction {
(
current: string,
argv: Arguments,
defaultCompletion: () => any,
defaultCompletion: (onCompleted?: CompletionCallback) => any,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be tempted to call this completionFilter.

done: (completions: string[]) => any
): any;
}
Expand Down