Skip to content

Commit 5bfb130

Browse files
committed
Apply same approach for rendering joined selection in webgl
1 parent 0521378 commit 5bfb130

1 file changed

Lines changed: 18 additions & 20 deletions

File tree

addons/addon-webgl/src/WebglRenderer.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -422,19 +422,24 @@ export class WebglRenderer extends Disposable implements IRenderer {
422422
// ranges are produced, we know that they are valid for the characters
423423
// and attributes of our input.
424424
if (joinedRanges.length > 0 && x === joinedRanges[0][0]) {
425-
isJoined = true;
426425
range = joinedRanges.shift()!;
427426

428-
// We already know the exact start and end column of the joined range,
429-
// so we get the string and width representing it directly.
430-
cell = new JoinedCellData(
431-
cell,
432-
line!.translateToString(true, range[0], range[1]),
433-
range[1] - range[0]
434-
);
435-
436-
// Skip over the cells occupied by this range in the loop
437-
lastCharX = range[1] - 1;
427+
// If the ligature's selection state is not consistent, don't join it. This helps the
428+
// selection render correctly regardless whether they should be joined.
429+
if (this._model.selection.isCellSelected(this._terminal, range[0], row) === this._model.selection.isCellSelected(this._terminal, range[1], row)) {
430+
isJoined = true;
431+
432+
// We already know the exact start and end column of the joined range,
433+
// so we get the string and width representing it directly.
434+
cell = new JoinedCellData(
435+
cell,
436+
line!.translateToString(true, range[0], range[1]),
437+
range[1] - range[0]
438+
);
439+
440+
// Skip over the cells occupied by this range in the loop
441+
lastCharX = range[1] - 1;
442+
}
438443
}
439444

440445
chars = cell.getChars();
@@ -507,15 +512,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
507512
j = ((y * terminal.cols) + x) * RENDER_MODEL_INDICIES_PER_CELL;
508513
this._glyphRenderer.value!.updateCell(x, y, NULL_CELL_CODE, 0, 0, 0, NULL_CELL_CHAR, 0, 0);
509514
this._model.cells[j] = NULL_CELL_CODE;
510-
// HACK: Generally we don't support multi-colored ligature backgrounds, however it's
511-
// important here that we re-resolve the cell color since selections are regular
512-
// background colors.
513-
//
514-
// This can result in bad aliasing since currently ligature glyphs drawn using a single
515-
// texture. This is most noticable when the background colors across the ligature differ
516-
// drastically. This could be improved in the future by sourcing from different glyphs
517-
// for each cell when the foreground or background differ.
518-
this._cellColorResolver.resolve(cell, x, row, this.dimensions.device.cell.width);
515+
// Don't re-resolve the cell color since multi-colored ligature backgrounds are not
516+
// supported
519517
this._model.cells[j + RENDER_MODEL_BG_OFFSET] = this._cellColorResolver.result.bg;
520518
this._model.cells[j + RENDER_MODEL_FG_OFFSET] = this._cellColorResolver.result.fg;
521519
this._model.cells[j + RENDER_MODEL_EXT_OFFSET] = this._cellColorResolver.result.ext;

0 commit comments

Comments
 (0)