Ensure viewport is correctly reset on term.reset

Part of #4603
This commit is contained in:
Daniel Imms
2023-08-02 11:18:00 -07:00
parent bb237f109a
commit acf53f69e0
4 changed files with 19 additions and 3 deletions
+1 -1
View File
@@ -1255,13 +1255,13 @@ export class Terminal extends CoreTerminal implements ITerminal {
super.reset(); super.reset();
this._selectionService?.reset(); this._selectionService?.reset();
this._decorationService.reset(); this._decorationService.reset();
this.viewport?.reset();
// reattach // reattach
this._customKeyEventHandler = customKeyEventHandler; this._customKeyEventHandler = customKeyEventHandler;
// do a full screen refresh // do a full screen refresh
this.refresh(0, this.rows - 1); this.refresh(0, this.rows - 1);
this.viewport?.syncScrollArea();
} }
public clearTextureAtlas(): void { public clearTextureAtlas(): void {
+3
View File
@@ -324,6 +324,9 @@ export class MockViewport implements IViewport {
public scrollLines(disp: number): void { public scrollLines(disp: number): void {
this._onRequestScrollLines.fire({ amount: disp, suppressScrollEvent: false }); this._onRequestScrollLines.fire({ amount: disp, suppressScrollEvent: false });
} }
public reset(): void {
throw new Error('Method not implemented.');
}
} }
export class MockCompositionHelper implements ICompositionHelper { export class MockCompositionHelper implements ICompositionHelper {
+2 -1
View File
@@ -161,13 +161,14 @@ export interface IPartialColorSet {
export interface IViewport extends IDisposable { export interface IViewport extends IDisposable {
scrollBarWidth: number; scrollBarWidth: number;
readonly onRequestScrollLines: IEvent<{ amount: number, suppressScrollEvent: boolean }>; readonly onRequestScrollLines: IEvent<{ amount: number, suppressScrollEvent: boolean }>;
syncScrollArea(immediate?: boolean): void; syncScrollArea(immediate?: boolean, force?: boolean): void;
getLinesScrolled(ev: WheelEvent): number; getLinesScrolled(ev: WheelEvent): number;
getBufferElements(startLine: number, endLine?: number): { bufferElements: HTMLElement[], cursorElement?: HTMLElement }; getBufferElements(startLine: number, endLine?: number): { bufferElements: HTMLElement[], cursorElement?: HTMLElement };
handleWheel(ev: WheelEvent): boolean; handleWheel(ev: WheelEvent): boolean;
handleTouchStart(ev: TouchEvent): void; handleTouchStart(ev: TouchEvent): void;
handleTouchMove(ev: TouchEvent): boolean; handleTouchMove(ev: TouchEvent): boolean;
scrollLines(disp: number): void; // todo api name? scrollLines(disp: number): void; // todo api name?
reset(): void;
} }
export interface ILinkifierEvent { export interface ILinkifierEvent {
+13 -1
View File
@@ -81,13 +81,25 @@ export class Viewport extends Disposable implements IViewport {
this.register(this._optionsService.onSpecificOptionChange('scrollback', () => this.syncScrollArea())); this.register(this._optionsService.onSpecificOptionChange('scrollback', () => this.syncScrollArea()));
// Perform this async to ensure the ICharSizeService is ready. // Perform this async to ensure the ICharSizeService is ready.
setTimeout(() => this.syncScrollArea(), 0); setTimeout(() => this.syncScrollArea());
} }
private _handleThemeChange(colors: ReadonlyColorSet): void { private _handleThemeChange(colors: ReadonlyColorSet): void {
this._viewportElement.style.backgroundColor = colors.background.css; this._viewportElement.style.backgroundColor = colors.background.css;
} }
public reset(): void {
this._currentRowHeight = 0;
this._currentDeviceCellHeight = 0;
this._lastRecordedBufferLength = 0;
this._lastRecordedViewportHeight = 0;
this._lastRecordedBufferHeight = 0;
this._lastTouchY = 0;
this._lastScrollTop = 0;
// Sync on next animation frame to ensure the new terminal state is used
this._coreBrowserService.window.requestAnimationFrame(() => this.syncScrollArea());
}
/** /**
* Refreshes row height, setting line-height, viewport height and scroll area height if * Refreshes row height, setting line-height, viewport height and scroll area height if
* necessary. * necessary.