From 8e3d96f75f397426754143fe3865ea8d686d3d45 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Sun, 25 Feb 2018 18:05:19 +0000 Subject: [PATCH] Defer update of CM surface to avoid invisible text Bug: T185184 Change-Id: I0b115d892ab322911c895dda030b77f35cc9195a --- .../modules/ve-cm/ve.ui.CodeMirrorAction.js | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/resources/modules/ve-cm/ve.ui.CodeMirrorAction.js b/resources/modules/ve-cm/ve.ui.CodeMirrorAction.js index cadcc721..8530e159 100644 --- a/resources/modules/ve-cm/ve.ui.CodeMirrorAction.js +++ b/resources/modules/ve-cm/ve.ui.CodeMirrorAction.js @@ -125,8 +125,7 @@ ve.ui.CodeMirrorAction.prototype.onLangChange = function () { * @param {ve.dm.Transaction} tx [description] */ ve.ui.CodeMirrorAction.prototype.onDocumentPrecommit = function ( tx ) { - var i, - offset = 0, + var offset = 0, replacements = [], linearData = this.surface.getModel().getDocument().data, store = linearData.getStore(), @@ -158,14 +157,18 @@ ve.ui.CodeMirrorAction.prototype.onDocumentPrecommit = function ( tx ) { } } ); - // Apply replacements in reverse to avoid having to shift offsets - for ( i = replacements.length - 1; i >= 0; i-- ) { - mirror.replaceRange( - replacements[ i ].data, - replacements[ i ].start, - replacements[ i ].end - ); - } + // Defer to allow to VE surface to update rendering to correct size (T185184) + setTimeout( function () { + var i; + // Apply replacements in reverse to avoid having to shift offsets + for ( i = replacements.length - 1; i >= 0; i-- ) { + mirror.replaceRange( + replacements[ i ].data, + replacements[ i ].start, + replacements[ i ].end + ); + } + } ); }; /* Registration */