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();