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

More XtermTerminal refactors #136292

Merged
merged 4 commits into from
Nov 2, 2021
Merged
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
23 changes: 11 additions & 12 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
private static _lastKnownGridDimensions: IGridDimensions | undefined;
private static _instanceIdCounter = 1;

xterm?: XtermTerminal;
private _xtermReadyPromise: Promise<XtermTerminal>;
private _xtermTypeAheadAddon: TypeAheadAddon | undefined;

private _processManager!: ITerminalProcessManager;
private _pressAnyKeyToCloseListener: IDisposable | undefined;

Expand All @@ -119,8 +123,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
private _titleSource: TitleEventSource = TitleEventSource.Process;
private _container: HTMLElement | undefined;
private _wrapperElement: (HTMLElement & { xterm?: XTermTerminal }) | undefined;
private _xtermTypeAhead: TypeAheadAddon | undefined;
private _xtermElement: HTMLDivElement | undefined;
private _horizontalScrollbar: DomScrollableElement | undefined;
private _terminalHasTextContextKey: IContextKey<boolean>;
private _terminalA11yTreeFocusContextKey: IContextKey<boolean>;
Expand All @@ -131,7 +133,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
private _cwd: string | undefined = undefined;
private _initialCwd: string | undefined = undefined;
private _dimensionsOverride: ITerminalDimensionsOverride | undefined;
private _xtermReadyPromise: Promise<XtermTerminal>;
private _titleReadyPromise: Promise<string>;
private _titleReadyComplete: ((title: string) => any) | undefined;
private _areLinksReady: boolean = false;
Expand All @@ -153,7 +154,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {

private _hasHadInput: boolean;


readonly statusList: ITerminalStatusList;
disableLayout: boolean = false;

Expand All @@ -167,8 +167,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
private _userHome?: string;
private _hasScrollBar?: boolean;

xterm?: XtermTerminal;

get target(): TerminalLocation | undefined { return this.xterm?.target; }
set target(value: TerminalLocation | undefined) {
if (this.xterm) {
Expand Down Expand Up @@ -658,8 +656,9 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._onLinksReady.fire(this);
});

this._xtermTypeAhead = this._register(this._instantiationService.createInstance(TypeAheadAddon, this._processManager, this._configHelper));
xterm.raw.loadAddon(this._xtermTypeAhead);
// TODO: This should be an optional addon
this._xtermTypeAheadAddon = this._register(this._instantiationService.createInstance(TypeAheadAddon, this._processManager, this._configHelper));
xterm.raw.loadAddon(this._xtermTypeAheadAddon);
this._pathService.userHome().then(userHome => {
this._userHome = userHome.fsPath;
});
Expand Down Expand Up @@ -701,8 +700,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._container = container;
this._wrapperElement = document.createElement('div');
this._wrapperElement.classList.add('terminal-wrapper');
this._xtermElement = document.createElement('div');
this._wrapperElement.appendChild(this._xtermElement);
const xtermElement = document.createElement('div');
this._wrapperElement.appendChild(xtermElement);

this._container.appendChild(this._wrapperElement);

Expand All @@ -711,7 +710,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
// Attach the xterm object to the DOM, exposing it to the smoke tests
this._wrapperElement.xterm = xterm.raw;

xterm.attachToElement(this._xtermElement);
xterm.attachToElement(xtermElement);

if (!xterm.raw.element || !xterm.raw.textarea) {
throw new Error('xterm elements not set after open');
Expand Down Expand Up @@ -1378,7 +1377,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {

this._processManager.relaunch(this._shellLaunchConfig, this._cols || Constants.DefaultCols, this._rows || Constants.DefaultRows, this._accessibilityService.isScreenReaderOptimized(), reset);

this._xtermTypeAhead?.reset();
this._xtermTypeAheadAddon?.reset();
}

@debounce(1000)
Expand Down