MCPcopy
hub / github.com/microsoft/vscode-js-debug / LongPredictionUI

Class LongPredictionUI

src/ui/longPredictionUI.ts:14–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12
13@injectable()
14export class LongPredictionUI implements IExtensionContribution {
15 constructor(@inject(ExtensionContext) private readonly context: vscode.ExtensionContext) {}
16
17 /**
18 * Registers the link UI for the extension.
19 */
20 public register(context: vscode.ExtensionContext) {
21 context.subscriptions.push(
22 vscode.debug.onDidReceiveDebugSessionCustomEvent(event => {
23 if (event.event === 'longPrediction') {
24 this.promptLongBreakpoint(event.session.workspaceFolder);
25 }
26 }),
27 );
28 }
29 private async promptLongBreakpoint(workspaceFolder?: vscode.WorkspaceFolder) {
30 if (this.context.workspaceState.get(omitLongPredictionKey)) {
31 return;
32 }
33
34 const message = l10n.t(
35 "It's taking a while to configure your breakpoints. You can speed this up by updating the 'outFiles' in your launch.json.",
36 );
37 const openLaunch = l10n.t('Open launch.json');
38 const dontShow = l10n.t("Don't show again");
39 const result = await vscode.window.showWarningMessage(message, dontShow, openLaunch);
40
41 if (result === dontShow) {
42 this.context.workspaceState.update(omitLongPredictionKey, true);
43 return;
44 }
45
46 if (result !== openLaunch) {
47 return;
48 }
49
50 if (!workspaceFolder) {
51 workspaceFolder = await vscode.window.showWorkspaceFolderPick();
52 }
53
54 if (!workspaceFolder) {
55 await vscode.window.showWarningMessage(l10n.t('No workspace folder open.'));
56 return;
57 }
58
59 const doc = await vscode.workspace.openTextDocument(
60 join(workspaceFolder.uri.fsPath, '.vscode', 'launch.json'),
61 );
62 await vscode.window.showTextDocument(doc);
63 }
64}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected