diff --git a/src/CompositionHelper.js b/src/CompositionHelper.js index 763994949d..3ce3835f13 100644 --- a/src/CompositionHelper.js +++ b/src/CompositionHelper.js @@ -178,11 +178,18 @@ CompositionHelper.prototype.updateCompositionElements = function(dontRecurse) { } var cursor = this.terminal.element.querySelector('.terminal-cursor'); if (cursor) { + // Take .xterm-rows offsetTop into account as well in case it's positioned absolutely within + // the .xterm element. + var xtermRows = this.terminal.element.querySelector('.xterm-rows'); + var cursorTop = xtermRows.offsetTop + cursor.offsetTop; + this.compositionView.style.left = cursor.offsetLeft + 'px'; - this.compositionView.style.top = cursor.offsetTop + 'px'; + this.compositionView.style.top = cursorTop + 'px'; + this.compositionView.style.height = cursor.offsetHeight + 'px'; + this.compositionView.style.lineHeight = cursor.offsetHeight + 'px'; var compositionViewBounds = this.compositionView.getBoundingClientRect(); this.textarea.style.left = cursor.offsetLeft + compositionViewBounds.width + 'px'; - this.textarea.style.top = (cursor.offsetTop + cursor.offsetHeight) + 'px'; + this.textarea.style.top = cursor.cursorTop + 'px'; } if (!dontRecurse) { setTimeout(this.updateCompositionElements.bind(this, true), 0);