@@ -125,6 +125,20 @@ describe("emitBuffer", () => {
125125 const output = emitBuffer(buf);
126126 expect(output).toContain(" ");
127127 });
128+
129+ test("wide character continuation cells are skipped", () => {
130+ const buf = new CellBuffer(5, 1);
131+ // Simulate a wide char at col 0 with continuation at col 1
132+ buf.set(0, 0, cell("\u4e16")); // CJK char (2 cols)
133+ buf.set(1, 0, cell("")); // continuation marker
134+ buf.set(2, 0, cell("x"));
135+ const output = emitBuffer(buf);
136+ // The output should contain the wide char and "x" without
137+ // an extra space between them (continuation is skipped)
138+ expect(output).toContain("\u4e16x");
139+ // Should NOT contain "\u4e16 x" (space from continuation)
140+ expect(output).not.toContain("\u4e16 x");
141+ });
128142 });
129143
130144 describe("emitDiff", () => {
@@ -183,4 +197,19 @@ describe("emitDiff", () => {
183197 const cursorMoves = output.match(/\x1b\[\d+;\d+H/g) || [];
184198 expect(cursorMoves.length).toBe(1);
185199 });
200+
201+ test("wide character continuation cells are skipped in diff", () => {
202+ const prev = new CellBuffer(5, 1);
203+ const next = new CellBuffer(5, 1);
204+ // Wide char at col 0 with continuation at col 1
205+ next.set(0, 0, cell("\u4e16"));
206+ next.set(1, 0, cell("")); // continuation
207+ next.set(2, 0, cell("x"));
208+ const output = emitDiff(prev, next);
209+ // Should emit the wide char and x without extra space
210+ expect(output).toContain("\u4e16");
211+ expect(output).toContain("x");
212+ // Continuation cell should not produce any output character
213+ expect(output).not.toContain("\u4e16 ");
214+ });
186215 });