Skip to content

feat(core): allow soft wraps between CJK characters#1143

Open
imnotlxy wants to merge 1 commit into
anomalyco:mainfrom
imnotlxy:main
Open

feat(core): allow soft wraps between CJK characters#1143
imnotlxy wants to merge 1 commit into
anomalyco:mainfrom
imnotlxy:main

Conversation

@imnotlxy

@imnotlxy imnotlxy commented Jun 2, 2026

Copy link
Copy Markdown

Line wraps are allowed between any CJK characters. Take this new test case as an example:

test "TextBufferView word wrapping - CJK graphemes fill line after punctuation" {
    const pool = gp.initGlobalPool(std.testing.allocator);
    defer gp.deinitGlobalPool();
    const link_pool = link.initGlobalLinkPool(std.testing.allocator);
    defer link.deinitGlobalLinkPool();

    var tb = try TextBuffer.init(std.testing.allocator, pool, link_pool, .wcwidth);
    defer tb.deinit();

    var view = try TextBufferView.init(std.testing.allocator, tb);
    defer view.deinit();

    try tb.setText("一二,三四五六七");

    view.setWrapMode(.word);
    view.setWrapWidth(10);

    const lines = view.getVirtualLines();
    try std.testing.expectEqual(@as(usize, 2), lines.len);
    try std.testing.expectEqual(@as(u32, 10), lines[0].width_cols);
    try std.testing.expectEqual(@as(u32, 6), lines[1].width_cols);
}

Before:

一二, <- line wrapped here
三四五六七

After:

一二,三四 <- line wrapped here
五六七

---------

Assisted-by: Zed:gpt-5.5
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.

1 participant