mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 21:52:24 +00:00
Make DebugSession.name writable; fixes #79583
This commit is contained in:
parent
7e5adb5dae
commit
cb6b17d6f3
10 changed files with 82 additions and 17 deletions
5
src/vs/vscode.d.ts
vendored
5
src/vs/vscode.d.ts
vendored
|
@ -8687,9 +8687,10 @@ declare module 'vscode' {
|
|||
readonly type: string;
|
||||
|
||||
/**
|
||||
* The debug session's name from the [debug configuration](#DebugConfiguration).
|
||||
* The debug session's name is initially taken from the [debug configuration](#DebugConfiguration).
|
||||
* Any changes will be properly reflected in the UI.
|
||||
*/
|
||||
readonly name: string;
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* The workspace folder of this session or `undefined` for a folderless setup.
|
||||
|
|
|
@ -35,6 +35,9 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
|
|||
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostDebugService);
|
||||
this._toDispose.add(debugService.onDidNewSession(session => {
|
||||
this._proxy.$acceptDebugSessionStarted(this.getSessionDto(session));
|
||||
this._toDispose.add(session.onDidChangeName(name => {
|
||||
this._proxy.$acceptDebugSessionNameChanged(this.getSessionDto(session), name);
|
||||
}));
|
||||
}));
|
||||
// Need to start listening early to new session events because a custom event can come while a session is initialising
|
||||
this._toDispose.add(debugService.onWillNewSession(session => {
|
||||
|
@ -225,6 +228,13 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
|
|||
});
|
||||
}
|
||||
|
||||
public $setDebugSessionName(sessionId: DebugSessionUUID, name: string): void {
|
||||
const session = this.debugService.getModel().getSession(sessionId);
|
||||
if (session) {
|
||||
session.setName(name);
|
||||
}
|
||||
}
|
||||
|
||||
public $customDebugAdapterRequest(sessionId: DebugSessionUUID, request: string, args: any): Promise<any> {
|
||||
const session = this.debugService.getModel().getSession(sessionId, true);
|
||||
if (session) {
|
||||
|
|
|
@ -717,6 +717,7 @@ export interface MainThreadDebugServiceShape extends IDisposable {
|
|||
$unregisterDebugConfigurationProvider(handle: number): void;
|
||||
$unregisterDebugAdapterDescriptorFactory(handle: number): void;
|
||||
$startDebugging(folder: UriComponents | undefined, nameOrConfig: string | IDebugConfiguration, parentSessionID: string | undefined): Promise<boolean>;
|
||||
$setDebugSessionName(id: DebugSessionUUID, name: string): void;
|
||||
$customDebugAdapterRequest(id: DebugSessionUUID, command: string, args: any): Promise<any>;
|
||||
$appendDebugConsole(value: string): void;
|
||||
$startBreakpointEvents(): void;
|
||||
|
@ -1263,6 +1264,7 @@ export interface ExtHostDebugServiceShape {
|
|||
$acceptDebugSessionActiveChanged(session: IDebugSessionDto | undefined): void;
|
||||
$acceptDebugSessionCustomEvent(session: IDebugSessionDto, event: any): void;
|
||||
$acceptBreakpointsDelta(delta: IBreakpointsDeltaDto): void;
|
||||
$acceptDebugSessionNameChanged(session: IDebugSessionDto, name: string): void;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -687,6 +687,13 @@ export class ExtHostDebugService implements IExtHostDebugService, ExtHostDebugSe
|
|||
this._onDidChangeActiveDebugSession.fire(this._activeDebugSession);
|
||||
}
|
||||
|
||||
public async $acceptDebugSessionNameChanged(sessionDto: IDebugSessionDto, name: string): Promise<void> {
|
||||
const session = await this.getSession(sessionDto);
|
||||
if (session) {
|
||||
session._acceptNameChanged(name);
|
||||
}
|
||||
}
|
||||
|
||||
public async $acceptDebugSessionCustomEvent(sessionDto: IDebugSessionDto, event: any): Promise<void> {
|
||||
const session = await this.getSession(sessionDto);
|
||||
const ee: vscode.DebugSessionCustomEvent = {
|
||||
|
@ -917,6 +924,15 @@ export class ExtHostDebugSession implements vscode.DebugSession {
|
|||
return this._name;
|
||||
}
|
||||
|
||||
public set name(name: string) {
|
||||
this._name = name;
|
||||
this._debugServiceProxy.$setDebugSessionName(this._id, name);
|
||||
}
|
||||
|
||||
_acceptNameChanged(name: string) {
|
||||
this._name = name;
|
||||
}
|
||||
|
||||
public get workspaceFolder(): vscode.WorkspaceFolder | undefined {
|
||||
return this._workspaceFolder;
|
||||
}
|
||||
|
|
|
@ -227,6 +227,7 @@ export class CallStackView extends ViewletPanel {
|
|||
}));
|
||||
|
||||
this._register(this.debugService.onDidNewSession(s => {
|
||||
this._register(s.onDidChangeName(() => this.tree.rerender(s)));
|
||||
if (s.parentSession) {
|
||||
// Auto expand sessions that have sub sessions
|
||||
this.parentSessionToExpand.add(s.parentSession);
|
||||
|
|
|
@ -209,7 +209,13 @@ export class FocusSessionActionViewItem extends SelectActionViewItem {
|
|||
}
|
||||
}));
|
||||
|
||||
this._register(this.debugService.onDidNewSession(() => this.update()));
|
||||
this._register(this.debugService.onDidNewSession(session => {
|
||||
this._register(session.onDidChangeName(() => this.update()));
|
||||
this.update();
|
||||
}));
|
||||
this.getSessions().forEach(session => {
|
||||
this._register(session.onDidChangeName(() => this.update()));
|
||||
});
|
||||
this._register(this.debugService.onDidEndSession(() => this.update()));
|
||||
|
||||
this.update();
|
||||
|
|
|
@ -55,6 +55,9 @@ export class DebugSession implements IDebugSession {
|
|||
|
||||
private readonly _onDidChangeREPLElements = new Emitter<void>();
|
||||
|
||||
private name: string | undefined;
|
||||
private readonly _onDidChangeName = new Emitter<string>();
|
||||
|
||||
constructor(
|
||||
private _configuration: { resolved: IConfig, unresolved: IConfig | undefined },
|
||||
public root: IWorkspaceFolder,
|
||||
|
@ -105,7 +108,13 @@ export class DebugSession implements IDebugSession {
|
|||
|
||||
getLabel(): string {
|
||||
const includeRoot = this.workspaceContextService.getWorkspace().folders.length > 1;
|
||||
return includeRoot && this.root ? `${this.configuration.name} (${resources.basenameOrAuthority(this.root.uri)})` : this.configuration.name;
|
||||
const name = this.name || this.configuration.name;
|
||||
return includeRoot && this.root ? `${name} (${resources.basenameOrAuthority(this.root.uri)})` : name;
|
||||
}
|
||||
|
||||
setName(name: string): void {
|
||||
this.name = name;
|
||||
this._onDidChangeName.fire(name);
|
||||
}
|
||||
|
||||
get state(): State {
|
||||
|
@ -144,6 +153,10 @@ export class DebugSession implements IDebugSession {
|
|||
return this._onDidChangeREPLElements.event;
|
||||
}
|
||||
|
||||
get onDidChangeName(): Event<string> {
|
||||
return this._onDidChangeName.event;
|
||||
}
|
||||
|
||||
//---- DAP events
|
||||
|
||||
get onDidCustomEvent(): Event<DebugProtocol.Event> {
|
||||
|
|
|
@ -466,7 +466,21 @@ export class LoadedScriptsView extends ViewletPanel {
|
|||
}
|
||||
}));
|
||||
|
||||
const registerLoadedSourceListener = (session: IDebugSession) => {
|
||||
const scheduleRefreshOnVisible = () => {
|
||||
if (this.isBodyVisible()) {
|
||||
this.changeScheduler.schedule();
|
||||
} else {
|
||||
this.treeNeedsRefreshOnVisible = true;
|
||||
}
|
||||
};
|
||||
|
||||
const registerSessionListeners = (session: IDebugSession) => {
|
||||
this._register(session.onDidChangeName(() => {
|
||||
// Re-add session, this will trigger proper sorting and id recalculation.
|
||||
root.remove(session.getId());
|
||||
root.add(session);
|
||||
scheduleRefreshOnVisible();
|
||||
}));
|
||||
this._register(session.onDidLoadedSource(event => {
|
||||
let sessionRoot: SessionTreeItem;
|
||||
switch (event.reason) {
|
||||
|
@ -474,11 +488,7 @@ export class LoadedScriptsView extends ViewletPanel {
|
|||
case 'changed':
|
||||
sessionRoot = root.add(session);
|
||||
sessionRoot.addPath(event.source);
|
||||
if (this.isBodyVisible()) {
|
||||
this.changeScheduler.schedule();
|
||||
} else {
|
||||
this.treeNeedsRefreshOnVisible = true;
|
||||
}
|
||||
scheduleRefreshOnVisible();
|
||||
if (event.reason === 'changed') {
|
||||
DebugContentProvider.refreshDebugContent(event.source.uri);
|
||||
}
|
||||
|
@ -486,11 +496,7 @@ export class LoadedScriptsView extends ViewletPanel {
|
|||
case 'removed':
|
||||
sessionRoot = root.find(session);
|
||||
if (sessionRoot && sessionRoot.removePath(event.source)) {
|
||||
if (this.isBodyVisible()) {
|
||||
this.changeScheduler.schedule();
|
||||
} else {
|
||||
this.treeNeedsRefreshOnVisible = true;
|
||||
}
|
||||
scheduleRefreshOnVisible();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -501,8 +507,8 @@ export class LoadedScriptsView extends ViewletPanel {
|
|||
}));
|
||||
};
|
||||
|
||||
this._register(this.debugService.onDidNewSession(registerLoadedSourceListener));
|
||||
this.debugService.getModel().getSessions().forEach(registerLoadedSourceListener);
|
||||
this._register(this.debugService.onDidNewSession(registerSessionListeners));
|
||||
this.debugService.getModel().getSessions().forEach(registerSessionListeners);
|
||||
|
||||
this._register(this.debugService.onDidEndSession(session => {
|
||||
root.remove(session.getId());
|
||||
|
|
|
@ -157,6 +157,8 @@ export interface IDebugSession extends ITreeElement {
|
|||
|
||||
setSubId(subId: string | undefined): void;
|
||||
|
||||
setName(name: string): void;
|
||||
readonly onDidChangeName: Event<string>;
|
||||
getLabel(): string;
|
||||
|
||||
getSourceForUri(modelUri: uri): Source | undefined;
|
||||
|
|
|
@ -180,6 +180,10 @@ export class MockSession implements IDebugSession {
|
|||
return 'mockname';
|
||||
}
|
||||
|
||||
setName(name: string): void {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
getSourceForUri(modelUri: uri): Source {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
@ -204,6 +208,10 @@ export class MockSession implements IDebugSession {
|
|||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
get onDidChangeName(): Event<string> {
|
||||
throw new Error('not implemented');
|
||||
}
|
||||
|
||||
setConfiguration(configuration: { resolved: IConfig, unresolved: IConfig }) { }
|
||||
|
||||
getAllThreads(): IThread[] {
|
||||
|
|
Loading…
Reference in a new issue