| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8211904 commit 1c59cef
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -601,6 +601,7 @@ function REPLServer(prompt, | |||
| 601 | 601 | // Wrap readline tty to enable editor mode | |
| 602 | 602 | const ttyWrite = self._ttyWrite.bind(self); | |
| 603 | 603 | self._ttyWrite = (d, key) => { | |
| 604 | + key = key || {}; | ||
| 604 | 605 | if (!self.editorMode || !self.terminal) { | |
| 605 | 606 | ttyWrite(d, key); | |
| 606 | 607 | return; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,16 +8,17 @@ const repl = require('repl'); | |||
| 8 | 8 | // \u001b[0J - Clear screen | |
| 9 | 9 | // \u001b[3G - Moves the cursor to 3rd column | |
| 10 | 10 | const terminalCode = '\u001b[1G\u001b[0J> \u001b[3G'; | |
| 11 | + const terminalCodeRegex = new RegExp(terminalCode.replace(/\[/g, '\\['), 'g'); | ||
| 11 | 12 | ||
| 12 | - function run({input, output, event}) { | ||
| 13 | + function run({input, output, event, checkTerminalCodes = true}) { | ||
| 13 | 14 | const stream = new common.ArrayStream(); | |
| 14 | 15 | let found = ''; | |
| 15 | 16 | ||
| 16 | 17 | stream.write = (msg) => found += msg.replace('\r', ''); | |
| 17 | 18 | ||
| 18 | - const expected = `${terminalCode}.editor\n` + | ||
| 19 | - '// Entering editor mode (^D to finish, ^C to cancel)\n' + | ||
| 20 | - `${input}${output}\n${terminalCode}`; | ||
| 19 | + let expected = `${terminalCode}.editor\n` + | ||
| 20 | + '// Entering editor mode (^D to finish, ^C to cancel)\n' + | ||
| 21 | + `${input}${output}\n${terminalCode}`; | ||
| 21 | 22 | ||
| 22 | 23 | const replServer = repl.start({ | |
| 23 | 24 | prompt: '> ', | |
@@ -31,6 +32,12 @@ function run({input, output, event}) { | |||
| 31 | 32 | stream.emit('data', input); | |
| 32 | 33 | replServer.write('', event); | |
| 33 | 34 | replServer.close(); | |
| 35 | + | ||
| 36 | + if (!checkTerminalCodes) { | ||
| 37 | + found = found.replace(terminalCodeRegex, '').replace(/\n/g, ''); | ||
| 38 | + expected = expected.replace(terminalCodeRegex, '').replace(/\n/g, ''); | ||
| 39 | + } | ||
| 40 | + | ||
| 34 | 41 | assert.strictEqual(found, expected); | |
| 35 | 42 | } | |
| 36 | 43 | ||
@@ -54,6 +61,12 @@ const tests = [ | |||
| 54 | 61 | input: ' var i = 1;\ni + 3', | |
| 55 | 62 | output: '\n4', | |
| 56 | 63 | event: {ctrl: true, name: 'd'} | |
| 64 | + }, | ||
| 65 | + { | ||
| 66 | + input: '', | ||
| 67 | + output: '', | ||
| 68 | + checkTerminalCodes: false, | ||
| 69 | + event: null, | ||
| 57 | 70 | } | |
| 58 | 71 | ]; | |
| 59 | 72 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments