[PR #512] [CLOSED] fix(utf8): use col_offset for CJK word wrap boundary detection #589

Closed
opened 2026-03-02 23:47:14 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/512
Author: @kskang
Created: 1/11/2026
Status: Closed

Base: mainHead: fix/cjk-col-offset


📝 Commits (1)

  • 02572b3 fix: use col_offset for CJK word wrap boundary detection

📊 Changes

5 files changed (+44 additions, -6 deletions)

View changed files

📝 packages/core/src/zig/buffer.zig (+2 -2)
📝 packages/core/src/zig/edit-buffer.zig (+2 -2)
📝 packages/core/src/zig/tests/text-buffer-drawing_test.zig (+26 -0)
📝 packages/core/src/zig/text-buffer-view.zig (+2 -2)
📝 packages/core/src/zig/utf8.zig (+12 -0)

📄 Description

CJK characters have display width 2. But the code counted them as width 1 when calculating word wrap boundaries. This caused incorrect wrap positions.

Changes

  • Add col_offset field to WrapBreak struct. This field tracks display column position.
  • Use col_offset instead of char_offset in wrap boundary detection.
  • Use dynamic width calculation for non-ASCII characters in buffer drawing.

Test

  • Add native test for CJK word wrap with mixed scripts (Korean, English, Chinese, Japanese).

Fixes #255


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/512 **Author:** [@kskang](https://github.com/kskang) **Created:** 1/11/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/cjk-col-offset` --- ### 📝 Commits (1) - [`02572b3`](https://github.com/anomalyco/opentui/commit/02572b345dddeffe9af0c649f168c66f15969ed9) fix: use col_offset for CJK word wrap boundary detection ### 📊 Changes **5 files changed** (+44 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/zig/buffer.zig` (+2 -2) 📝 `packages/core/src/zig/edit-buffer.zig` (+2 -2) 📝 `packages/core/src/zig/tests/text-buffer-drawing_test.zig` (+26 -0) 📝 `packages/core/src/zig/text-buffer-view.zig` (+2 -2) 📝 `packages/core/src/zig/utf8.zig` (+12 -0) </details> ### 📄 Description CJK characters have display width 2. But the code counted them as width 1 when calculating word wrap boundaries. This caused incorrect wrap positions. ## Changes - Add `col_offset` field to `WrapBreak` struct. This field tracks display column position. - Use `col_offset` instead of `char_offset` in wrap boundary detection. - Use dynamic width calculation for non-ASCII characters in buffer drawing. ## Test - Add native test for CJK word wrap with mixed scripts (Korean, English, Chinese, Japanese). Fixes #255 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 23:47:14 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#589
No description provided.