11import { Disposable , TerminalShellExecutionStartEvent } from 'vscode' ;
2- import { onDidStartTerminalShellExecution } from '../../common/vscodeApis/windowApis' ;
2+ import { onDidStartTerminalShellExecution , showWarningMessage } from '../../common/vscodeApis/windowApis' ;
33import { sendTelemetryEvent } from '../../telemetry' ;
44import { EventName } from '../../telemetry/constants' ;
55import { ICommandManager } from '../../common/application/types' ;
66import { Commands } from '../../common/constants' ;
7+ import { Common , Repl } from '../../common/utils/localize' ;
8+ import { IExtensionContext } from '../../common/types' ;
9+ import { getGlobalStorage } from '../../common/persistentState' ;
10+
11+ export const SUGGEST_NATIVE_REPL = 'suggestNativeRepl' ;
712
813export function checkREPLCommand ( command : string ) : boolean {
914 const lower = command . toLowerCase ( ) . trimStart ( ) ;
@@ -12,19 +17,33 @@ export function checkREPLCommand(command: string): boolean {
1217
1318export async function registerTriggerForTerminalREPL (
1419 commandManager : ICommandManager ,
20+ context : IExtensionContext ,
1521 disposables : Disposable [ ] ,
1622) : Promise < void > {
1723 disposables . push (
1824 onDidStartTerminalShellExecution ( async ( e : TerminalShellExecutionStartEvent ) => {
1925 if ( e . execution . commandLine . isTrusted && checkREPLCommand ( e . execution . commandLine . value ) ) {
2026 sendTelemetryEvent ( EventName . REPL , undefined , { replType : 'manualTerminal' } ) ;
21- // TODO: Prompt user to start Native REPL
2227
23- // If yes, then launch native REPL
24- await commandManager . executeCommand ( Commands . Start_Native_REPL , undefined ) ;
28+ // Plan:
29+ // Global memento to disable show of prompt entirely - global memento
30+ // workspace memento to track and only show suggest of native REPL once.
31+ const globalSuggestNativeRepl = getGlobalStorage < boolean > ( context , SUGGEST_NATIVE_REPL ) ;
32+ if ( globalSuggestNativeRepl . get ( ) ) {
33+ // Prompt user to start Native REPL
34+ const selection = await showWarningMessage (
35+ Repl . terminalSuggestNativeReplPrompt ,
36+ 'Launch Native REPL' ,
37+ Common . doNotShowAgain ,
38+ ) ;
2539
26- // TODO: Decide whether we want everytime, or once per workspace, or once per terminal
27- // How do I even track all terminal instances.
40+ if ( selection === 'Launch Native REPL' ) {
41+ await commandManager . executeCommand ( Commands . Start_Native_REPL , undefined ) ;
42+ } else {
43+ // Update global suggest to disable Native REPL suggestion in future even after reload.
44+ await globalSuggestNativeRepl . set ( false ) ;
45+ }
46+ }
2847 }
2948 } ) ,
3049 ) ;
0 commit comments