Replace x.slice(0,x.length-y) with x.slice(0,-y)

Requires y to be non-zero.

Change-Id: I033732cb78b5e3149ac26e19243bf21b143eb105
This commit is contained in:
Ed Sanders 2024-12-02 18:06:01 +00:00
parent b222377bd7
commit 3a9c8f78ba

View file

@ -29,10 +29,14 @@ OO.inheritClass( ve.ui.MWPreTextInputWidget, ve.ui.WhitespacePreservingTextInput
*/ */
ve.ui.MWPreTextInputWidget.prototype.setValueAndWhitespace = function ( value ) { ve.ui.MWPreTextInputWidget.prototype.setValueAndWhitespace = function ( value ) {
this.whitespace[ 0 ] = value.match( /^\n?/ )[ 0 ]; this.whitespace[ 0 ] = value.match( /^\n?/ )[ 0 ];
if ( this.whitespace[ 0 ] ) {
value = value.slice( this.whitespace[ 0 ].length ); value = value.slice( this.whitespace[ 0 ].length );
}
this.whitespace[ 1 ] = value.match( /\n?$/ )[ 0 ]; this.whitespace[ 1 ] = value.match( /\n?$/ )[ 0 ];
value = value.slice( 0, value.length - this.whitespace[ 1 ].length ); if ( this.whitespace[ 1 ] ) {
value = value.slice( 0, -this.whitespace[ 1 ].length );
}
this.setValue( value ); this.setValue( value );
}; };