Skip to content

Commit

Permalink
feat: add enable persistent terminal session preference
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaaaash committed Nov 1, 2023
1 parent 33359fd commit cb1b28f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/i18n/src/common/en-US.lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ export const localizationBundle = {
'preference.terminal.integrated.xtermRenderType': 'Xterm Render Type',
'preference.terminal.integrated.xtermRenderTypeDesc':
'Choose Xterm render type, Webgl for better performance, Canvas better compatibility',
'preference.terminal.integrated.enablePersistentSessionDesc': 'Persist terminal sessions/history for the workspace across window reloads.',
'preference.terminal.integrated.cursorStyle': 'Terminal > Cursor Style',
'preference.terminal.integrated.cursorStyleDesc': 'Control the style of terminal cursor',
'common.preference.open': 'Settings',
Expand Down
1 change: 1 addition & 0 deletions packages/i18n/src/common/zh-CN.lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ export const localizationBundle = {
'preference.terminal.integrated.localEchoStyleDesc': '本地回显文本的终端样式;字体样式或 RGB 颜色。',
'preference.terminal.integrated.xtermRenderType': 'Xterm 渲染类型',
'preference.terminal.integrated.xtermRenderTypeDesc': '选择 Xterm 渲染类型,WebGL 性能更强,Canvas 兼容性更佳。',
'preference.terminal.integrated.enablePersistentSessionDesc': '窗口重载时持久化终端会话',
'preference.terminal.integrated.cursorStyle': '终端输入指针样式',
'preference.terminal.integrated.cursorStyleDesc': '修改终端输入指针样式',
'settings.group.general': '常规',
Expand Down
17 changes: 9 additions & 8 deletions packages/terminal-next/src/browser/terminal.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ import {

import { TerminalContextKey } from './terminal.context-key';
import { TerminalGroupViewService } from './terminal.view';
import { PreferenceService } from '@opensumi/ide-core-browser/lib/preferences/types';
import { CodeTerminalSettingId } from '../common/preference';

@Injectable()
export class TerminalController extends WithEventBus implements ITerminalController {
Expand Down Expand Up @@ -136,6 +138,9 @@ export class TerminalController extends WithEventBus implements ITerminalControl
@Autowired(ICtxMenuRenderer)
private ctxMenuRenderer: ICtxMenuRenderer;

@Autowired(PreferenceService)
private readonly preferenceService: PreferenceService;

@Autowired(AppConfig)
protected readonly appConfig: AppConfig;

Expand Down Expand Up @@ -556,15 +561,11 @@ export class TerminalController extends WithEventBus implements ITerminalControl

wGroup.widgets.forEach((widget) => {
const client = this._clients.get(widget.id);
if (!client) {
return;
}

if (client.launchConfig?.isExtensionOwnedTerminal || client.launchConfig?.disablePersistence) {
return;
}
const disablePersistence =
!this.preferenceService.get(CodeTerminalSettingId.EnablePersistentSessions) ||
client?.launchConfig?.disablePersistence;

if (client.isTaskExecutor) {
if (!client || disablePersistence || client?.isTaskExecutor) {
return;
}

Expand Down
6 changes: 6 additions & 0 deletions packages/terminal-next/src/common/preference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const enum CodeTerminalSettingId {
PersistentSessionReviveProcess = 'terminal.integrated.persistentSessionReviveProcess',
CustomGlyphs = 'terminal.integrated.customGlyphs',
PersistentSessionScrollback = 'terminal.integrated.persistentSessionScrollback',
PersistentSession = 'terminal.integrated.enablePersistentSession',
InheritEnv = 'terminal.integrated.inheritEnv',
ShowLinkHover = 'terminal.integrated.showLinkHover',
IgnoreProcessNames = 'terminal.integrated.ignoreProcessNames',
Expand Down Expand Up @@ -344,5 +345,10 @@ export const terminalPreferenceSchema: PreferenceSchema = {
enum: [RenderType.WebGL, RenderType.Canvas, RenderType.Dom],
default: RenderType.WebGL,
},
[CodeTerminalSettingId.PersistentSession]: {
type: 'boolean',
description: '%preference.terminal.integrated.enablePersistentSessionDesc%',
default: true,
},
},
};

0 comments on commit cb1b28f

Please sign in to comment.