From 12a029127982959c2f36816990855df96390f4ba Mon Sep 17 00:00:00 2001 From: mesalogo Date: Sat, 10 Oct 2026 12:55:18 +0800 Subject: [PATCH] fix(terminal): contain IME composition layout --- src/renderer/src/TerminalPanel.test.tsx | 12 ++++++++++++ src/renderer/src/terminal-panel.css | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/renderer/src/TerminalPanel.test.tsx b/src/renderer/src/TerminalPanel.test.tsx index ad6394bc..62f97a17 100644 --- a/src/renderer/src/TerminalPanel.test.tsx +++ b/src/renderer/src/TerminalPanel.test.tsx @@ -221,6 +221,18 @@ describe('TerminalPanel', () => { ) }) + it('contains IME composition layout inside the terminal', () => { + expect(terminalStylesheet).toMatch( + /\.terminal-panel__emulator\s*\{[^}]*contain:\s*size layout paint;[^}]*overflow-anchor:\s*none;/u + ) + expect(terminalStylesheet).toMatch( + /\.terminal-panel__emulator \.xterm\s*\{[^}]*width:\s*100%;[^}]*max-width:\s*100%;[^}]*overflow:\s*hidden;/u + ) + expect(terminalStylesheet).toMatch( + /\.terminal-panel__emulator \.xterm-helpers\s*\{[^}]*max-width:\s*0;[^}]*overflow:\s*visible;/u + ) + }) + it('creates only after the first valid fitted size and forwards input', async () => { const backend = adapterHarness() const emulator = emulatorHarness() diff --git a/src/renderer/src/terminal-panel.css b/src/renderer/src/terminal-panel.css index acc2d25e..806e6bbd 100644 --- a/src/renderer/src/terminal-panel.css +++ b/src/renderer/src/terminal-panel.css @@ -116,11 +116,24 @@ flex: 1; padding: 0; overflow: hidden; + contain: size layout paint; + overflow-anchor: none; background: var(--surface-canvas); } .terminal-panel__emulator .xterm { + position: relative; + width: 100%; + min-width: 0; + max-width: 100%; height: 100%; + overflow: hidden; +} + +/* IME composition must stay inside the terminal's own scroll boundary. */ +.terminal-panel__emulator .xterm-helpers { + max-width: 0; + overflow: visible; } .terminal-panel__status {