Skip to content

Commit

Permalink
Improve handling of selection of empty editor with only END_OF_BUFFER…
Browse files Browse the repository at this point in the history
…_MARKER.
  • Loading branch information
khaykov committed Nov 27, 2024
1 parent 806c3a4 commit e5dacfe
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,10 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
}

if (length() != 0) {
if((length() == 1 && text[0] == Constants.END_OF_BUFFER_MARKER)){
return
}

// if the text end has the marker, let's make sure the cursor never includes it or surpasses it
if ((selStart == length() || selEnd == length()) && text[length() - 1] == Constants.END_OF_BUFFER_MARKER) {
var start = selStart
Expand Down Expand Up @@ -1972,14 +1976,6 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
return super.onTextContextMenuItem(id)
}
}
android.R.id.selectAll -> {
return if (text.toString() == Constants.END_OF_BUFFER_MARKER.toString()) {
deleteInlineStyleFromTheBeginning()
return true
} else {
super.onTextContextMenuItem(id)
}
}
else -> return super.onTextContextMenuItem(id)
}

Expand Down

0 comments on commit e5dacfe

Please sign in to comment.