Skip to content

Commit

Permalink
Merge pull request #136292 from microsoft/tyriar/more_xtermterminal
Browse files Browse the repository at this point in the history
More XtermTerminal refactors
  • Loading branch information
Tyriar authored Nov 2, 2021
2 parents 338b390 + b135abf commit 773e643
Showing 1 changed file with 11 additions and 12 deletions.
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 @@ -98,6 +98,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 @@ -115,8 +119,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 @@ -127,7 +129,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 @@ -149,7 +150,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {

private _hasHadInput: boolean;


readonly statusList: ITerminalStatusList;
disableLayout: boolean = false;

Expand All @@ -163,8 +163,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 @@ -606,8 +604,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 @@ -649,8 +648,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 @@ -659,7 +658,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 @@ -1326,7 +1325,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

0 comments on commit 773e643

Please sign in to comment.