Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -230,28 +230,38 @@ |
231 | 231 | |
232 | 232 | es.SurfaceView.prototype.moveCursor = function( instruction ) { |
233 | 233 | this.selection.normalize(); |
| 234 | + var offset; |
234 | 235 | if ( instruction === 'left') { |
235 | 236 | if ( !this.keyboard.keys.shift ) { |
236 | | - this.selection.from = this.selection.to = this.documentView.getModel().getRelativeContentOffset( this.selection.getLength() ? this.selection.start : this.selection.to, -1 ); |
| 237 | + this.selection.from = this.selection.to = |
| 238 | + this.documentView.getModel().getRelativeContentOffset( |
| 239 | + this.selection.getLength() ? this.selection.start : this.selection.to, -1 |
| 240 | + ); |
237 | 241 | this.documentView.clearSelection(); |
238 | 242 | this.showCursor(); |
239 | 243 | } else { |
240 | | - this.selection.to = this.documentView.getModel().getRelativeContentOffset( this.selection.to, -1 ); |
| 244 | + this.selection.to = this.documentView.getModel().getRelativeContentOffset( |
| 245 | + this.selection.to, -1 |
| 246 | + ); |
241 | 247 | this.documentView.drawSelection( this.selection ); |
242 | 248 | this.hideCursor(); |
243 | 249 | } |
244 | 250 | } else if ( instruction === 'right' ) { |
245 | 251 | if ( !this.keyboard.keys.shift ) { |
246 | | - this.selection.from = this.selection.to = this.documentView.getModel().getRelativeContentOffset( this.selection.getLength() ? this.selection.end : this.selection.to, 1 ); |
| 252 | + this.selection.from = this.selection.to = |
| 253 | + this.documentView.getModel().getRelativeContentOffset( |
| 254 | + this.selection.getLength() ? this.selection.end : this.selection.to, 1 |
| 255 | + ); |
247 | 256 | this.documentView.clearSelection(); |
248 | 257 | this.showCursor(); |
249 | 258 | } else { |
250 | | - this.selection.to = this.documentView.getModel().getRelativeContentOffset( this.selection.to, 1 ); |
| 259 | + this.selection.to = this.documentView.getModel().getRelativeContentOffset( |
| 260 | + this.selection.to, 1 |
| 261 | + ); |
251 | 262 | this.documentView.drawSelection( this.selection ); |
252 | 263 | this.hideCursor(); |
253 | 264 | } |
254 | 265 | } else if ( instruction === 'up' || instruction === 'down' ) { |
255 | | - |
256 | 266 | var currentPosition = this.documentView.getRenderedPositionFromOffset( this.selection.to ); |
257 | 267 | |
258 | 268 | if ( this.cursor.initialLeft === null ) { |
— | — | @@ -259,8 +269,10 @@ |
260 | 270 | } |
261 | 271 | |
262 | 272 | var fakePosition = new es.Position( this.cursor.initialLeft, currentPosition.top ), |
263 | | - offset, step, edge, i = 0; |
264 | | - |
| 273 | + step, |
| 274 | + edge, |
| 275 | + i = 0; |
| 276 | + |
265 | 277 | if ( instruction === 'up' ) { |
266 | 278 | step = -5; |
267 | 279 | edge = 0; |
— | — | @@ -269,7 +281,6 @@ |
270 | 282 | edge = this.documentView.getContentLength(); |
271 | 283 | } |
272 | 284 | |
273 | | - |
274 | 285 | do { |
275 | 286 | fakePosition.top += ++i * step; |
276 | 287 | offset = this.documentView.getOffsetFromRenderedPosition( fakePosition ); |
— | — | @@ -277,9 +288,9 @@ |
278 | 289 | fakePosition.left = this.cursor.initialLeft; |
279 | 290 | } while ( currentPosition.top === fakePosition.top && offset !== edge ); |
280 | 291 | |
281 | | - |
282 | 292 | if ( !this.keyboard.keys.shift ) { |
283 | | - this.selection.from = this.selection.to = this.documentView.getOffsetFromRenderedPosition( fakePosition ); |
| 293 | + this.selection.from = this.selection.to = |
| 294 | + this.documentView.getOffsetFromRenderedPosition( fakePosition ); |
284 | 295 | this.documentView.clearSelection(); |
285 | 296 | this.showCursor(); |
286 | 297 | } else { |
— | — | @@ -287,10 +298,12 @@ |
288 | 299 | this.documentView.drawSelection( this.selection ); |
289 | 300 | this.hideCursor(); |
290 | 301 | } |
291 | | - |
292 | 302 | } else if ( instruction === 'home' ) { |
293 | | - var offset = this.cursor.initialBias ? this.documentView.getModel().getRelativeContentOffset( this.selection.to, -1 ) : this.selection.to; |
294 | | - offset = this.documentView.getRenderedLineRangeFromOffset( offset ).start; |
| 303 | + offset = this.documentView.getRenderedLineRangeFromOffset( |
| 304 | + this.cursor.initialBias ? |
| 305 | + this.documentView.getModel().getRelativeContentOffset( this.selection.to, -1 ) : |
| 306 | + this.selection.to |
| 307 | + ).start; |
295 | 308 | if ( !this.keyboard.keys.shift ) { |
296 | 309 | this.selection.from = this.selection.to = offset; |
297 | 310 | this.documentView.clearSelection(); |
— | — | @@ -301,8 +314,11 @@ |
302 | 315 | this.hideCursor(); |
303 | 316 | } |
304 | 317 | } else if ( instruction === 'end' ) { |
305 | | - var offset = this.cursor.initialBias ? this.documentView.getModel().getRelativeContentOffset( this.selection.to, -1 ) : this.selection.to; |
306 | | - offset = this.documentView.getRenderedLineRangeFromOffset( offset ).end; |
| 318 | + offset = this.documentView.getRenderedLineRangeFromOffset( |
| 319 | + this.cursor.initialBias ? |
| 320 | + this.documentView.getModel().getRelativeContentOffset( this.selection.to, -1 ) : |
| 321 | + this.selection.to |
| 322 | + ).end; |
307 | 323 | if ( !this.keyboard.keys.shift ) { |
308 | 324 | this.selection.from = this.selection.to = offset; |
309 | 325 | this.documentView.clearSelection(); |