Avoid dirty diffs when editing code blocks with line numbers

Steps to reproduce:
* Make a wikitext page with <syntaxhighlight line="sure">…</…>.
* Edit with VisualEditor and make an unrelated change to the content.
* Save.
* Before the attribute was always replaced with line="1".
* With this patch the old value stays untouched.

Change-Id: I433a206905c1a0a1bc06ef8b4037f6db9d935810
This commit is contained in:
thiemowmde 2022-10-26 12:54:59 +02:00 committed by Thiemo Kreuz (WMDE)
parent fb95fb983b
commit 0b13847937

View file

@ -179,6 +179,11 @@ ve.ui.MWSyntaxHighlightWindow.prototype.updateMwData = function ( mwData ) {
startLine = this.startLineNumber.getValue(); startLine = this.startLineNumber.getValue();
mwData.attrs.lang = language || undefined; mwData.attrs.lang = language || undefined;
mwData.attrs.line = showLines ? '1' : undefined; if ( !showLines ) {
delete mwData.attrs.line;
// Keep whatever value was there before to not cause dirty diffs
} else if ( !( 'line' in mwData.attrs ) ) {
mwData.attrs.line = '1';
}
mwData.attrs.start = startLine !== '' ? startLine : undefined; mwData.attrs.start = startLine !== '' ? startLine : undefined;
}; };