Skip to content

[FEATURE REQUEST] Improve Chinese IME compatibility on Linux X11 - #15

Merged
Raiden-MeixElysia merged 2 commits into
ELY-Open-Source:mainfrom
yaoyao368345:codex/linux-x11-ime-v0.1.8
Oct 24, 2026
Merged

Raiden-MeixElysia merged 2 commits into
ELY-Open-Source:mainfrom
yaoyao368345:codex/linux-x11-ime-v0.1.8

Conversation

@yaoyao368345

Copy link
Copy Markdown
Contributor

Type

  • [FEATURE REQUEST]: a new feature or an improvement
  • [BUG REPORT]: a bug fix
  • [Other]: docs, refactoring, CI, dependencies or chores

What and why

On ELYTerminal v0.1.8 under Linux X11, committing Chinese input can terminate the application with Encoding Error: UnsupportedEncoding, while pasting Chinese text works. This improves XIM compatibility without changing application sources or the pinned GPUI version.

Cause and fix

GPUI uses zed-xim 0.4.0-zed, whose published xim-ctext 0.3.0 decoder rejects GB2312 COMPOUND_TEXT. zed-xim calls expect("Encoding Error") on the decoder result. A GB2312 fixture reproduces the panic; this does not claim to capture the user's actual XIM packet.

  • Backport the unchanged decoder source and MIT license from Riey/xim-rs at 5e18bce, including CJK decoding and transitions back to ASCII.
  • Keep local crate version 0.3.0 so the Cargo path patch satisfies zed-xim's existing requirement. The provenance, upstream version 0.4.1 and removal condition are explicit in vendor/xim-ctext/README.md.
  • Add four Linux integration tests using the same resolved decoder as GPUI. Preserve upstream vendor comments, keep the 500-line check, and include the license in the Linux tarball.
  • Add a hosted Linux IME workflow that runs project checks, decoder tests and a build as a regular user in a clean Ubuntu 22.04 container.

How it was tested

  • Locally: fmt, clippy, all 276 existing tests, four IME integration tests, nine upstream decoder tests and a locked build passed.
  • The regression fixtures cover the previously failing GB2312 commit, Chinese/ASCII mixing, UTF-8 Chinese/Emoji and plain ASCII.
  • Ubuntu 22.04 / X11 / IBus 1.5.26: the user confirmed Chinese input works in patched v0.1.8 builds. The DEB/AppImage bundlers used for that acceptance are proposed separately.
  • Wayland and other input methods remain untested for this fix.

Fork validation for this head: Linux IME run 39742838948 completed successfully (Ubuntu 22.04 container, regular user). This is fork CI; upstream PR-triggered checks are reported separately.

Checklist

  • The title starts with the requested type prefix
  • Tests and the build pass locally
  • Docs and license provenance are included

@Raiden-MeixElysia
Raiden-MeixElysia merged commit f4c65bb into ELY-Open-Source:main Oct 24, 2026
@Raiden-MeixElysia

Copy link
Copy Markdown
Contributor

Thank you, @yaoyao368345. You found the crash and its cause: zed-xim calls expect on every decode, and crates.io's xim-ctext 0.3.0 refuses GB2312. Your branch is merged in f4c65bb.

What changed after the merge:

  • Main already had a [patch.crates-io] table, for an alacritty fork. TOML takes one table of a name, so the two joined.
  • The decoder you vendored, xim-rs's, still failed on text IBus sends. ibus-x11 never calls setlocale, so libX11 writes its compound text in the C locale. There 嗎, 幫, 辦, 擊, 眾 and 佔 travel as JIS X 0212, which stopped the app at the first preedit. 夠, 產, 絕, 腳 and most Cantonese travel in Big5 or GBK extended segments, which typed %/2big5-0 into the shell. Text after a UTF-8 segment was lost.
  • 7b926dc and 715aa4e replace it with a decoder that keeps G0 and G1 across escapes and segments, as libX11's own does, and reads each set through libX11's own table. The web's tables differ: a Big5-HKSCS private-use character stopped the app, and ・ came out ·. The tables are generated from libX11 1.8.12's lcUniConv; libX11's notice sits beside them and ships in the Linux tarball, where xim-rs's license went with xim-rs's code. An error now carries its bytes, so a crash names what the input method sent.
  • Your tests became a table of bytes libX11 wrote. CI's Linux job runs them, so the second workflow went.

The decoder matched libX11's and fcitx5's own reverse conversions over 2,143,690 strings. Under Xorg in Docker, with IBus libpinyin, ELYTerminal now draws each preedit and commits 中文, 你好嗎 and 足夠. It ships in the next release.

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.

2 participants