mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
migrate process properties to use generic onDidChangeProperty (#135610)
This commit is contained in:
@@ -18,7 +18,7 @@ import { serializeEnvironmentVariableCollection } from 'vs/workbench/contrib/ter
|
||||
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
|
||||
import { ICreateContributedTerminalProfileOptions, IProcessReadyEvent, IShellLaunchConfigDto, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProfile, TerminalIcon, TerminalLocation, IProcessProperty, TerminalShellType, IShellLaunchConfig, ProcessPropertyType, ProcessCapability, IProcessPropertyMap } from 'vs/platform/terminal/common/terminal';
|
||||
import { ICreateContributedTerminalProfileOptions, IProcessReadyEvent, IShellLaunchConfigDto, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProfile, TerminalIcon, TerminalLocation, IProcessProperty, TerminalShellType, ProcessPropertyType, ProcessCapability, IProcessPropertyMap } from 'vs/platform/terminal/common/terminal';
|
||||
import { TerminalDataBufferer } from 'vs/platform/terminal/common/terminalDataBuffering';
|
||||
import { ThemeColor } from 'vs/platform/theme/common/themeService';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
@@ -262,17 +262,14 @@ export class ExtHostPseudoterminal implements ITerminalChildProcess {
|
||||
private readonly _onDidChangeProperty = new Emitter<IProcessProperty<any>>();
|
||||
public readonly onDidChangeProperty = this._onDidChangeProperty.event;
|
||||
|
||||
|
||||
constructor(private readonly _pty: vscode.Pseudoterminal) { }
|
||||
onProcessResolvedShellLaunchConfig?: Event<IShellLaunchConfig> | undefined;
|
||||
onDidChangeHasChildProcesses?: Event<boolean> | undefined;
|
||||
|
||||
refreshProperty<T extends ProcessPropertyType>(property: ProcessPropertyType): Promise<IProcessPropertyMap[T]> {
|
||||
return Promise.resolve('');
|
||||
throw new Error(`refreshProperty is not suppported in extension owned terminals. property: ${property}`);
|
||||
}
|
||||
|
||||
async updateProperty<T extends ProcessPropertyType>(property: ProcessPropertyType, value: IProcessPropertyMap[T]): Promise<void> {
|
||||
Promise.resolve('');
|
||||
updateProperty<T extends ProcessPropertyType>(property: ProcessPropertyType, value: IProcessPropertyMap[T]): Promise<void> {
|
||||
throw new Error(`updateProperty is not suppported in extension owned terminals. property: ${property}, value: ${value}`);
|
||||
}
|
||||
|
||||
async start(): Promise<undefined> {
|
||||
@@ -589,17 +586,17 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
|
||||
|
||||
protected _setupExtHostProcessListeners(id: number, p: ITerminalChildProcess): IDisposable {
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
disposables.add(p.onProcessReady((e: { pid: number, cwd: string }) => this._proxy.$sendProcessReady(id, e.pid, e.cwd)));
|
||||
disposables.add(p.onProcessTitleChanged(title => this._proxy.$sendProcessTitle(id, title)));
|
||||
disposables.add(p.onDidChangeProperty(property => {
|
||||
if (property.type === ProcessPropertyType.Exit) {
|
||||
this._onProcessExit(id, property.value);
|
||||
}
|
||||
this._proxy.$sendProcessProperty(id, property);
|
||||
}));
|
||||
|
||||
// Buffer data events to reduce the amount of messages going to the renderer
|
||||
this._bufferer.startBuffering(id, p.onProcessData);
|
||||
disposables.add(p.onProcessExit(exitCode => this._onProcessExit(id, exitCode)));
|
||||
|
||||
if (p.onProcessOverrideDimensions) {
|
||||
disposables.add(p.onProcessOverrideDimensions(e => this._proxy.$sendOverrideDimensions(id, e)));
|
||||
}
|
||||
this._terminalProcesses.set(id, p);
|
||||
|
||||
const awaitingStart = this._extensionTerminalAwaitingStart[id];
|
||||
@@ -642,11 +639,11 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
|
||||
}
|
||||
|
||||
public $acceptProcessRequestInitialCwd(id: number): void {
|
||||
this._terminalProcesses.get(id)?.getInitialCwd().then(initialCwd => this._proxy.$sendProcessInitialCwd(id, initialCwd));
|
||||
this._terminalProcesses.get(id)?.getInitialCwd().then(initialCwd => this._proxy.$sendProcessProperty(id, { type: ProcessPropertyType.InitialCwd, value: initialCwd }));
|
||||
}
|
||||
|
||||
public $acceptProcessRequestCwd(id: number): void {
|
||||
this._terminalProcesses.get(id)?.getCwd().then(cwd => this._proxy.$sendProcessCwd(id, cwd));
|
||||
this._terminalProcesses.get(id)?.getCwd().then(cwd => this._proxy.$sendProcessProperty(id, { type: ProcessPropertyType.Cwd, value: cwd }));
|
||||
}
|
||||
|
||||
public $acceptProcessRequestLatency(id: number): number {
|
||||
@@ -777,9 +774,6 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
|
||||
processDiposable.dispose();
|
||||
delete this._terminalProcessDisposables[id];
|
||||
}
|
||||
|
||||
// Send exit event to main side
|
||||
this._proxy.$sendProcessExit(id, exitCode);
|
||||
}
|
||||
|
||||
private _getTerminalById(id: number): ExtHostTerminal | null {
|
||||
|
||||
Reference in New Issue
Block a user