Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -251,7 +251,43 @@ |
252 | 252 | this.hideCursor(); |
253 | 253 | } |
254 | 254 | } else if ( instruction === 'up' || instruction === 'down' ) { |
255 | | - // ... |
| 255 | + |
| 256 | + var currentPosition = this.documentView.getRenderedPositionFromOffset( this.selection.to ); |
| 257 | + |
| 258 | + if ( this.cursor.initialLeft === null ) { |
| 259 | + this.cursor.initialLeft = currentPosition.left; |
| 260 | + } |
| 261 | + |
| 262 | + var fakePosition = new es.Position( this.cursor.initialLeft, currentPosition.top ), |
| 263 | + offset, step, edge, i = 0; |
| 264 | + |
| 265 | + if ( instruction === 'up' ) { |
| 266 | + step = -5; |
| 267 | + edge = 0; |
| 268 | + } else { |
| 269 | + step = 5; |
| 270 | + edge = this.documentView.getContentLength(); |
| 271 | + } |
| 272 | + |
| 273 | + |
| 274 | + do { |
| 275 | + fakePosition.top += ++i * step; |
| 276 | + offset = this.documentView.getOffsetFromRenderedPosition( fakePosition ); |
| 277 | + fakePosition = this.documentView.getRenderedPositionFromOffset( offset ); |
| 278 | + fakePosition.left = this.cursor.initialLeft; |
| 279 | + } while ( currentPosition.top === fakePosition.top && offset !== edge ); |
| 280 | + |
| 281 | + |
| 282 | + if ( !this.keyboard.keys.shift ) { |
| 283 | + this.selection.from = this.selection.to = this.documentView.getOffsetFromRenderedPosition( fakePosition ); |
| 284 | + this.documentView.clearSelection(); |
| 285 | + this.showCursor(); |
| 286 | + } else { |
| 287 | + this.selection.to = this.documentView.getOffsetFromRenderedPosition( fakePosition ); |
| 288 | + this.documentView.drawSelection( this.selection ); |
| 289 | + this.hideCursor(); |
| 290 | + } |
| 291 | + |
256 | 292 | } else if ( instruction === 'home' ) { |
257 | 293 | var offset = this.cursor.initialBias ? this.documentView.getModel().getRelativeContentOffset( this.selection.to, -1 ) : this.selection.to; |
258 | 294 | offset = this.documentView.getRenderedLineRangeFromOffset( offset ).start; |