@@ -28,6 +28,10 @@ const {
2828 ERR_INSPECTOR_NOT_AVAILABLE ,
2929} = require ( 'internal/errors' ) . codes ;
3030
31+ const {
32+ kIsMultiline,
33+ } = require ( 'internal/readline/interface' ) ;
34+
3135const {
3236 clearLine,
3337 clearScreenDown,
@@ -159,8 +163,6 @@ function setupPreview(repl, contextSymbol, bufferSymbol, active) {
159163
160164 let escaped = null ;
161165
162- let justExecutedMultilineCommand = false ;
163-
164166 function getPreviewPos ( ) {
165167 const displayPos = repl . _getDisplayPos ( `${ repl . getPrompt ( ) } ${ repl . line } ` ) ;
166168 const cursorPos = repl . line . length !== repl . cursor ?
@@ -183,11 +185,6 @@ function setupPreview(repl, contextSymbol, bufferSymbol, active) {
183185 clearLine ( repl . output ) ;
184186 moveCursor ( repl . output , 0 , - rows ) ;
185187 inputPreview = null ;
186- // If pressing enter on some history line,
187- // The next preview should not be generated
188- if ( ( key . name === 'return' || key . name === 'enter' ) && ! key . meta && repl . historyIndex !== - 1 ) {
189- justExecutedMultilineCommand = true ;
190- }
191188 }
192189 if ( completionPreview !== null ) {
193190 // Prevent cursor moves if not necessary!
@@ -372,8 +369,11 @@ function setupPreview(repl, contextSymbol, bufferSymbol, active) {
372369 }
373370
374371 const showPreview = ( showCompletion = true ) => {
375- // Prevent duplicated previews after a refresh.
376- if ( inputPreview !== null || ! repl . isCompletionEnabled || ! process . features . inspector ) {
372+ // Prevent duplicated previews after a refresh or in a multiline command.
373+ if ( inputPreview !== null ||
374+ repl [ kIsMultiline ] ||
375+ ! repl . isCompletionEnabled ||
376+ ! process . features . inspector ) {
377377 return ;
378378 }
379379
@@ -384,11 +384,6 @@ function setupPreview(repl, contextSymbol, bufferSymbol, active) {
384384 return ;
385385 }
386386
387- if ( justExecutedMultilineCommand ) {
388- justExecutedMultilineCommand = false ;
389- return ;
390- }
391-
392387 hasCompletions = false ;
393388
394389 // Add the autocompletion preview.
0 commit comments