| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4175ea3 commit 8a7c101
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -204,6 +204,7 @@ const domainSet = new SafeWeakSet(); | |||
| 204 | 204 | ||
| 205 | 205 | const kBufferedCommandSymbol = Symbol('bufferedCommand'); | |
| 206 | 206 | const kContextId = Symbol('contextId'); | |
| 207 | + const kLoadingSymbol = Symbol('loading'); | ||
| 207 | 208 | ||
| 208 | 209 | let addedNewListener = false; | |
| 209 | 210 | ||
@@ -882,7 +883,7 @@ function REPLServer(prompt, | |||
| 882 | 883 | self[kBufferedCommandSymbol] += cmd + '\n'; | |
| 883 | 884 | ||
| 884 | 885 | // code alignment | |
| 885 | - const matches = self._sawKeyPress ? | ||
| 886 | + const matches = self._sawKeyPress && !self[kLoadingSymbol] ? | ||
| 886 | 887 | RegExpPrototypeExec(/^\s+/, cmd) : null; | |
| 887 | 888 | if (matches) { | |
| 888 | 889 | const prefix = matches[0]; | |
@@ -1801,8 +1802,10 @@ function defineDefaultCommands(repl) { | |||
| 1801 | 1802 | const stats = fs.statSync(file); | |
| 1802 | 1803 | if (stats && stats.isFile()) { | |
| 1803 | 1804 | _turnOnEditorMode(this); | |
| 1805 | + this[kLoadingSymbol] = true; | ||
| 1804 | 1806 | const data = fs.readFileSync(file, 'utf8'); | |
| 1805 | 1807 | this.write(data); | |
| 1808 | + this[kLoadingSymbol] = false; | ||
| 1806 | 1809 | _turnOffEditorMode(this); | |
| 1807 | 1810 | this.write('\n'); | |
| 1808 | 1811 | } else { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -67,9 +67,14 @@ testMe.complete('inner.o', common.mustSucceed((data) => { | |||
| 67 | 67 | // Clear the REPL. | |
| 68 | 68 | putIn.run(['.clear']); | |
| 69 | 69 | ||
| 70 | + testMe._sawKeyPress = true; | ||
| 70 | 71 | // Load the file back in. | |
| 71 | 72 | putIn.run([`.load ${saveFileName}`]); | |
| 72 | 73 | ||
| 74 | + // Make sure loading doesn't insert extra indentation | ||
| 75 | + // https://github.com/nodejs/node/issues/47673 | ||
| 76 | + assert.strictEqual(testMe.line, ''); | ||
| 77 | + | ||
| 73 | 78 | // Make sure that the REPL data is "correct". | |
| 74 | 79 | testMe.complete('inner.o', common.mustSucceed((data) => { | |
| 75 | 80 | assert.deepStrictEqual(data, works); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments