Skip to content

Commit 09c6052

Browse files
committed
add global native repl suggestion tracker. TODO: workspace tracker
1 parent 0a6ab08 commit 09c6052

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

src/client/extensionActivation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export function activateFeatures(ext: ExtensionState, _components: Components):
111111
);
112112
const executionHelper = ext.legacyIOC.serviceContainer.get<ICodeExecutionHelper>(ICodeExecutionHelper);
113113
const commandManager = ext.legacyIOC.serviceContainer.get<ICommandManager>(ICommandManager);
114-
registerTriggerForTerminalREPL(commandManager, ext.disposables);
114+
registerTriggerForTerminalREPL(commandManager, ext.context, ext.disposables);
115115
registerStartNativeReplCommand(ext.disposables, interpreterService);
116116
registerReplCommands(ext.disposables, interpreterService, executionHelper, commandManager);
117117
registerReplExecuteOnEnter(ext.disposables, interpreterService, commandManager);

src/client/terminals/codeExecution/terminalReplWatcher.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { Disposable, TerminalShellExecutionStartEvent } from 'vscode';
2-
import { onDidStartTerminalShellExecution } from '../../common/vscodeApis/windowApis';
2+
import { onDidStartTerminalShellExecution, showWarningMessage } from '../../common/vscodeApis/windowApis';
33
import { sendTelemetryEvent } from '../../telemetry';
44
import { EventName } from '../../telemetry/constants';
55
import { ICommandManager } from '../../common/application/types';
66
import { 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

813
export function checkREPLCommand(command: string): boolean {
914
const lower = command.toLowerCase().trimStart();
@@ -12,19 +17,33 @@ export function checkREPLCommand(command: string): boolean {
1217

1318
export 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

Comments
 (0)