| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 026d4e3 commit 0f46c1c
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -658,6 +658,12 @@ class Interface extends InterfaceConstructor { | |||
| 658 | 658 | ||
| 659 | 659 | [kInsertString](c) { | |
| 660 | 660 | this[kBeforeEdit](this.line, this.cursor); | |
| 661 | + if (!this.isCompletionEnabled) { | ||
| 662 | + this.line += c; | ||
| 663 | + this.cursor += c.length; | ||
| 664 | + this[kWriteToOutput](c); | ||
| 665 | + return; | ||
| 666 | + } | ||
| 661 | 667 | if (this.cursor < this.line.length) { | |
| 662 | 668 | const beg = StringPrototypeSlice(this.line, 0, this.cursor); | |
| 663 | 669 | const end = StringPrototypeSlice( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,36 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const repl = require('repl'); | ||
| 5 | + const stream = require('stream'); | ||
| 6 | + const assert = require('assert'); | ||
| 7 | + | ||
| 8 | + // Pasting big input should not cause the process to have a huge CPU usage. | ||
| 9 | + | ||
| 10 | + const cpuUsage = process.cpuUsage(); | ||
| 11 | + | ||
| 12 | + const r = initRepl(); | ||
| 13 | + r.input.emit('data', 'a'.repeat(2e4) + '\n'); | ||
| 14 | + r.input.emit('data', '.exit\n'); | ||
| 15 | + | ||
| 16 | + r.once('exit', common.mustCall(() => { | ||
| 17 | + const diff = process.cpuUsage(cpuUsage); | ||
| 18 | + assert.ok(diff.user < 1e6); | ||
| 19 | + })); | ||
| 20 | + | ||
| 21 | + function initRepl() { | ||
| 22 | + const input = new stream(); | ||
| 23 | + input.write = input.pause = input.resume = () => {}; | ||
| 24 | + input.readable = true; | ||
| 25 | + | ||
| 26 | + const output = new stream(); | ||
| 27 | + output.write = () => {}; | ||
| 28 | + output.writable = true; | ||
| 29 | + | ||
| 30 | + return repl.start({ | ||
| 31 | + input, | ||
| 32 | + output, | ||
| 33 | + terminal: true, | ||
| 34 | + prompt: '' | ||
| 35 | + }); | ||
| 36 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments