| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -363,7 +363,7 @@ function setupPreview(repl, contextSymbol, bufferSymbol, active) { | |||
| 363 | 363 | }, () => callback(new ERR_INSPECTOR_NOT_AVAILABLE())); | |
| 364 | 364 | } | |
| 365 | 365 | ||
| 366 | - const showPreview = () => { | ||
| 366 | + const showPreview = (showCompletion = true) => { | ||
| 367 | 367 | // Prevent duplicated previews after a refresh. | |
| 368 | 368 | if (inputPreview !== null || !repl.isCompletionEnabled) { | |
| 369 | 369 | return; | |
@@ -379,8 +379,10 @@ function setupPreview(repl, contextSymbol, bufferSymbol, active) { | |||
| 379 | 379 | hasCompletions = false; | |
| 380 | 380 | ||
| 381 | 381 | // Add the autocompletion preview. | |
| 382 | - const insertPreview = false; | ||
| 383 | - showCompletionPreview(repl.line, insertPreview); | ||
| 382 | + if (showCompletion) { | ||
| 383 | + const insertPreview = false; | ||
| 384 | + showCompletionPreview(repl.line, insertPreview); | ||
| 385 | + } | ||
| 384 | 386 | ||
| 385 | 387 | // Do not preview if the command is buffered. | |
| 386 | 388 | if (repl[bufferSymbol]) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -993,9 +993,8 @@ function REPLServer(prompt, | |||
| 993 | 993 | clearPreview(key); | |
| 994 | 994 | if (!reverseSearch(d, key)) { | |
| 995 | 995 | ttyWrite(d, key); | |
| 996 | - if (key.name !== 'escape') { | ||
| 997 | - showPreview(); | ||
| 998 | - } | ||
| 996 | + const showCompletionPreview = key.name !== 'escape'; | ||
| 997 | + showPreview(showCompletionPreview); | ||
| 999 | 998 | } | |
| 1000 | 999 | return; | |
| 1001 | 1000 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -614,6 +614,24 @@ const tests = [ | |||
| 614 | 614 | ], | |
| 615 | 615 | clean: false | |
| 616 | 616 | }, | |
| 617 | + { | ||
| 618 | + // Test that preview should not be removed when pressing ESCAPE key | ||
| 619 | + env: { NODE_REPL_HISTORY: defaultHistoryPath }, | ||
| 620 | + skip: !process.features.inspector, | ||
| 621 | + test: [ | ||
| 622 | + '1+1', | ||
| 623 | + ESCAPE, | ||
| 624 | + ENTER, | ||
| 625 | + ], | ||
| 626 | + expected: [ | ||
| 627 | + prompt, ...'1+1', | ||
| 628 | + '\n// 2', | ||
| 629 | + '\n// 2', | ||
| 630 | + '2\n', | ||
| 631 | + prompt, | ||
| 632 | + ], | ||
| 633 | + clean: false | ||
| 634 | + }, | ||
| 617 | 635 | ]; | |
| 618 | 636 | const numtests = tests.length; | |
| 619 | 637 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments