diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index c9885a73a..4f41eadfd 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -1115,9 +1115,13 @@ fn rebuildCells( // the cell with the cursor. const start_i: usize = self.cells.items.len; defer if (cursor_row) { + // If we're on a wide spacer tail, then we want to look for + // the previous cell. + const screen_cell = row.getCell(screen.cursor.x); + const x = screen.cursor.x - @intFromBool(screen_cell.attrs.wide_spacer_tail); for (self.cells.items[start_i..]) |cell| { - if (cell.grid_pos[0] == @as(f32, @floatFromInt(screen.cursor.x)) and - cell.mode == .fg) + if (cell.grid_pos[0] == @as(f32, @floatFromInt(x)) and + (cell.mode == .fg or cell.mode == .fg_color)) { cursor_cell = cell; break; @@ -1201,10 +1205,13 @@ fn rebuildCells( } if (cursor_cell) |*cell| { - cell.color = if (self.config.cursor_text) |txt| - .{ txt.r, txt.g, txt.b, 255 } - else - .{ 0, 0, 0, 255 }; + if (cell.mode == .fg) { + cell.color = if (self.config.cursor_text) |txt| + .{ txt.r, txt.g, txt.b, 255 } + else + .{ 0, 0, 0, 255 }; + } + self.cells.appendAssumeCapacity(cell.*); } } diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 210c654e0..430148f73 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -751,9 +751,13 @@ pub fn rebuildCells( // the cell with the cursor. const start_i: usize = self.cells.items.len; defer if (cursor_row) { + // If we're on a wide spacer tail, then we want to look for + // the previous cell. + const screen_cell = row.getCell(screen.cursor.x); + const x = screen.cursor.x - @intFromBool(screen_cell.attrs.wide_spacer_tail); for (self.cells.items[start_i..]) |cell| { - if (cell.grid_col == screen.cursor.x and - cell.mode == .fg) + if (cell.grid_col == x and + (cell.mode == .fg or cell.mode == .fg_color)) { cursor_cell = cell; break; @@ -824,16 +828,18 @@ pub fn rebuildCells( } if (cursor_cell) |*cell| { - if (self.config.cursor_text) |txt| { - cell.fg_r = txt.r; - cell.fg_g = txt.g; - cell.fg_b = txt.b; - cell.fg_a = 255; - } else { - cell.fg_r = 0; - cell.fg_g = 0; - cell.fg_b = 0; - cell.fg_a = 255; + if (cell.mode == .fg) { + if (self.config.cursor_text) |txt| { + cell.fg_r = txt.r; + cell.fg_g = txt.g; + cell.fg_b = txt.b; + cell.fg_a = 255; + } else { + cell.fg_r = 0; + cell.fg_g = 0; + cell.fg_b = 0; + cell.fg_a = 255; + } } self.cells.appendAssumeCapacity(cell.*); }