Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open/close dev tools when escape sequence logging toggled #137746

Merged
merged 4 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/vs/workbench/contrib/terminal/browser/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,14 @@ export interface ITerminalService extends ITerminalInstanceHost {

resolveLocation(location?: ITerminalLocationOptions): TerminalLocation | undefined
setNativeDelegate(nativeCalls: ITerminalServiceNativeDelegate): void;

toggleDevTools(open?: boolean): Promise<void>;
handleNewRegisteredBackend(backend: ITerminalBackend): void;
}

export interface ITerminalServiceNativeDelegate {
getWindowCount(): Promise<number>;
openDevTools(): Promise<void>;
toggleDevTools(): Promise<void>;
}

/**
Expand Down Expand Up @@ -754,7 +756,7 @@ export interface ITerminalInstance {

addDisposable(disposable: IDisposable): void;

toggleEscapeSequenceLogging(): void;
toggleEscapeSequenceLogging(): Promise<boolean>;

getInitialCwd(): Promise<string>;
getCwd(): Promise<string>;
Expand Down
6 changes: 4 additions & 2 deletions src/vs/workbench/contrib/terminal/browser/terminalActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1156,8 +1156,10 @@ export function registerTerminalActions() {
precondition: TerminalContextKeys.processSupported
});
}
run(accessor: ServicesAccessor) {
accessor.get(ITerminalService).activeInstance?.toggleEscapeSequenceLogging();
async run(accessor: ServicesAccessor) {
const terminalService = accessor.get(ITerminalService);
const toggledOn = await terminalService.activeInstance?.toggleEscapeSequenceLogging();
terminalService.toggleDevTools(toggledOn);
}
});
registerAction2(class extends Action2 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1751,9 +1751,10 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}
}

async toggleEscapeSequenceLogging(): Promise<void> {
async toggleEscapeSequenceLogging(): Promise<boolean> {
const xterm = await this._xtermReadyPromise;
xterm.raw.options.logLevel = xterm.raw.options.logLevel === 'debug' ? 'info' : 'debug';
return xterm.raw.options.logLevel === 'debug';
}

async getInitialCwd(): Promise<string> {
Expand Down
7 changes: 7 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/terminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,13 @@ export class TerminalService implements ITerminalService {
this._nativeDelegate = nativeDelegate;
}

async toggleDevTools(open?: boolean): Promise<void> {
if (open) {
this._nativeDelegate?.openDevTools();
} else {
this._nativeDelegate?.toggleDevTools();
}
}
private _shouldReviveProcesses(reason: ShutdownReason): boolean {
if (!this._configHelper.config.enablePersistentSessions) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export class TerminalNativeContribution extends Disposable implements IWorkbench
this._register(nativeHostService.onDidResumeOS(() => this._onOsResume()));

this._terminalService.setNativeDelegate({
getWindowCount: () => nativeHostService.getWindowCount()
getWindowCount: () => nativeHostService.getWindowCount(),
openDevTools: () => nativeHostService.openDevTools(),
toggleDevTools: () => nativeHostService.toggleDevTools()
});

const connection = remoteAgentService.getConnection();
Expand Down