Skip to content

Commit

Permalink
fix crash when BigTextFieldState.replaceTextAtCursor is called with…
Browse files Browse the repository at this point in the history
… a selection
  • Loading branch information
sunny-chung committed Jan 8, 2025
1 parent d6012b9 commit 6775f66
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [Unreleased]

### Fixed
UI
- Crash when `BigTextFieldState.replaceTextAtCursor` is called with a selection.


## UI [2.0.0], DS [2.0.0] - 2025-01-05

### Breaking Change
UI
- BigTextManipulator and onTextManipulatorReady are removed. Replaced by BigText, BigTextFieldState and BigTextViewState.
- Default cursor color has been changed

### New
Common
- Option to turn off soft wrap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ class BigTextFieldState(val text: BigText, val viewState: BigTextViewState) {

fun replaceTextAtCursor(newText: CharSequence, isSaveIntoUndoHistory: Boolean = true) {
if (viewState.hasSelection()) {
text.delete(viewState.selection)
val selection = viewState.selection
text.delete(selection)
viewState.setSelection(EMPTY_SELECTION_RANGE)
viewState.setCursorIndex(selection.start)
}
if (newText.isNotEmpty()) {
text.insertAt(viewState.cursorIndex, newText)
Expand Down

0 comments on commit 6775f66

Please sign in to comment.