mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
Pasting input should not trigger any completions and other calculations. This is now handled by just writing the string to the terminal in case the user is pasting. As soon as pasting is done, the completions will be re-enabled. Fixes: https://github.com/nodejs/node/issues/40626 Fixes: https://github.com/nodejs/node/issues/43343 PR-URL: https://github.com/nodejs/node/pull/59857 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
37 lines
792 B
JavaScript
37 lines
792 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const repl = require('repl');
|
|
const stream = require('stream');
|
|
const assert = require('assert');
|
|
|
|
// Pasting big input should not cause the process to have a huge CPU usage.
|
|
|
|
const cpuUsage = process.cpuUsage();
|
|
|
|
const r = initRepl();
|
|
r.input.emit('data', 'a'.repeat(2e4) + '\n');
|
|
r.input.emit('data', '.exit\n');
|
|
|
|
r.once('exit', common.mustCall(() => {
|
|
const diff = process.cpuUsage(cpuUsage);
|
|
assert.ok(diff.user < 1e6);
|
|
}));
|
|
|
|
function initRepl() {
|
|
const input = new stream();
|
|
input.write = input.pause = input.resume = () => {};
|
|
input.readable = true;
|
|
|
|
const output = new stream();
|
|
output.write = () => {};
|
|
output.writable = true;
|
|
|
|
return repl.start({
|
|
input,
|
|
output,
|
|
terminal: true,
|
|
prompt: ''
|
|
});
|
|
}
|