From 55281022a0a54e46db1727ef62bdb769ae899b7e Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Mon, 9 Mar 2026 14:32:38 -0700 Subject: [PATCH] Fix IME composition text overflowing terminal --- src/browser/input/CompositionHelper.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/browser/input/CompositionHelper.ts b/src/browser/input/CompositionHelper.ts index b4b03a842..d170eae3b 100644 --- a/src/browser/input/CompositionHelper.ts +++ b/src/browser/input/CompositionHelper.ts @@ -239,6 +239,12 @@ export class CompositionHelper { this._compositionView.style.lineHeight = cellHeight + 'px'; this._compositionView.style.fontFamily = this._optionsService.rawOptions.fontFamily; this._compositionView.style.fontSize = this._optionsService.rawOptions.fontSize + 'px'; + // Limit the composition view width to the space between the cursor and + // the terminal's right edge, preventing it from overflowing the terminal. + const maxWidth = this._bufferService.cols * this._renderService.dimensions.css.cell.width - cursorLeft; + this._compositionView.style.maxWidth = maxWidth + 'px'; + this._compositionView.style.overflow = 'hidden'; + this._compositionView.style.direction = 'rtl'; // Sync the textarea to the exact position of the composition view so the IME knows where the // text is. const compositionViewBounds = this._compositionView.getBoundingClientRect();