Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/debug/browser/debugConsoleQuickAccess.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
import { CancellationToken } from '../../../../base/common/cancellation.js';
6
import { matchesFuzzy } from '../../../../base/common/filters.js';
7
import { DisposableStore } from '../../../../base/common/lifecycle.js';
8
import { localize } from '../../../../nls.js';
9
import { ICommandService } from '../../../../platform/commands/common/commands.js';
10
import { FastAndSlowPicks, IPickerQuickAccessItem, PickerQuickAccessProvider, Picks } from '../../../../platform/quickinput/browser/pickerQuickAccess.js';
11
import { IQuickPickSeparator } from '../../../../platform/quickinput/common/quickInput.js';
12
import { IViewsService } from '../../../services/views/common/viewsService.js';
13
import { DEBUG_CONSOLE_QUICK_ACCESS_PREFIX, SELECT_AND_START_ID } from './debugCommands.js';
14
import { IDebugService, IDebugSession, REPL_VIEW_ID } from '../common/debug.js';
15
16
export class DebugConsoleQuickAccess extends PickerQuickAccessProvider<IPickerQuickAccessItem> {
17
18
constructor(
19
@IDebugService private readonly _debugService: IDebugService,
20
@IViewsService private readonly _viewsService: IViewsService,
21
@ICommandService private readonly _commandService: ICommandService,
22
) {
23
super(DEBUG_CONSOLE_QUICK_ACCESS_PREFIX, { canAcceptInBackground: true });
24
}
25
26
protected _getPicks(filter: string, disposables: DisposableStore, token: CancellationToken): Picks<IPickerQuickAccessItem> | Promise<Picks<IPickerQuickAccessItem>> | FastAndSlowPicks<IPickerQuickAccessItem> | null {
27
const debugConsolePicks: Array<IPickerQuickAccessItem | IQuickPickSeparator> = [];
28
29
this._debugService.getModel().getSessions(true).filter(s => s.hasSeparateRepl()).forEach((session, index) => {
30
const pick = this._createPick(session, index, filter);
31
if (pick) {
32
debugConsolePicks.push(pick);
33
}
34
});
35
36
37
if (debugConsolePicks.length > 0) {
38
debugConsolePicks.push({ type: 'separator' });
39
}
40
41
const createTerminalLabel = localize("workbench.action.debug.startDebug", "Start a New Debug Session");
42
debugConsolePicks.push({
43
label: `$(plus) ${createTerminalLabel}`,
44
ariaLabel: createTerminalLabel,
45
accept: () => this._commandService.executeCommand(SELECT_AND_START_ID)
46
});
47
return debugConsolePicks;
48
}
49
50
private _createPick(session: IDebugSession, sessionIndex: number, filter: string): IPickerQuickAccessItem | undefined {
51
const label = session.name;
52
53
const highlights = matchesFuzzy(filter, label, true);
54
if (highlights) {
55
return {
56
label,
57
highlights: { label: highlights },
58
accept: (keyMod, event) => {
59
this._debugService.focusStackFrame(undefined, undefined, session, { explicit: true });
60
if (!this._viewsService.isViewVisible(REPL_VIEW_ID)) {
61
this._viewsService.openView(REPL_VIEW_ID, true);
62
}
63
}
64
};
65
}
66
return undefined;
67
}
68
}
69
70