Skip to content

Commit

Permalink
fix(completions): escape colon in completion choices
Browse files Browse the repository at this point in the history
This is similar to the code in `completeOptionKey`
  • Loading branch information
alan-agius4 committed Mar 21, 2022
1 parent b4c4bf6 commit 904772c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/completion.ts
Expand Up @@ -147,7 +147,7 @@ export class Completion implements CompletionInstance {
if (this.previousArgHasChoices(args)) {
const choices = this.getPreviousArgChoices(args);
if (choices && choices.length > 0) {
completions.push(...choices);
completions.push(...choices.map(c => c.replace(/:/g, '\\:')));
}
}
}
Expand Down Expand Up @@ -182,7 +182,7 @@ export class Completion implements CompletionInstance {
const choices = this.yargs.getOptions().choices[positionalKey] || [];
for (const choice of choices) {
if (choice.startsWith(current)) {
completions.push(choice);
completions.push(choice.replace(/:/g, '\\:'));
}
}
}
Expand Down

0 comments on commit 904772c

Please sign in to comment.