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

vscode: Support isTransient in TerminalOptions and ExtensionTerminalOptions #12055

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

- [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/)

## v1.34.0 - 01/26/2023

- [plugin] added support for `isTransient` of `TerminalOptions` and `ExternalTerminalOptions` VS Code API [#12055](https://github.com/eclipse-theia/theia/pull/12055) - Contributed on behalf of STMicroelectronics
- [terminal] added support for preference `terminal.integrated.enablePersistentSessions` to allow disabling restoring terminals on reload [#12055](https://github.com/eclipse-theia/theia/pull/12055) - Contributed on behalf of STMicroelectronics

## v1.33.0 - 12/20/2022

- [application-package] added support for declaring extensions as peer dependencies [#11808](https://github.com/eclipse-theia/theia/pull/11808)
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-ext/src/main/browser/terminal-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ export class TerminalServiceMainImpl implements TerminalServiceMain, TerminalLin
attributes: options.attributes,
hideFromUser: options.hideFromUser,
location: this.getTerminalLocation(options, parentId),
isPseudoTerminal
isPseudoTerminal,
isTransient: options.isTransient
});
if (options.message) {
terminal.writeLine(options.message);
Expand Down
12 changes: 12 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3006,6 +3006,12 @@ export module '@theia/plugin' {
*/
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;

/**
* Terminal attributes. Can be useful to apply some implementation specific information.
*/
Expand Down Expand Up @@ -3077,6 +3083,12 @@ export module '@theia/plugin' {
* 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
5 changes: 5 additions & 0 deletions packages/terminal/src/browser/base/terminal-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,9 @@ export interface TerminalWidgetOptions {
readonly hideFromUser?: boolean;

readonly location?: TerminalLocationOptions;

/**
* When enabled, the terminal will not be persisted across window reloads.
*/
readonly isTransient?: boolean;
}
8 changes: 7 additions & 1 deletion packages/terminal/src/browser/terminal-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ export const TerminalConfigSchema: PreferenceSchema = {
nls.localize('theia/terminal/confirmCloseChildren', 'Confirm if there are any terminals that have child processes.'),
],
default: 'never'
},
'terminal.integrated.enablePersistentSessions': {
type: 'boolean',
description: nls.localizeByDefault('Persist terminal sessions for the workspace across window reloads.'),
default: true
}
}
};
Expand Down Expand Up @@ -181,7 +186,8 @@ export interface TerminalConfiguration {
'terminal.integrated.shellArgs.windows': string[],
'terminal.integrated.shellArgs.osx': string[],
'terminal.integrated.shellArgs.linux': string[],
'terminal.integrated.confirmOnExit': ConfirmOnExitType
'terminal.integrated.confirmOnExit': ConfirmOnExitType,
'terminal.integrated.enablePersistentSessions': boolean
}

type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
Expand Down
11 changes: 8 additions & 3 deletions packages/terminal/src/browser/terminal-widget-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget
return this.options.hideFromUser ?? false;
}

get transient(): boolean {
// The terminal is transient if session persistence is disabled or it's explicitly marked as transient
return !this.preferences['terminal.integrated.enablePersistentSessions'] || !!this.options.isTransient;
}

onDispose(onDispose: () => void): void {
this.toDispose.push(Disposable.create(onDispose));
}
Expand All @@ -421,15 +426,15 @@ export class TerminalWidgetImpl extends TerminalWidget implements StatefulWidget

storeState(): object {
this.closeOnDispose = false;
if (this.options.isPseudoTerminal) {
if (this.transient || this.options.isPseudoTerminal) {
return {};
}
return { terminalId: this.terminalId, titleLabel: this.title.label };
}

restoreState(oldState: object): void {
// pseudo terminal can not restore
if (this.options.isPseudoTerminal) {
// transient terminals and pseudo terminals are not restored
if (this.transient || this.options.isPseudoTerminal) {
this.dispose();
return;
}
Expand Down