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

Fix webgl renderer does not render when writing if a selection exists #3232

Merged
merged 5 commits into from
Feb 3, 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
29 changes: 17 additions & 12 deletions addons/xterm-addon-webgl/src/WebglRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,8 @@ export class WebglRenderer extends Disposable implements IRenderer {

this._refreshCharAtlas();

this._rectangleRenderer.updateSelection(this._model.selection);
this._glyphRenderer.updateSelection(this._model);

// Force a full refresh
this._model.clear();
this._model.clearSelection();
}

public onDevicePixelRatioChange(): void {
Expand All @@ -138,7 +134,6 @@ export class WebglRenderer extends Disposable implements IRenderer {
this._updateDimensions();

this._model.resize(this._terminal.cols, this._terminal.rows);
this._rectangleRenderer.onResize();

// Resize all render layers
this._renderLayers.forEach(l => l.resize(this._terminal, this.dimensions));
Expand All @@ -152,14 +147,20 @@ export class WebglRenderer extends Disposable implements IRenderer {
// Resize the screen
this._core.screenElement!.style.width = `${this.dimensions.canvasWidth}px`;
this._core.screenElement!.style.height = `${this.dimensions.canvasHeight}px`;

this._rectangleRenderer.onResize();
if (this._model.selection.hasSelection) {
// Update selection as dimensions have changed
this._rectangleRenderer.updateSelection(this._model.selection);
}

this._glyphRenderer.setDimensions(this.dimensions);
this._glyphRenderer.onResize();

this._refreshCharAtlas();

// Force a full refresh
this._model.clear();
this._model.clearSelection();
}

public onCharSizeChanged(): void {
Expand All @@ -179,9 +180,6 @@ export class WebglRenderer extends Disposable implements IRenderer {

this._updateSelectionModel(start, end, columnSelectMode);

this._rectangleRenderer.updateSelection(this._model.selection);
this._glyphRenderer.updateSelection(this._model);

this._onRequestRedraw.fire({ start: 0, end: this._terminal.rows - 1 });
}

Expand Down Expand Up @@ -220,7 +218,6 @@ export class WebglRenderer extends Disposable implements IRenderer {
this._charAtlas?.clearTexture();
this._model.clear();
this._updateModel(0, this._terminal.rows - 1);
this._glyphRenderer.updateSelection(this._model);
this._onRequestRedraw.fire({ start: 0, end: this._terminal.rows - 1 });
}

Expand Down Expand Up @@ -253,7 +250,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
// Tell renderer the frame is beginning
if (this._glyphRenderer.beginFrame()) {
this._model.clear();
this._model.clearSelection();
this._updateSelectionModel(undefined, undefined);
}

// Update model to reflect what's drawn
Expand Down Expand Up @@ -303,14 +300,19 @@ export class WebglRenderer extends Disposable implements IRenderer {
}
}
this._rectangleRenderer.updateBackgrounds(this._model);
if (this._model.selection.hasSelection) {
// Model could be updated but the selection is unchanged
this._glyphRenderer.updateSelection(this._model);
}
}

private _updateSelectionModel(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean): void {
private _updateSelectionModel(start: [number, number] | undefined, end: [number, number] | undefined, columnSelectMode: boolean = false): void {
const terminal = this._terminal;

// Selection does not exist
if (!start || !end || (start[0] === end[0] && start[1] === end[1])) {
this._model.clearSelection();
this._rectangleRenderer.updateSelection(this._model.selection);
return;
}

Expand All @@ -323,6 +325,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
// No need to draw the selection
if (viewportCappedStartRow >= terminal.rows || viewportCappedEndRow < 0) {
this._model.clearSelection();
this._rectangleRenderer.updateSelection(this._model.selection);
return;
}

Expand All @@ -334,6 +337,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
this._model.selection.viewportCappedEndRow = viewportCappedEndRow;
this._model.selection.startCol = start[0];
this._model.selection.endCol = end[0];

this._rectangleRenderer.updateSelection(this._model.selection);
}

/**
Expand Down