Skip to content

Commit

Permalink
fix crash if hit "Shift + Down" at the last row in BigMonospaceTextField
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny-chung committed Nov 16, 2024
1 parent 2d27204 commit 8aaa151
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -946,14 +946,14 @@ private fun CoreBigMonospaceText(
} else {
transformedText.length
} - transformedText.findRowPositionStartIndexByRowIndex(newRow)
if (col <= newRowLength) {
val pos = if (col <= newRowLength) {
transformedText.findRowPositionStartIndexByRowIndex(newRow) + col
} else {
transformedText.findRowPositionStartIndexByRowIndex(newRow) + newRowLength
}
viewState.roundedTransformedCursorIndex(pos, CursorAdjustDirection.Bidirectional, transformedText, viewState.transformedCursorIndex, true)
}
}
newTransformedPosition = viewState.roundedTransformedCursorIndex(newTransformedPosition, CursorAdjustDirection.Bidirectional, transformedText, viewState.transformedCursorIndex, true)
updateTransformedCursorOrSelection(
newTransformedPosition = newTransformedPosition,
isSelection = it.isShiftPressed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ class BigTextViewState {
}

internal fun updateSelectionByTransformedSelection(transformedText: BigTextTransformed) {
selection = transformedText.findOriginalPositionByTransformedPosition(transformedSelection.first) ..
selection = if (transformedSelection.isEmpty()) {
EMPTY_SELECTION_RANGE
} else {
transformedText.findOriginalPositionByTransformedPosition(transformedSelection.first) ..
transformedText.findOriginalPositionByTransformedPosition(transformedSelection.last)
}
}

internal fun updateTransformedSelectionBySelection(transformedText: BigTextTransformed) {
Expand Down

0 comments on commit 8aaa151

Please sign in to comment.