From 1b748ed63edd12b0fc6af706678e1ced766b7bdc Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Thu, 30 Nov 2023 11:15:37 -0500 Subject: [PATCH] Improve display of save as --- src/common/document.ts | 2 +- src/common/editor.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/common/document.ts b/src/common/document.ts index 26c9929..9024e64 100644 --- a/src/common/document.ts +++ b/src/common/document.ts @@ -84,7 +84,7 @@ export class Document { } const row = this.row(at.y)!; - const mergeNextRow = at.x === row.size && at.y < len - 1; + const mergeNextRow = at.x === row.size && at.y + 1 < len; const mergeIntoPrevRow = at.x === 0 && at.y > 0; // If we are at the end of a line, and press delete, diff --git a/src/common/editor.ts b/src/common/editor.ts index d5bdbb1..1a2c8a3 100644 --- a/src/common/editor.ts +++ b/src/common/editor.ts @@ -97,8 +97,9 @@ class Editor { public async save(): Promise { if (this.#filename === '') { - const filename = await this.prompt('Save as: '); + const filename = await this.prompt('Save as: %s (ESC to cancel)'); if (filename === null) { + this.setStatusMessage('Save aborted'); return; } @@ -232,7 +233,12 @@ class Editor { let res = ''; outer: while (true) { - this.setStatusMessage(`${p}${res}`); + if (p.includes('%s')) { + this.setStatusMessage(p.replace('%s', res)); + } else { + this.setStatusMessage(`${p}${res}`); + } + await this.refreshScreen(); for await (const chunk of term.inputLoop()) { const char = readKey(chunk);