diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index c17dc9144b5..8b99157ebe0 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -179,12 +179,14 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { private _labelComputer?: TerminalLabelComputer; private _userHome?: string; private _hasScrollBar?: boolean; + private _target?: TerminalLocation | undefined; - get target(): TerminalLocation | undefined { return this.xterm?.target; } + get target(): TerminalLocation | undefined { return this._target; } set target(value: TerminalLocation | undefined) { if (this.xterm) { this.xterm.target = value; } + this._target = value; } get instanceId(): number { return this._instanceId; } @@ -558,7 +560,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { throw new Error('Terminal disposed of during xterm.js creation'); } - const xterm = this._instantiationService.createInstance(XtermTerminal, Terminal, this._configHelper, this._cols, this._rows); + const xterm = this._instantiationService.createInstance(XtermTerminal, Terminal, this._configHelper, this._cols, this._rows, this.target || TerminalLocation.Panel); this.xterm = xterm; const lineDataEventAddon = new LineDataEventAddon(); this.xterm.raw.loadAddon(lineDataEventAddon); @@ -700,7 +702,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { throw new Error('xterm elements not set after open'); } - this._setAriaLabel(xterm.raw, this._instanceId, this._title); xterm.raw.attachCustomKeyEventHandler((event: KeyboardEvent): boolean => { diff --git a/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts b/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts index 3b5aa91c7fe..a9462a6fbc9 100644 --- a/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts +++ b/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts @@ -13,13 +13,7 @@ import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/term import { DisposableStore } from 'vs/base/common/lifecycle'; import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { TerminalLocation, TerminalSettingId } from 'vs/platform/terminal/common/terminal'; -import { IColorTheme, IThemeService } from 'vs/platform/theme/common/themeService'; -import { IViewDescriptorService, ViewContainerLocation } from 'vs/workbench/common/views'; -import { editorBackground } from 'vs/platform/theme/common/colorRegistry'; -import { ansiColorIdentifiers, TERMINAL_BACKGROUND_COLOR, TERMINAL_CURSOR_BACKGROUND_COLOR, TERMINAL_CURSOR_FOREGROUND_COLOR, TERMINAL_FOREGROUND_COLOR, TERMINAL_SELECTION_BACKGROUND_COLOR } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry'; import { ICommandTracker, ITerminalFont, TERMINAL_VIEW_ID } from 'vs/workbench/contrib/terminal/common/terminal'; -import { PANEL_BACKGROUND, SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme'; -import { Color } from 'vs/base/common/color'; import { isSafari } from 'vs/base/browser/browser'; import { IXtermTerminal } from 'vs/workbench/contrib/terminal/browser/terminal'; import { ILogService } from 'vs/platform/log/common/log'; @@ -28,6 +22,12 @@ import { TerminalStorageKeys } from 'vs/workbench/contrib/terminal/common/termin import { INotificationService, IPromptChoice, Severity } from 'vs/platform/notification/common/notification'; import { CommandTrackerAddon } from 'vs/workbench/contrib/terminal/browser/xterm/commandTrackerAddon'; import { localize } from 'vs/nls'; +import { IColorTheme, IThemeService } from 'vs/platform/theme/common/themeService'; +import { IViewDescriptorService, ViewContainerLocation } from 'vs/workbench/common/views'; +import { editorBackground } from 'vs/platform/theme/common/colorRegistry'; +import { PANEL_BACKGROUND, SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme'; +import { TERMINAL_FOREGROUND_COLOR, TERMINAL_BACKGROUND_COLOR, TERMINAL_CURSOR_FOREGROUND_COLOR, TERMINAL_CURSOR_BACKGROUND_COLOR, TERMINAL_SELECTION_BACKGROUND_COLOR, ansiColorIdentifiers } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry'; +import { Color } from 'vs/base/common/color'; // How long in milliseconds should an average frame take to render for a notification to appear // which suggests the fallback DOM-based renderer @@ -45,7 +45,6 @@ let WebglAddon: typeof WebglAddonType; export class XtermTerminal extends DisposableStore implements IXtermTerminal { /** The raw xterm.js instance */ readonly raw: RawXtermTerminal; - target?: TerminalLocation; private _core: IXtermCore; private static _suggestedRendererType: 'canvas' | 'dom' | undefined = undefined; @@ -63,6 +62,12 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal { get commandTracker(): ICommandTracker { return this._commandTrackerAddon; } + private _target: TerminalLocation | undefined; + set target(location: TerminalLocation | undefined) { + this._target = location; + } + get target(): TerminalLocation | undefined { return this._target; } + /** * @param xtermCtor The xterm.js constructor, this is passed in so it can be fetched lazily * outside of this class such that {@link raw} is not nullable. @@ -72,6 +77,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal { private readonly _configHelper: TerminalConfigHelper, cols: number, rows: number, + location: TerminalLocation, @IConfigurationService private readonly _configurationService: IConfigurationService, @ILogService private readonly _logService: ILogService, @INotificationService private readonly _notificationService: INotificationService, @@ -80,7 +86,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal { @IViewDescriptorService private readonly _viewDescriptorService: IViewDescriptorService ) { super(); - + this.target = location; const font = this._configHelper.getFont(undefined, true); const config = this._configHelper.config; const editorOptions = this._configurationService.getValue('editor'); @@ -125,6 +131,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal { this._updateUnicodeVersion(); } })); + this.add(this._themeService.onDidColorThemeChange(theme => this._updateTheme(theme))); this.add(this._viewDescriptorService.onDidChangeLocation(({ views }) => { if (views.some(v => v.id === TERMINAL_VIEW_ID)) { @@ -133,7 +140,6 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal { })); // Load addons - this._updateUnicodeVersion(); this._commandTrackerAddon = new CommandTrackerAddon(); @@ -148,7 +154,6 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal { attachToElement(container: HTMLElement) { // Update the theme when attaching as the terminal location could have changed this._updateTheme(); - if (!this._container) { this.raw.open(container); } diff --git a/src/vs/workbench/contrib/terminal/test/browser/xterm/xtermTerminal.test.ts b/src/vs/workbench/contrib/terminal/test/browser/xterm/xtermTerminal.test.ts index 100f7654d0c..024cd8c1924 100644 --- a/src/vs/workbench/contrib/terminal/test/browser/xterm/xtermTerminal.test.ts +++ b/src/vs/workbench/contrib/terminal/test/browser/xterm/xtermTerminal.test.ts @@ -109,7 +109,7 @@ suite('XtermTerminal', () => { instantiationService.stub(IViewDescriptorService, viewDescriptorService); configHelper = instantiationService.createInstance(TerminalConfigHelper); - xterm = instantiationService.createInstance(TestXtermTerminal, Terminal, configHelper, 80, 30); + xterm = instantiationService.createInstance(TestXtermTerminal, Terminal, configHelper, 80, 30, 1); TestWebglAddon.shouldThrow = false; TestWebglAddon.isEnabled = false; @@ -126,7 +126,7 @@ suite('XtermTerminal', () => { [PANEL_BACKGROUND]: '#ff0000', [SIDE_BAR_BACKGROUND]: '#00ff00' })); - xterm = instantiationService.createInstance(XtermTerminal, Terminal, configHelper, 80, 30); + xterm = instantiationService.createInstance(XtermTerminal, Terminal, configHelper, 80, 30, 1); strictEqual(xterm.raw.getOption('theme').background, '#ff0000'); viewDescriptorService.moveTerminalToLocation(ViewContainerLocation.Sidebar); strictEqual(xterm.raw.getOption('theme').background, '#00ff00'); @@ -159,7 +159,7 @@ suite('XtermTerminal', () => { 'terminal.ansiBrightCyan': '#150000', 'terminal.ansiBrightWhite': '#160000', })); - xterm = instantiationService.createInstance(XtermTerminal, Terminal, configHelper, 80, 30); + xterm = instantiationService.createInstance(XtermTerminal, Terminal, configHelper, 80, 30, 1); deepStrictEqual(xterm.raw.getOption('theme'), { background: '#000100', foreground: '#000200', diff --git a/test/smoke/src/areas/terminal/terminal-profiles.test.ts b/test/smoke/src/areas/terminal/terminal-profiles.test.ts index 45cb7db73a3..755302f89aa 100644 --- a/test/smoke/src/areas/terminal/terminal-profiles.test.ts +++ b/test/smoke/src/areas/terminal/terminal-profiles.test.ts @@ -35,7 +35,7 @@ export function setup() { await terminal.assertTerminalGroups([[{ name: CONTRIBUTED_PROFILE_NAME }, { name: CONTRIBUTED_PROFILE_NAME }]]); }); - it.skip('should set the default profile', async () => { + it('should set the default profile', async () => { await terminal.runCommandWithValue(TerminalCommandIdWithValue.SelectDefaultProfile, process.platform === 'win32' ? 'PowerShell' : undefined); await terminal.runCommand(TerminalCommandId.CreateNew); await terminal.assertSingleTab({ name: ANY_PROFILE_NAME }); @@ -48,7 +48,7 @@ export function setup() { await terminal.assertTerminalGroups([[{}, {}]]); }); - it.skip('createWithProfile command should create a terminal with a profile', async () => { + it('createWithProfile command should create a terminal with a profile', async () => { await terminal.runCommandWithValue(TerminalCommandIdWithValue.NewWithProfile); await terminal.assertSingleTab({ name: ANY_PROFILE_NAME }); }); diff --git a/test/smoke/src/areas/terminal/terminal-tabs.test.ts b/test/smoke/src/areas/terminal/terminal-tabs.test.ts index 5dd8ec9ac4a..7c415b7b1f2 100644 --- a/test/smoke/src/areas/terminal/terminal-tabs.test.ts +++ b/test/smoke/src/areas/terminal/terminal-tabs.test.ts @@ -14,7 +14,7 @@ export function setup() { terminal = app.workbench.terminal; }); - it.skip('clicking the plus button should create a terminal and display the tabs view showing no split decorations', async () => { + it('clicking the plus button should create a terminal and display the tabs view showing no split decorations', async () => { await terminal.runCommand(TerminalCommandId.Show); await terminal.runCommand(TerminalCommandId.CreateNew); await terminal.clickPlusButton();