mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-27 15:40:00 +00:00
ve.ui.CodeMirror.v6: update gutter width after CM view is updated
This fixes a bug in the 2017 editor implementation where changes to the gutter width were calculated before the gutter element was updated. This fix prevents misalignment issues when copying and pasting large amounts of content. Bug: T373649 Change-Id: I74bcbc46b0b62ff2ed138fe57d852a3cd87c22d0
This commit is contained in:
parent
8e545a27d6
commit
021a4723d5
|
@ -222,12 +222,6 @@ ve.ui.CodeMirrorAction.prototype.onDocumentPrecommit = function ( tx ) {
|
|||
store = this.surface.getModel().getDocument().getStore();
|
||||
let offset = 0;
|
||||
|
||||
const documentNode = document.querySelector( '.ve-ce-documentNode' );
|
||||
const guttersWidth = parseInt( document.querySelector( '.cm-gutters' ).offsetWidth );
|
||||
const marginProperty = this.surface.getModel().getDocument().getDir() === 'rtl' ? 'margin-right' : 'margin-left';
|
||||
// XXX: Why 6px?
|
||||
documentNode.style[ marginProperty ] = ( guttersWidth - 6 ) + 'px';
|
||||
|
||||
tx.operations.forEach( ( op ) => {
|
||||
if ( op.type === 'retain' ) {
|
||||
offset += op.length;
|
||||
|
@ -245,6 +239,8 @@ ve.ui.CodeMirrorAction.prototype.onDocumentPrecommit = function ( tx ) {
|
|||
for ( let i = replacements.length - 1; i >= 0; i-- ) {
|
||||
this.surface.mirror.view.dispatch( { changes: replacements[ i ] } );
|
||||
}
|
||||
|
||||
action.updateGutterWidth( this.surface.getModel().getDocument().getDir() );
|
||||
};
|
||||
|
||||
/* Registration */
|
||||
|
|
Loading…
Reference in a new issue