mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Improve logic for moving cursor up and down - especially in case of initialBias.
This commit is contained in:
parent
65afd9b610
commit
bf1b9a881f
|
@ -571,7 +571,8 @@ es.SurfaceView.prototype.moveCursor = function( direction, unit ) {
|
||||||
* reach the next/previous line
|
* reach the next/previous line
|
||||||
*/
|
*/
|
||||||
var position = this.documentView.getRenderedPositionFromOffset(
|
var position = this.documentView.getRenderedPositionFromOffset(
|
||||||
this.selection.to
|
this.selection.to,
|
||||||
|
this.cursor.initialBias
|
||||||
);
|
);
|
||||||
if ( this.cursor.initialLeft === null ) {
|
if ( this.cursor.initialLeft === null ) {
|
||||||
this.cursor.initialLeft = position.left;
|
this.cursor.initialLeft = position.left;
|
||||||
|
@ -588,7 +589,8 @@ es.SurfaceView.prototype.moveCursor = function( direction, unit ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fakePosition = this.documentView.getRenderedPositionFromOffset(
|
fakePosition = this.documentView.getRenderedPositionFromOffset(
|
||||||
this.documentView.getOffsetFromRenderedPosition( fakePosition )
|
this.documentView.getOffsetFromRenderedPosition( fakePosition ),
|
||||||
|
this.cursor.initialBias
|
||||||
);
|
);
|
||||||
fakePosition.left = this.cursor.initialLeft;
|
fakePosition.left = this.cursor.initialLeft;
|
||||||
} while ( position.top === fakePosition.top );
|
} while ( position.top === fakePosition.top );
|
||||||
|
@ -598,8 +600,13 @@ es.SurfaceView.prototype.moveCursor = function( direction, unit ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cursor.initialBias = direction === 'right' && unit === 'line' ? true : false;
|
this.cursor.initialBias = (
|
||||||
|
( direction === 'right' && unit === 'line' ) ||
|
||||||
|
( direction === 'down' && unit === 'char' ) ||
|
||||||
|
( direction === 'up' && unit === 'char' ) ) ?
|
||||||
|
true :
|
||||||
|
false;
|
||||||
|
|
||||||
if ( this.keyboard.keys.shift && this.selection.from !== to) {
|
if ( this.keyboard.keys.shift && this.selection.from !== to) {
|
||||||
this.selection.to = to;
|
this.selection.to = to;
|
||||||
this.documentView.drawSelection( this.selection );
|
this.documentView.drawSelection( this.selection );
|
||||||
|
|
Loading…
Reference in a new issue