@@ -282,13 +282,7 @@ func (self *TextArea) GoToEndOfLine() {
282
282
283
283
self .cursor = self .closestNewlineOnRight ()
284
284
285
- // If the end of line is a soft line break, we need to move left by one so
286
- // that we end up at the last whitespace before the line break. Otherwise
287
- // we'd be at the start of the next line, since the newline character
288
- // doesn't really exist in the real content.
289
- if self .cursor < len (self .content ) && self .content [self .cursor ] != '\n' {
290
- self .cursor --
291
- }
285
+ self .moveLeftFromSoftLineBreak ()
292
286
}
293
287
294
288
func (self * TextArea ) closestNewlineOnRight () int {
@@ -303,6 +297,16 @@ func (self *TextArea) closestNewlineOnRight() int {
303
297
return len (self .content )
304
298
}
305
299
300
+ func (self * TextArea ) moveLeftFromSoftLineBreak () {
301
+ // If the end of line is a soft line break, we need to move left by one so
302
+ // that we end up at the last whitespace before the line break. Otherwise
303
+ // we'd be at the start of the next line, since the newline character
304
+ // doesn't really exist in the real content.
305
+ if self .cursor < len (self .content ) && self .content [self .cursor ] != '\n' {
306
+ self .cursor --
307
+ }
308
+ }
309
+
306
310
func (self * TextArea ) atLineStart () bool {
307
311
return self .cursor == 0 ||
308
312
(len (self .content ) > self .cursor - 1 && self .content [self .cursor - 1 ] == '\n' )
@@ -420,12 +424,16 @@ func (self *TextArea) SetCursor2D(x int, y int) {
420
424
for _ , r := range self .wrappedContent {
421
425
if x <= 0 && y == 0 {
422
426
self .cursor = self .wrappedCursorToOrigCursor (newCursor )
427
+ if self .wrappedContent [newCursor ] == '\n' {
428
+ self .moveLeftFromSoftLineBreak ()
429
+ }
423
430
return
424
431
}
425
432
426
433
if r == '\n' {
427
434
if y == 0 {
428
435
self .cursor = self .wrappedCursorToOrigCursor (newCursor )
436
+ self .moveLeftFromSoftLineBreak ()
429
437
return
430
438
}
431
439
y --
0 commit comments