Skip to content

Commit

Permalink
Merge pull request xtermjs#5277 from Tyriar/ligature_selection__cursor
Browse files Browse the repository at this point in the history
Disable ligatures when cursor is in range
  • Loading branch information
Tyriar authored Jan 6, 2025
2 parents d1b01c5 + 112cfbe commit 33a5457
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions addons/addon-webgl/src/WebglRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
let isValidJoinRange: boolean = true;
let lastCharX: number;
let range: [number, number];
let isCursorRow: boolean;
let chars: string;
let code: number;
let width: number;
Expand All @@ -407,6 +408,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
row = y + terminal.buffer.ydisp;
line = terminal.buffer.lines.get(row)!;
this._model.lineLengths[y] = 0;
isCursorRow = cursorY === row;
skipJoinedCheckUntilX = 0;
joinedRanges = this._characterJoinerService.getJoinedCharacters(row);
for (x = 0; x < terminal.cols; x++) {
Expand Down Expand Up @@ -438,6 +440,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
for (i = range[0] + 1; i < range[1]; i++) {
isValidJoinRange &&= (firstSelectionState === this._model.selection.isCellSelected(this._terminal, i, row));
}
// Similarly, if the cursor is in the ligature, don't join it.
isValidJoinRange &&= !isCursorRow || cursorX < range[0] || cursorX >= range[1];
if (!isValidJoinRange) {
skipJoinedCheckUntilX = range[1];
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/browser/renderer/dom/DomRendererRowFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ export class DomRendererRowFactory {
for (i = range[0] + 1; i < range[1]; i++) {
isValidJoinRange &&= (firstSelectionState === this._isCellInSelection(i, row));
}
// Similarly, if the cursor is in the ligature, don't join it.
isValidJoinRange &&= !isCursorRow || cursorX < range[0] || cursorX >= range[1];
if (!isValidJoinRange) {
skipJoinedCheckUntilX = range[1];
} else {
Expand Down

0 comments on commit 33a5457

Please sign in to comment.