Skip to content

FillRect Corrupts Wide Characters When Overlapping #4466

@tig

Description

@tig

Original Issue:
Image

When OutputBufferImpl.FillRect() overwrites cells containing wide characters (e.g., Chinese text), it directly sets cell contents without properly handling wide character invalidation. This causes visual corruption when UI elements like MessageBox borders are drawn over wide character content.

Reproduction

  1. Display Chinese text (e.g., "你好呀") in a view
  2. Draw a MessageBox that overlaps the text
  3. Move mouse over the MessageBox border (triggers HighlightState changes and redraws)
  4. Observe corrupted rendering where wide characters are partially overwritten

See the ChineseUI scenario in UICatalog for a concrete example.

Root Cause

Without Fix:

  • FillRect() directly assigns cell values without calling AddStr()
  • Wide characters that get partially overwritten are not invalidated
  • Adjacent cells are not marked dirty
  • The second column of a wide character retains stale data

In OutputBufferImpl.FillRect():

#else
Contents [r, c] = new ()
{
    Grapheme = rune != default (Rune) ? rune.ToString () : " ",
    Attribute = CurrentAttribute, 
    IsDirty = true
};
#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions