Skip to content

Commit 838385b

Browse files
committed
fix: wide char bugs in table truncation, column resize, and overlay flash
Table rendering: truncating a wide character at a column boundary now replaces it with a space instead of dropping the continuation cell and corrupting all subsequent columns. Table column resize: fixed-width columns are no longer proportionally shrunk when the table narrows — only auto-width columns absorb the deficit. Fixed columns shrink only as a last resort. Overlay flash/fade: add SetCellColors to CharacterBuffer for color-only updates that skip CleanupWideCharAt, preventing wide character pairs from being destroyed during overlay animation passes.
1 parent 41652aa commit 838385b

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

SharpConsoleUI/Helpers/ColorBlendHelper.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,9 @@ public static void ApplyColorOverlay(
5252
var newBg = BlendColor(cell.Background, overlayColor, intensity);
5353
var newFg = BlendColor(cell.Foreground, overlayColor, intensity * foregroundBlendRatio);
5454

55-
var updated = new Layout.Cell(cell.Character, newFg, newBg, cell.Decorations)
56-
{
57-
IsWideContinuation = cell.IsWideContinuation,
58-
Combiners = cell.Combiners
59-
};
60-
buffer.SetCell(x, y, updated);
55+
// Use color-only update to avoid CleanupWideCharAt destroying
56+
// wide character pairs (emoji, CJK) during overlay passes
57+
buffer.SetCellColors(x, y, newFg, newBg);
6158
}
6259
}
6360
}

SharpConsoleUI/Layout/CharacterBuffer.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,27 @@ public void SetCell(int x, int y, Cell cell)
265265
}
266266
}
267267

268+
/// <summary>
269+
/// Updates only the foreground and background colors of a cell without modifying
270+
/// the character, decorations, wide-char flags, or combiners.
271+
/// Does not trigger wide-character cleanup — safe for overlay effects (flash, fade)
272+
/// that blend colors without changing cell content.
273+
/// </summary>
274+
public void SetCellColors(int x, int y, Color foreground, Color background)
275+
{
276+
if (x < 0 || x >= Width || y < 0 || y >= Height)
277+
return;
278+
279+
ref var existing = ref _cells[x, y];
280+
if (!existing.Foreground.Equals(foreground) || !existing.Background.Equals(background))
281+
{
282+
existing.Foreground = foreground;
283+
existing.Background = background;
284+
existing.Dirty = true;
285+
ExpandDirtyRegion(x, y);
286+
}
287+
}
288+
268289
/// <summary>
269290
/// Writes a string at the specified position with the given colors.
270291
/// Wide characters occupy 2 columns with a continuation cell for the right half.

0 commit comments

Comments
 (0)