diff --git a/lib/repl.js b/lib/repl.js index e57b23946bb528..1d678e67114c09 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -471,6 +471,7 @@ function REPLServer(prompt, if (self.editorMode) { self.bufferedCommand += cmd + '\n'; + self.memory(cmd); return; } diff --git a/test/parallel/test-repl-.save.load.js b/test/parallel/test-repl-.save.load.js index b9c5bc88afa842..247f359e829d25 100644 --- a/test/parallel/test-repl-.save.load.js +++ b/test/parallel/test-repl-.save.load.js @@ -29,6 +29,26 @@ putIn.run(['.save ' + saveFileName]); // the file should have what I wrote assert.equal(fs.readFileSync(saveFileName, 'utf8'), testFile.join('\n') + '\n'); +{ + // save .editor mode code + const cmds = [ + 'function testSave() {', + 'return "saved";', + '}' + ]; + const putIn = new common.ArrayStream(); + const replServer = repl.start('', putIn); + + putIn.run(['.editor']); + putIn.run(cmds); + replServer.write('', {ctrl: true, name: 'd'}); + + putIn.run([`.save ${saveFileName}`]); + replServer.close(); + assert.strictEqual(fs.readFileSync(saveFileName, 'utf8'), + `${cmds.join('\n')}\n`); +} + // make sure that the REPL data is "correct" // so when I load it back I know I'm good testMe.complete('inner.o', function(error, data) {