repl: don’t write to input stream in editor mode
Instead of writing to the REPL’s input stream for the alignment spaces in `.editor` mode, let `readline` handle the spaces properly (echoing them using `_ttyWrite` and adding them to the current line buffer). Fixes: https://github.com/nodejs/node/issues/9189 PR-URL: https://github.com/nodejs/node/pull/9207 Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
8b6fd4386a
commit
3dfc12793f
@ -476,7 +476,7 @@ function REPLServer(prompt,
|
|||||||
const matches = self._sawKeyPress ? cmd.match(/^\s+/) : null;
|
const matches = self._sawKeyPress ? cmd.match(/^\s+/) : null;
|
||||||
if (matches) {
|
if (matches) {
|
||||||
const prefix = matches[0];
|
const prefix = matches[0];
|
||||||
self.inputStream.write(prefix);
|
self.write(prefix);
|
||||||
self.line = prefix;
|
self.line = prefix;
|
||||||
self.cursor = prefix.length;
|
self.cursor = prefix.length;
|
||||||
}
|
}
|
||||||
|
@ -75,12 +75,15 @@ tests.forEach(run);
|
|||||||
// Auto code alignment for .editor mode
|
// Auto code alignment for .editor mode
|
||||||
function testCodeAligment({input, cursor = 0, line = ''}) {
|
function testCodeAligment({input, cursor = 0, line = ''}) {
|
||||||
const stream = new common.ArrayStream();
|
const stream = new common.ArrayStream();
|
||||||
|
const outputStream = new common.ArrayStream();
|
||||||
|
|
||||||
|
stream.write = () => { throw new Error('Writing not allowed!'); };
|
||||||
|
|
||||||
const replServer = repl.start({
|
const replServer = repl.start({
|
||||||
prompt: '> ',
|
prompt: '> ',
|
||||||
terminal: true,
|
terminal: true,
|
||||||
input: stream,
|
input: stream,
|
||||||
output: stream,
|
output: outputStream,
|
||||||
useColors: false
|
useColors: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user