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

only call buffer once and store it on xterm creation #112844

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 7 additions & 5 deletions src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { TerminalLinkManager } from 'vs/workbench/contrib/terminal/browser/links
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { ITerminalInstanceService, ITerminalInstance, TerminalShellType, WindowsShellType, ITerminalExternalLinkProvider } from 'vs/workbench/contrib/terminal/browser/terminal';
import { TerminalProcessManager } from 'vs/workbench/contrib/terminal/browser/terminalProcessManager';
import type { Terminal as XTermTerminal, IBuffer, ITerminalAddon } from 'xterm';
import type { Terminal as XTermTerminal, IBuffer, ITerminalAddon, IBufferNamespace } from 'xterm';
import type { SearchAddon, ISearchOptions } from 'xterm-addon-search';
import type { Unicode11Addon } from 'xterm-addon-unicode11';
import type { WebglAddon } from 'xterm-addon-webgl';
Expand Down Expand Up @@ -88,6 +88,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
private _title: string = '';
private _wrapperElement: (HTMLElement & { xterm?: XTermTerminal }) | undefined;
private _xterm: XTermTerminal | undefined;
private _xtermBuffer: IBufferNamespace | undefined;
private _xtermCore: XTermCore | undefined;
private _xtermSearch: SearchAddon | undefined;
private _xtermUnicode11: Unicode11Addon | undefined;
Expand Down Expand Up @@ -416,6 +417,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
wordSeparator: config.wordSeparators
});
this._xterm = xterm;
this._xtermBuffer = xterm.buffer;
this._xtermCore = (xterm as any)._core as XTermCore;
this._updateUnicodeVersion();
this.updateAccessibilitySupport();
Expand Down Expand Up @@ -800,7 +802,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}
}
if (this._xterm) {
const buffer = this._xterm.buffer;
const buffer = this._xtermBuffer!;
this._sendLineData(buffer.active, buffer.active.baseY + buffer.active.cursorY);
this._xterm.dispose();
}
Expand Down Expand Up @@ -881,7 +883,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
// change since the number of visible rows decreases.
// This can likely be removed after https:/xtermjs/xterm.js/issues/291 is
// fixed upstream.
this._xtermCore._onScroll.fire(this._xterm.buffer.active.viewportY);
this._xtermCore._onScroll.fire(this._xtermBuffer!.active.viewportY);
if (this._container && this._container.parentElement) {
// Force a layout when the instance becomes invisible. This is particularly important
// for ensuring that terminals that are created in the background by an extension will
Expand Down Expand Up @@ -1216,15 +1218,15 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}

private _onLineFeed(): void {
const buffer = this._xterm!.buffer;
const buffer = this._xtermBuffer!;
const newLine = buffer.active.getLine(buffer.active.baseY + buffer.active.cursorY);
if (newLine && !newLine.isWrapped) {
this._sendLineData(buffer.active, buffer.active.baseY + buffer.active.cursorY - 1);
}
}

private _onCursorMove(): void {
const buffer = this._xterm!.buffer;
const buffer = this._xtermBuffer!;
this._sendLineData(buffer.active, buffer.active.baseY + buffer.active.cursorY);
}

Expand Down