Skip to content

CJK (Chinese/Japanese/Korean) characters display incorrectly - missing characters #39

Description

@willzhqiang

Summary

First off, love the concept of spice-edit! The idea that in the age of AI agents we don't need to memorize tons of hotkeys and can just point-and-click in the terminal is brilliant.

However, I noticed that CJK (Chinese/Japanese/Korean) characters are not rendering correctly. It appears that every other character is being dropped/hidden, likely because CJK characters are "wide characters" that occupy 2 terminal columns, but spice-edit seems to be treating them as single-width.

Steps to Reproduce

  1. Create a file with a CJK filename and CJK content:
    echo "中文测试" > /tmp/中文测试.txt
  2. Open the directory in spice-edit:
    spiceedit /tmp/

Expected Behavior

  • Filename in explorer: 中文测试.txt
  • File content: 中文测试

Actual Behavior

  • Filename in explorer: 中 测.txt (2nd and 4th characters missing)
  • File content: 中 测 (same issue)

It seems like the width calculation assumes each character is 1 column wide, but CJK characters are 2 columns wide (so-called "fullwidth" or "wide" characters). This causes the rendering to consume the space of the next character.

Environment

  • macOS
  • Terminal: Kitty (but likely reproducible in any terminal)
  • Locale: UTF-8

Possible Cause

Most terminal UI libraries need to use a Unicode width library (e.g., Go's golang.org/x/text/width or go-runewidth) to correctly calculate the display width of characters. CJK characters have East_Asian_Width property of W (Wide) or F (Fullwidth), meaning they take 2 cells in a terminal.

Thanks for the great project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions