From f3f4dcaf9fa295a4b3807391bf9336d741c8557e Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 3 Jun 2026 07:05:19 -0700 Subject: [PATCH] fix(CharacterJoiner): bound join ranges to trimmed line length (#5990) Character joiner scanning already iterated cells with getTrimmedLength(), but trailing attribute runs and _stringRangesToCellRanges used buffer cols. On short lines that could run joiners on a single trailing cell and extend open ranges through empty tail columns, affecting ligature/join rendering. Use trimmed length consistently for trailing-run detection, the cell-range walk, and the final range end column. Co-authored-by: Cursor --- src/browser/services/CharacterJoinerService.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/browser/services/CharacterJoinerService.ts b/src/browser/services/CharacterJoinerService.ts index e1da0bd28..2cf3bd506 100644 --- a/src/browser/services/CharacterJoinerService.ts +++ b/src/browser/services/CharacterJoinerService.ts @@ -100,6 +100,7 @@ export class CharacterJoinerService implements ICharacterJoinerService { const ranges: [number, number][] = []; const lineStr = line.translateToString(true); + const trimmedLength = line.getTrimmedLength(); // Because some cells can be represented by multiple javascript characters, // we track the cell and the string indexes separately. This allows us to @@ -111,7 +112,7 @@ export class CharacterJoinerService implements ICharacterJoinerService { let rangeAttrFG = line.getFg(0); let rangeAttrBG = line.getBg(0); - for (let x = 0; x < line.getTrimmedLength(); x++) { + for (let x = 0; x < trimmedLength; x++) { line.loadCell(x, this._workCell); if (this._workCell.getWidth() === 0) { @@ -147,7 +148,7 @@ export class CharacterJoinerService implements ICharacterJoinerService { } // Process any trailing ranges. - if (this._bufferService.cols - rangeStartColumn > 1) { + if (trimmedLength - rangeStartColumn > 1) { const joinedRanges = this._getJoinedRanges( lineStr, rangeStartStringIndex, @@ -216,7 +217,8 @@ export class CharacterJoinerService implements ICharacterJoinerService { return; } - for (let x = startCol; x < this._bufferService.cols; x++) { + const trimmedLength = line.getTrimmedLength(); + for (let x = startCol; x < trimmedLength; x++) { const width = line.getWidth(x); const length = line.getString(x).length || WHITESPACE_CELL_CHAR.length; @@ -264,7 +266,7 @@ export class CharacterJoinerService implements ICharacterJoinerService { // If there is still a range left at the end, it must extend all the way to // the end of the line. if (currentRange) { - currentRange[1] = this._bufferService.cols; + currentRange[1] = trimmedLength; } }