Skip to content

Commit 8added2

Browse files
authored
Merge pull request #928 from wordpress-mobile/gutenberg/issue/1663-heading-block
[Gutenberg] Account for the end of buffer marker
2 parents f65933f + 743803f commit 8added2

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/AztecText.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,9 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
632632

633633
val emptyEditTextBackspaceDetector = InputFilter { source, start, end, dest, dstart, dend ->
634634
if (selectionStart == 0 && selectionEnd == 0
635-
&& end == 0 && start == 0
635+
&& start == 0
636636
&& dstart == 0 && dend == 0
637+
&& isCleanStringEmpty(source)
637638
&& !isHandlingBackspaceEvent) {
638639
isHandlingBackspaceEvent = true
639640

@@ -654,6 +655,14 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
654655
}
655656
}
656657

658+
private fun isCleanStringEmpty(text: CharSequence): Boolean {
659+
if ( isInGutenbergMode ) {
660+
return (text.count() == 1 && text[0] == Constants.END_OF_BUFFER_MARKER)
661+
} else {
662+
return text.count() == 0
663+
}
664+
}
665+
657666
private fun handleBackspaceAndEnter(event: KeyEvent): Boolean {
658667
if (event.action == KeyEvent.ACTION_DOWN && event.keyCode == KeyEvent.KEYCODE_ENTER) {
659668
// Check if the external listener has consumed the enter pressed event

0 commit comments

Comments
 (0)