]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
Reposition textview after composition view
authorDaniel Imms <daimms@microsoft.com>
Fri, 12 Aug 2016 17:21:41 +0000 (10:21 -0700)
committerDaniel Imms <daimms@microsoft.com>
Fri, 12 Aug 2016 17:21:41 +0000 (10:21 -0700)
Call the function again via setTimeout to allow changes after composition
events. This prevents the IME windows jumping sometimes on thesecond key
press.

Fixes #208

src/xterm.js

index 88096dffb9243c1c4a46658e13d6eb65302f92a7..3eb4fcb06dbc9698a16d73d1702725945b075fd1 100644 (file)
      * Positions the composition view on top of the cursor and the textarea just below it (so the
      * IME helper dialog is positioned correctly).
      */
-    CompositionHelper.prototype.updateCompositionElements = function() {
+    CompositionHelper.prototype.updateCompositionElements = function(dontRecurse) {
       if (!this.isComposing) {
         return;
       }
       if (cursor) {
         this.compositionView.style.left = cursor.offsetLeft + 'px';
         this.compositionView.style.top = cursor.offsetTop + 'px';
-        this.textarea.style.left = cursor.offsetLeft + 'px';
+        var compositionViewBounds = this.compositionView.getBoundingClientRect();
+        this.textarea.style.left = cursor.offsetLeft + compositionViewBounds.width + 'px';
         this.textarea.style.top = (cursor.offsetTop + cursor.offsetHeight) + 'px';
       }
+      if (!dontRecurse) {
+        setTimeout(this.updateCompositionElements.bind(this, true), 0);
+      }
     };
 
     /**