Skip to content

fix(core): validate preserved overlay character width#839

Open
AbigailJixiangyuyu wants to merge 6 commits intoanomalyco:mainfrom
AbigailJixiangyuyu:fix/cjk-overlay-width
Open

fix(core): validate preserved overlay character width#839
AbigailJixiangyuyu wants to merge 6 commits intoanomalyco:mainfrom
AbigailJixiangyuyu:fix/cjk-overlay-width

Conversation

@AbigailJixiangyuyu
Copy link
Copy Markdown
Contributor

@AbigailJixiangyuyu AbigailJixiangyuyu commented Mar 20, 2026

Issue for this PR

Closes #837

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

  • In packages/core/src/tests/absolute-positioning.snapshot.test.ts, it adds regression tests covering transparent and zero-sized absolute overlays over text like Hello 中文 world.
  • In packages/core/src/zig/buffer.zig, it updates overlay preservation logic so underlying double-width characters are treated as valid preserved content, not just width-1 characters.

How did you verify your code works?

Tested locally with bun test packages/core/src/tests/absolute-positioning.snapshot.test.ts --test-name-pattern "Overlay regression".

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@simonklee
Copy link
Copy Markdown
Member

Thanks for attempting to fix this. I don't think this is the right approach, though.

family.mp4

@AbigailJixiangyuyu
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback. I’ll revisit the issue and try to come up with a better fix.

@AbigailJixiangyuyu
Copy link
Copy Markdown
Contributor Author

When a dirty cell belongs to a wide grapheme continuation, redraw the full grapheme from its start cell instead of handling the continuation cell in isolation.

@AbigailJixiangyuyu
Copy link
Copy Markdown
Contributor Author

PixPin_2026-03-21_01-27-36.mp4

@aarcamp
Copy link
Copy Markdown
Contributor

aarcamp commented Mar 27, 2026

Please see #791 for a different solution. Among other issues it solves the distortion problem around the overlay box edges which are seen in the last screen recording posted here. It's quite tricky because narrow and wide characters can share the same column of cells in the terminal, meaning to keep straight edges on the boxes, you need to reserve a 1-cell perimeter, and apply it on all 4 sides to keep things even. You also have to consider the case where the border attribute is enabled on the box, in which case you can use that as the perimeter instead. Further, you need to detect when the box edges don't touch any wide characters, so you can forego the perimeter when only narrow characters surround the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CJK text rendered underneath a popup/overlay gets hidden or overwritten

3 participants