File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,7 @@ const domainSet = new SafeWeakSet();
204204
205205const kBufferedCommandSymbol = Symbol ( 'bufferedCommand' ) ;
206206const kContextId = Symbol ( 'contextId' ) ;
207+ const kLoadingSymbol = Symbol ( 'loading' ) ;
207208
208209let addedNewListener = false ;
209210
@@ -882,7 +883,7 @@ function REPLServer(prompt,
882883 self [ kBufferedCommandSymbol ] += cmd + '\n' ;
883884
884885 // code alignment
885- const matches = self . _sawKeyPress && ! self . _loading ?
886+ const matches = self . _sawKeyPress && ! self [ kLoadingSymbol ] ?
886887 RegExpPrototypeExec ( / ^ \s + / , cmd ) : null ;
887888 if ( matches ) {
888889 const prefix = matches [ 0 ] ;
@@ -1801,10 +1802,10 @@ function defineDefaultCommands(repl) {
18011802 const stats = fs . statSync ( file ) ;
18021803 if ( stats && stats . isFile ( ) ) {
18031804 _turnOnEditorMode ( this ) ;
1804- this . _loading = true ;
1805+ this [ kLoadingSymbol ] = true ;
18051806 const data = fs . readFileSync ( file , 'utf8' ) ;
18061807 this . write ( data ) ;
1807- this . _loading = false ;
1808+ this [ kLoadingSymbol ] = false ;
18081809 _turnOffEditorMode ( this ) ;
18091810 this . write ( '\n' ) ;
18101811 } else {
Original file line number Diff line number Diff line change @@ -67,9 +67,14 @@ testMe.complete('inner.o', common.mustSucceed((data) => {
6767// Clear the REPL.
6868putIn . run ( [ '.clear' ] ) ;
6969
70+ testMe . _sawKeyPress = true ;
7071// Load the file back in.
7172putIn . run ( [ `.load ${ saveFileName } ` ] ) ;
7273
74+ // Make sure loading doesn't insert extra indentation
75+ // https://github.com/nodejs/node/issues/47673
76+ assert . equal ( testMe . line , '' )
77+
7378// Make sure that the REPL data is "correct".
7479testMe . complete ( 'inner.o' , common . mustSucceed ( ( data ) => {
7580 assert . deepStrictEqual ( data , works ) ;
You can’t perform that action at this time.
0 commit comments