Skip to content
Open
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
14 changes: 11 additions & 3 deletions lib/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ export class CanvasRenderer {
* Render a cell's text and decorations (Pass 2 of two-pass rendering)
* Selection foreground color is applied here to match the selection background.
*/
private renderCellText(cell: GhosttyCell, x: number, y: number): void {
private renderCellText(cell: GhosttyCell, x: number, y: number, colorOverride?: string): void {
const cellX = x * this.metrics.width;
const cellY = y * this.metrics.height;
const cellWidth = this.metrics.width * cell.width;
Expand All @@ -604,8 +604,10 @@ export class CanvasRenderer {
if (cell.flags & CellFlags.BOLD) fontStyle += 'bold ';
this.ctx.font = `${fontStyle}${this.fontSize}px ${this.fontFamily}`;

// Set text color - use selection foreground if selected
if (isSelected) {
// Set text color - use override if provided, otherwise selection or cell color
if (colorOverride) {
this.ctx.fillStyle = colorOverride;
} else if (isSelected) {
this.ctx.fillStyle = this.theme.selectionForeground;
} else {
// Extract colors and handle inverse
Expand Down Expand Up @@ -720,6 +722,12 @@ export class CanvasRenderer {
case 'block':
// Full cell block
this.ctx.fillRect(cursorX, cursorY, this.metrics.width, this.metrics.height);

// Re-draw the character under the cursor with cursorAccent color
const line = this.currentBuffer?.getLine(y);
if (line?.[x]) {
this.renderCellText(line[x], x, y, this.theme.cursorAccent);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid repainting full-width glyph outside block cursor cell

Redrawing line[x] via renderCellText can repaint a double-width character (cell.width === 2) across both cells, but the block cursor background drawn just above still covers only one cell. In the default theme cursorAccent is the same as the background, so when the cursor lands on a full-width CJK glyph, the right half gets repainted in background color on the non-cursor cell and effectively disappears. This regression is introduced by the new redraw path and is reproducible whenever block cursor is positioned on wide characters.

Useful? React with 👍 / 👎.

}
break;

case 'underline':
Expand Down