@@ -416,7 +416,7 @@ static void JumpToStartOrEndOfLine(bool toStart)
416416 {
417417 // Determine the current and next line
418418 UILineInfo thisline = default ;
419- UILineInfo nextLine = default ;
419+ UILineInfo ? nextLine = null ;
420420 for ( int i = 0 ; i < Input . Component . cachedInputTextGenerator . lineCount ; i ++ )
421421 {
422422 UILineInfo line = Input . Component . cachedInputTextGenerator . lines [ i ] ;
@@ -431,25 +431,26 @@ static void JumpToStartOrEndOfLine(bool toStart)
431431
432432 if ( toStart )
433433 {
434- // Determine where the non-whitespace text begins
435- int nonWhitespaceStartIdx = thisline . startCharIdx ;
436- while ( char . IsWhiteSpace ( Input . Text [ nonWhitespaceStartIdx ] ) )
437- nonWhitespaceStartIdx ++ ;
434+ // Determine where the indented text begins
435+ int endOfLine = nextLine == null ? Input . Text . Length : nextLine . Value . startCharIdx ;
436+ int indentedStart = thisline . startCharIdx ;
437+ while ( indentedStart < endOfLine - 1 && char . IsWhiteSpace ( Input . Text [ indentedStart ] ) )
438+ indentedStart ++ ;
438439
439440 // Jump to either the true start or the non-whitespace position,
440441 // depending on which one we are not at.
441- if ( LastCaretPosition == nonWhitespaceStartIdx )
442+ if ( LastCaretPosition == indentedStart )
442443 SetCaretPosition ( thisline . startCharIdx ) ;
443444 else
444- SetCaretPosition ( nonWhitespaceStartIdx ) ;
445+ SetCaretPosition ( indentedStart ) ;
445446 }
446447 else
447448 {
448449 // If there is no next line, jump to the end of this line (+1, to the invisible next character position)
449- if ( nextLine . startCharIdx <= 0 )
450+ if ( nextLine == null )
450451 SetCaretPosition ( Input . Text . Length ) ;
451452 else // jump to the next line start index - 1, ie. end of this line
452- SetCaretPosition ( nextLine . startCharIdx - 1 ) ;
453+ SetCaretPosition ( nextLine . Value . startCharIdx - 1 ) ;
453454 }
454455 }
455456
0 commit comments