Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7d70385

Browse files
committedSep 2, 2023
repl: Don't accumulate excess indentation in .load
When using .load the REPL would accumulate indentation with each line including the indentation from all previous lines. Now it keeps the indentation at the correct level. Fixes: nodejs#47673
1 parent 0add7a8 commit 7d70385

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

Diff for: ‎lib/repl.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ function REPLServer(prompt,
882882
self[kBufferedCommandSymbol] += cmd + '\n';
883883

884884
// code alignment
885-
const matches = self._sawKeyPress ?
885+
const matches = self._sawKeyPress && !self._loading ?
886886
RegExpPrototypeExec(/^\s+/, cmd) : null;
887887
if (matches) {
888888
const prefix = matches[0];
@@ -1801,8 +1801,10 @@ function defineDefaultCommands(repl) {
18011801
const stats = fs.statSync(file);
18021802
if (stats && stats.isFile()) {
18031803
_turnOnEditorMode(this);
1804+
this._loading = true;
18041805
const data = fs.readFileSync(file, 'utf8');
18051806
this.write(data);
1807+
this._loading = false;
18061808
_turnOffEditorMode(this);
18071809
this.write('\n');
18081810
} else {

0 commit comments

Comments
 (0)
Please sign in to comment.