Skip to content

Commit

Permalink
finalize terminal disablePersistence API (#141898)
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed Feb 4, 2022
1 parent 921264b commit 6b0442b
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/vs/platform/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ export interface IShellLaunchConfig {
/**
* Opt-out of the default terminal persistence on restart and reload
*/
disablePersistence?: boolean;
isTransient?: boolean;
}

export interface ICreateContributedTerminalProfileOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/browser/mainThreadTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
isFeatureTerminal: launchConfig.isFeatureTerminal,
isExtensionOwnedTerminal: launchConfig.isExtensionOwnedTerminal,
useShellEnvironment: launchConfig.useShellEnvironment,
disablePersistence: launchConfig.disablePersistence
isTransient: launchConfig.isTransient
};
const terminal = Promises.withAsyncBody<ITerminalInstance>(async r => {
const terminal = await this._terminalService.createTerminal({
Expand Down
3 changes: 0 additions & 3 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return extHostEditorInsets.createWebviewEditorInset(editor, line, height, options, extension);
},
createTerminal(nameOrOptions?: vscode.TerminalOptions | vscode.ExtensionTerminalOptions | string, shellPath?: string, shellArgs?: string[] | string): vscode.Terminal {
if (nameOrOptions && typeof nameOrOptions === 'object' && 'disablePersistence' in nameOrOptions) {
checkProposedApiEnabled(extension, 'terminalDisablePersistence');
}
if (typeof nameOrOptions === 'object') {
if ('pty' in nameOrOptions) {
return extHostTerminalService.createExtensionTerminal(nameOrOptions);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ export interface TerminalLaunchConfig {
isExtensionOwnedTerminal?: boolean;
useShellEnvironment?: boolean;
location?: TerminalLocation | { viewColumn: number; preserveFocus?: boolean } | { parentTerminal: ExtHostTerminalIdentifier } | { splitActiveTerminal: boolean };
disablePersistence?: boolean;
isTransient?: boolean;
}

export interface MainThreadTerminalServiceShape extends IDisposable {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/common/extHostTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class ExtHostTerminal {
isExtensionOwnedTerminal: true,
useShellEnvironment: withNullAsUndefined(internalOptions?.useShellEnvironment),
location: internalOptions?.location || this._serializeParentTerminal(options.location, internalOptions?.resolvedExtHostIdentifier),
disablePersistence: withNullAsUndefined(options.disablePersistence)
isTransient: withNullAsUndefined(options.isTransient)
});
}

Expand All @@ -168,7 +168,7 @@ export class ExtHostTerminal {
icon: iconPath,
color: ThemeColor.isThemeColor(color) ? color.id : undefined,
location: this._serializeParentTerminal(location, parentTerminal),
disablePersistence: true
isTransient: true
});
// At this point, the id has been set via `$acceptTerminalOpened`
if (typeof this._id === 'string') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}

get persistentProcessId(): number | undefined { return this._processManager.persistentProcessId; }
get shouldPersist(): boolean { return this._processManager.shouldPersist && !this.shellLaunchConfig.disablePersistence; }
get shouldPersist(): boolean { return this._processManager.shouldPersist && !this.shellLaunchConfig.isTransient; }

/**
* Create xterm.js instance and attach data listeners.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
// this is a copy of what the merged environment collection is on the remote side
const env = await this._resolveEnvironment(backend, variableResolver, shellLaunchConfig);

const shouldPersist = !shellLaunchConfig.isFeatureTerminal && this._configHelper.config.enablePersistentSessions && !shellLaunchConfig.disablePersistence;
const shouldPersist = !shellLaunchConfig.isFeatureTerminal && this._configHelper.config.enablePersistentSessions && !shellLaunchConfig.isTransient;
if (shellLaunchConfig.attachPersistentProcess) {
const result = await backend.attachToProcess(shellLaunchConfig.attachPersistentProcess.id);
if (result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export const allApiProposals = Object.freeze({
telemetry: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.telemetry.d.ts',
terminalDataWriteEvent: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalDataWriteEvent.d.ts',
terminalDimensions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalDimensions.d.ts',
terminalDisablePersistence: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalDisablePersistence.d.ts',
terminalNameChangeEvent: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalNameChangeEvent.d.ts',
testCoverage: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testCoverage.d.ts',
testObserver: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testObserver.d.ts',
Expand Down
12 changes: 12 additions & 0 deletions src/vscode-dts/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9805,6 +9805,12 @@ declare module 'vscode' {
* The {@link TerminalLocation} or {@link TerminalEditorLocationOptions} or {@link TerminalSplitLocationOptions} for the terminal.
*/
location?: TerminalLocation | TerminalEditorLocationOptions | TerminalSplitLocationOptions;

/**
* Opt-out of the default terminal persistence on restart and reload.
* This will only take effect when `terminal.integrated.enablePersistentSessions` is enabled.
*/
isTransient?: boolean;
}

/**
Expand Down Expand Up @@ -9838,6 +9844,12 @@ declare module 'vscode' {
* The {@link TerminalLocation} or {@link TerminalEditorLocationOptions} or {@link TerminalSplitLocationOptions} for the terminal.
*/
location?: TerminalLocation | TerminalEditorLocationOptions | TerminalSplitLocationOptions;

/**
* Opt-out of the default terminal persistence on restart and reload.
* This will only take effect when `terminal.integrated.enablePersistentSessions` is enabled.
*/
isTransient?: boolean;
}

/**
Expand Down
21 changes: 0 additions & 21 deletions src/vscode-dts/vscode.proposed.terminalDisablePersistence.d.ts

This file was deleted.

0 comments on commit 6b0442b

Please sign in to comment.