Skip to content

Commit

Permalink
Fix Issue heapwolf#25: Inappropriate Redrawn Multi-Line Asks
Browse files Browse the repository at this point in the history
heapwolf#25

Prompts were causing bad user experience in situations where
the prompt contains multiple lines. This is because prompt-sync
will redraw the prompt as you type, and assumes it only takes
up one line.

The fix provided splits the provided ask by newline, prints
all but the last line only once, and assigns the final line
to the ask variable used for the remainder of the module.
  • Loading branch information
axelKingsley committed Mar 14, 2021
1 parent 33a1252 commit 5f0233e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function create(config) {

if (ask) {
process.stdout.write(ask);
ask = ask.split(/\r?\n/).pop();
}

var cycle = 0;
Expand Down

0 comments on commit 5f0233e

Please sign in to comment.