@@ -281,6 +281,25 @@ export class Terminal extends CoreTerminal implements ITerminal {
281281 this . _onBlur . fire ( ) ;
282282 }
283283
284+ private _syncTextArea ( ) : void {
285+ if ( ! this . textarea || ! this . buffer . isCursorInViewport || this . _compositionHelper ! . isComposing ) {
286+ return ;
287+ }
288+
289+ const cellHeight = Math . ceil ( this . _charSizeService ! . height * this . optionsService . options . lineHeight ) ;
290+ const cursorTop = this . _bufferService . buffer . y * cellHeight ;
291+ const cursorLeft = this . _bufferService . buffer . x * this . _charSizeService ! . width ;
292+
293+ // Sync the textarea to the exact position of the composition view so the IME knows where the
294+ // text is.
295+ this . textarea . style . left = cursorLeft + 'px' ;
296+ this . textarea . style . top = cursorTop + 'px' ;
297+ this . textarea . style . width = this . _charSizeService ! . width + 'px' ;
298+ this . textarea . style . height = cellHeight + 'px' ;
299+ this . textarea . style . lineHeight = cellHeight + 'px' ;
300+ this . textarea . style . zIndex = '-5' ;
301+ }
302+
284303 /**
285304 * Initialize default behavior
286305 */
@@ -436,7 +455,10 @@ export class Terminal extends CoreTerminal implements ITerminal {
436455 this . register ( this . _inputHandler . onRequestSyncScrollBar ( ( ) => this . viewport ! . syncScrollArea ( ) ) ) ;
437456 this . register ( this . viewport ) ;
438457
439- this . register ( this . onCursorMove ( ( ) => this . _renderService ! . onCursorMove ( ) ) ) ;
458+ this . register ( this . onCursorMove ( ( ) => {
459+ this . _renderService ! . onCursorMove ( ) ;
460+ this . _syncTextArea ( ) ;
461+ } ) ) ;
440462 this . register ( this . onResize ( ( ) => this . _renderService ! . onResize ( this . cols , this . rows ) ) ) ;
441463 this . register ( this . onBlur ( ( ) => this . _renderService ! . onBlur ( ) ) ) ;
442464 this . register ( this . onFocus ( ( ) => this . _renderService ! . onFocus ( ) ) ) ;
0 commit comments