Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -323,7 +323,6 @@ |
324 | 324 | } |
325 | 325 | break; |
326 | 326 | case 8: // Backspace |
327 | | - this.cursor.initialBias = this.cursor.initialLeft = null; |
328 | 327 | if ( this.selection.from === this.selection.to ) { |
329 | 328 | var sourceOffset = this.selection.to, |
330 | 329 | targetOffset = this.documentView.getModel().getRelativeContentOffset( sourceOffset, -1), |
— | — | @@ -370,7 +369,6 @@ |
371 | 370 | } |
372 | 371 | break; |
373 | 372 | case 46: // Delete |
374 | | - this.cursor.initialBias = this.cursor.initialLeft = null; |
375 | 373 | if ( this.selection.from === this.selection.to ) { |
376 | 374 | var sourceOffset = this.documentView.getModel().getRelativeContentOffset( this.selection.to, 1), |
377 | 375 | targetOffset = this.selection.to, |
— | — | @@ -415,7 +413,6 @@ |
416 | 414 | } |
417 | 415 | break; |
418 | 416 | case 13: // Enter |
419 | | - this.cursor.initialBias = this.cursor.initialLeft = null; |
420 | 417 | if ( this.selection.from === this.selection.to ) { |
421 | 418 | var node = this.documentView.getNodeFromOffset( this.selection.to, false ), |
422 | 419 | nodeOffset = this.documentView.getOffsetFromNode( node, false ); |
— | — | @@ -454,7 +451,6 @@ |
455 | 452 | e.preventDefault(); |
456 | 453 | break; |
457 | 454 | default: // Insert content (maybe) |
458 | | - this.cursor.initialBias = this.cursor.initialLeft = null; |
459 | 455 | if ( this.keyboard.keydownTimeout ) { |
460 | 456 | clearTimeout( this.keyboard.keydownTimeout ); |
461 | 457 | } |
— | — | @@ -578,6 +574,7 @@ |
579 | 575 | this.selection.to, |
580 | 576 | this.cursor.initialBias |
581 | 577 | ); |
| 578 | + |
582 | 579 | if ( this.cursor.initialLeft === null ) { |
583 | 580 | this.cursor.initialLeft = position.left; |
584 | 581 | } |
— | — | @@ -585,6 +582,9 @@ |
586 | 583 | i = 0, |
587 | 584 | step = direction === 'up' ? -5 : 5, |
588 | 585 | top = this.$.position().top; |
| 586 | + |
| 587 | + this.cursor.initialBias = position.left > this.documentView.getNodeFromOffset( this.selection.to, false ).contentView.$.offset().left; |
| 588 | + |
589 | 589 | do { |
590 | 590 | fakePosition.top += ++i * step; |
591 | 591 | if ( fakePosition.top < top ) { |
— | — | @@ -592,29 +592,10 @@ |
593 | 593 | } else if (fakePosition.top > top + this.dimensions.height + this.dimensions.scrollTop ) { |
594 | 594 | break; |
595 | 595 | } |
596 | | - offset = this.documentView.getOffsetFromRenderedPosition( fakePosition ); |
597 | | - fakePosition1 = this.documentView.getRenderedPositionFromOffset( |
598 | | - offset, |
599 | | - false |
| 596 | + fakePosition = this.documentView.getRenderedPositionFromOffset( |
| 597 | + this.documentView.getOffsetFromRenderedPosition( fakePosition ), |
| 598 | + this.cursor.initialBias |
600 | 599 | ); |
601 | | - fakePosition2 = this.documentView.getRenderedPositionFromOffset( |
602 | | - offset, |
603 | | - true |
604 | | - ); |
605 | | - |
606 | | - if(this.cursor.initialBias) { |
607 | | - if(fakePosition1.top != fakePosition2.top) { |
608 | | - fakePosition = fakePosition2; |
609 | | - newBias = true; |
610 | | - } else { |
611 | | - fakePosition = fakePosition1; |
612 | | - //newBias = true; |
613 | | - } |
614 | | - } else { |
615 | | - fakePosition = fakePosition1; |
616 | | - newBias = false; |
617 | | - } |
618 | | - |
619 | 600 | fakePosition.left = this.cursor.initialLeft; |
620 | 601 | } while ( position.top === fakePosition.top ); |
621 | 602 | to = this.documentView.getOffsetFromRenderedPosition( fakePosition ); |
— | — | @@ -623,12 +604,8 @@ |
624 | 605 | break; |
625 | 606 | } |
626 | 607 | |
627 | | - if(typeof newBias !== 'undefined') { |
628 | | - this.cursor.initialBias = newBias; |
629 | | - } |
630 | | - |
631 | 608 | if( direction != 'up' && direction != 'down' ) { |
632 | | - this.cursor.initialBias = direction === 'right' && unit === 'line' ? true : false; |
| 609 | + this.cursor.initialBias = direction === 'right' && unit === 'line' ? true : false; |
633 | 610 | } |
634 | 611 | |
635 | 612 | if ( this.keyboard.keys.shift && this.selection.from !== to) { |