mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
repl: fix pasting after moving the cursor to the left
Fixes: https://github.com/nodejs/node/issues/60446 PR-URL: https://github.com/nodejs/node/pull/60470 Reviewed-By: Jordan Harband <ljharb@gmail.com>
This commit is contained in:
1 parent
2c651c90cf
commit
07ec1239ef
2 files changed
+16
-1
No files matched your search
@@ -659,7 +659,17 @@ class Interface extends InterfaceConstructor {
|
||||
[kInsertString](c) {
|
||||
this[kBeforeEdit](this.line, this.cursor);
|
||||
if (!this.isCompletionEnabled) {
|
||||
this.line += c;
|
||||
if (this.cursor < this.line.length) {
|
||||
const beg = StringPrototypeSlice(this.line, 0, this.cursor);
|
||||
const end = StringPrototypeSlice(
|
||||
this.line,
|
||||
this.cursor,
|
||||
this.line.length,
|
||||
);
|
||||
this.line = beg + c + end;
|
||||
} else {
|
||||
this.line += c;
|
||||
}
|
||||
this.cursor += c.length;
|
||||
this[kWriteToOutput](c);
|
||||
return;
|
||||
|
||||
@@ -9,6 +9,11 @@ const { startNewREPLServer } = require('../common/repl');
|
||||
const cpuUsage = process.cpuUsage();
|
||||
|
||||
const { replServer } = startNewREPLServer({}, { disableDomainErrorAssert: true });
|
||||
replServer.input.emit('data', '{}');
|
||||
replServer.input.emit('keypress', '', { name: 'left' });
|
||||
replServer.input.emit('data', 'node');
|
||||
assert.strictEqual(replServer.line, '{node}');
|
||||
|
||||
replServer.input.emit('data', 'a'.repeat(2e4) + '\n');
|
||||
replServer.input.emit('data', '.exit\n');
|
||||
|
||||
|
||||
Reference in new issue
Block a user