summaryrefslogtreecommitdiff
path: root/test/parallel/test-readline-interface.js
diff options
context:
space:
mode:
authorBenoît Zugmeyer <bzugmeyer@gmail.com>2019-06-18 00:34:27 +0200
committerMichaël Zasso <targos@protonmail.com>2019-07-20 11:05:15 +0200
commite6e98afbf272d2480d6bf4aa6dfa2d8e2fdd42ad (patch)
tree0ff0bd512df7eff9e9273f4ba055a4542206c3f1 /test/parallel/test-readline-interface.js
parent6fbad8baa40981b9645be21316b062382b881369 (diff)
downloadandroid-node-v8-e6e98afbf272d2480d6bf4aa6dfa2d8e2fdd42ad.tar.gz
android-node-v8-e6e98afbf272d2480d6bf4aa6dfa2d8e2fdd42ad.tar.bz2
android-node-v8-e6e98afbf272d2480d6bf4aa6dfa2d8e2fdd42ad.zip
readline: fix position computation
The implementation of _getDisplayPos, used to compute the cursor position and to find out how many lines to clear up when re-rendering the readline output, was counting each line (except the last one) from the input as one row, even if they were wraping. This caused some rendering issues when the 'prompt' have at least one wide line ending with a newline char, duplicating the lines at the top of the prompt when calling _refreshLine (ex: when the user hits backspace). This patch fixes the issue by computing the real rows count for each new line in the input string. PR-URL: https://github.com/nodejs/node/pull/28272 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test/parallel/test-readline-interface.js')
-rw-r--r--test/parallel/test-readline-interface.js19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js
index 2dff11f2a2..3f80fd4442 100644
--- a/test/parallel/test-readline-interface.js
+++ b/test/parallel/test-readline-interface.js
@@ -1042,7 +1042,7 @@ function isWarned(emitter) {
rli.close();
}
- // multi-line cursor position
+ // Multi-line input cursor position
{
const fi = new FakeInput();
const rli = new readline.Interface({
@@ -1059,6 +1059,23 @@ function isWarned(emitter) {
rli.close();
}
+ // Multi-line prompt cursor position
+ {
+ const fi = new FakeInput();
+ const rli = new readline.Interface({
+ input: fi,
+ output: fi,
+ prompt: '\nfilledline\nwraping text\n> ',
+ terminal: terminal
+ });
+ fi.columns = 10;
+ fi.emit('data', 't');
+ const cursorPos = rli._getCursorPos();
+ assert.strictEqual(cursorPos.rows, 4);
+ assert.strictEqual(cursorPos.cols, 3);
+ rli.close();
+ }
+
// Clear the whole screen
{
const fi = new FakeInput();