Skip to content

Commit

Permalink
re-enable smoke tests, keep editor fix (#139012) (#139019)
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed Dec 13, 2021
1 parent b3d3156 commit c4738fe
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
7 changes: 4 additions & 3 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Expand Up @@ -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; }
Expand Down Expand Up @@ -559,7 +561,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);
Expand Down Expand Up @@ -701,7 +703,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 => {
Expand Down
25 changes: 15 additions & 10 deletions src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts
Expand Up @@ -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';
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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.
Expand All @@ -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,
Expand All @@ -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<IEditorOptions>('editor');
Expand Down Expand Up @@ -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)) {
Expand All @@ -133,7 +140,6 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal {
}));

// Load addons

this._updateUnicodeVersion();

this._commandTrackerAddon = new CommandTrackerAddon();
Expand All @@ -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);
}
Expand Down
Expand Up @@ -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;
Expand All @@ -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');
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion test/smoke/src/areas/terminal/terminal-profiles.test.ts
Expand Up @@ -36,7 +36,7 @@ export function setup(opts: ParsedArgs) {
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 });
Expand Down

0 comments on commit c4738fe

Please sign in to comment.