-
Notifications
You must be signed in to change notification settings - Fork 28.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #151771
- Loading branch information
Showing
3 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/vs/workbench/contrib/debug/browser/debugConsoleQuickAccess.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import { CancellationToken } from 'vs/base/common/cancellation'; | ||
import { Codicon } from 'vs/base/common/codicons'; | ||
import { matchesFuzzy } from 'vs/base/common/filters'; | ||
import { DisposableStore } from 'vs/base/common/lifecycle'; | ||
import { localize } from 'vs/nls'; | ||
import { FastAndSlowPicks, IPickerQuickAccessItem, PickerQuickAccessProvider, Picks } from 'vs/platform/quickinput/browser/pickerQuickAccess'; | ||
import { IQuickInputService, IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput'; | ||
import { IViewsService } from 'vs/workbench/common/views'; | ||
import { StartDebugQuickAccessProvider } from 'vs/workbench/contrib/debug/browser/debugQuickAccess'; | ||
import { getStateLabel, IDebugService, IDebugSession, REPL_VIEW_ID } from 'vs/workbench/contrib/debug/common/debug'; | ||
|
||
export class DebugConsoleQuickAccess extends PickerQuickAccessProvider<IPickerQuickAccessItem> { | ||
protected _getPicks(filter: string, disposables: DisposableStore, token: CancellationToken): Picks<IPickerQuickAccessItem> | Promise<Picks<IPickerQuickAccessItem>> | FastAndSlowPicks<IPickerQuickAccessItem> | null { | ||
const debugConsolePicks: Array<IPickerQuickAccessItem | IQuickPickSeparator> = []; | ||
|
||
this._debugService.getModel().getSessions(true).filter(s => s.hasSeparateRepl()).forEach((session, index) => { | ||
const pick = this._createPick(session, index, filter); | ||
if (pick) { | ||
debugConsolePicks.push(pick); | ||
} | ||
}); | ||
|
||
|
||
if (debugConsolePicks.length > 0) { | ||
debugConsolePicks.push({ type: 'separator' }); | ||
} | ||
|
||
const createTerminalLabel = localize("workbench.action.debug.startDebug", "Start a New Debug Session"); | ||
debugConsolePicks.push({ | ||
label: `$(plus) ${createTerminalLabel}`, | ||
ariaLabel: createTerminalLabel, | ||
accept: () => | ||
this._quickInputService.quickAccess.show(StartDebugQuickAccessProvider.PREFIX) | ||
}); | ||
return debugConsolePicks; | ||
} | ||
|
||
static PREFIX = 'debugcons '; | ||
|
||
constructor( | ||
@IDebugService private readonly _debugService: IDebugService, | ||
@IViewsService private readonly _viewsService: IViewsService, | ||
@IQuickInputService private readonly _quickInputService: IQuickInputService | ||
) { | ||
super(DebugConsoleQuickAccess.PREFIX, { canAcceptInBackground: true }); | ||
} | ||
|
||
private _createPick(session: IDebugSession, sessionIndex: number, filter: string): IPickerQuickAccessItem | undefined { | ||
const iconId = Codicon.debug.id; | ||
const label = `$(${iconId}) ${sessionIndex + 1}: ${session.name}`; | ||
|
||
const highlights = matchesFuzzy(filter, label, true); | ||
if (highlights) { | ||
return { | ||
label, | ||
description: getStateLabel(session.state), | ||
highlights: { label: highlights }, | ||
accept: (keyMod, event) => { | ||
this._debugService.focusStackFrame(undefined, undefined, session, { explicit: true }); | ||
if (!this._viewsService.isViewVisible(REPL_VIEW_ID)) { | ||
this._viewsService.openView(REPL_VIEW_ID, true); | ||
} | ||
} | ||
}; | ||
} | ||
return undefined; | ||
} | ||
} |