Skip to content

Commit

Permalink
feat(@clack/core): allow tab completion for placeholders (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpreston321 authored Aug 24, 2023
2 parents 7c7fde8 + 4f6fcf5 commit 24a3f4a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-news-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clack/core': patch
---

feat(@clack/core): allow tab completion for placeholders
6 changes: 6 additions & 0 deletions packages/core/src/prompts/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ export default class Prompt {
if (char && (char.toLowerCase() === 'y' || char.toLowerCase() === 'n')) {
this.emit('confirm', char.toLowerCase() === 'y');
}
if (char === '\t' && this.opts.placeholder) {
if (!this.value) {
this.rl.write(this.opts.placeholder);
this.emit('value', this.opts.placeholder);
}
}
if (char) {
this.emit('key', char.toLowerCase());
}
Expand Down

0 comments on commit 24a3f4a

Please sign in to comment.