Skip to content

Commit

Permalink
fix(#99): enable hard wrapping for long words
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Mar 5, 2023
1 parent d20c41f commit c96eda5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/purple-lions-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@clack/core': patch
'@clack/prompts': patch
---

Enable hard line-wrapping behavior for long words without spaces
5 changes: 2 additions & 3 deletions packages/core/src/prompts/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,14 @@ export default class Prompt {
this.unsubscribe();
}

// TODO: handle wrapping
private restoreCursor() {
const lines = wrap(this._prevFrame, process.stdout.columns).split('\n').length - 1;
const lines = wrap(this._prevFrame, process.stdout.columns, { hard: true }).split('\n').length - 1;
this.output.write(cursor.move(-999, lines * -1));
}

private _prevFrame = '';
private render() {
const frame = wrap(this._render(this) ?? '', process.stdout.columns);
const frame = wrap(this._render(this) ?? '', process.stdout.columns, { hard: true });
if (frame === this._prevFrame) return;

if (this.state === 'initial') {
Expand Down

0 comments on commit c96eda5

Please sign in to comment.