diff --git a/lib/repl.js b/lib/repl.js index 2a63050923b198..560bc87afa940b 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -882,7 +882,7 @@ function REPLServer(prompt, self[kBufferedCommandSymbol] += cmd + '\n'; // code alignment - const matches = self._sawKeyPress ? + const matches = self._sawKeyPress && !self._loading ? RegExpPrototypeExec(/^\s+/, cmd) : null; if (matches) { const prefix = matches[0]; @@ -1801,8 +1801,10 @@ function defineDefaultCommands(repl) { const stats = fs.statSync(file); if (stats && stats.isFile()) { _turnOnEditorMode(this); + this._loading = true; const data = fs.readFileSync(file, 'utf8'); this.write(data); + this._loading = false; _turnOffEditorMode(this); this.write('\n'); } else {