Skip to content

Commit

Permalink
Treat a string that only contains the formatting marker as empty
Browse files Browse the repository at this point in the history
  • Loading branch information
chipsnyder committed Dec 8, 2020
1 parent 873f941 commit 619f54b
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
import com.facebook.react.views.text.ReactFontManager;
import com.facebook.react.views.text.ReactTextUpdate;
import com.facebook.react.views.textinput.ReactContentSizeChangedEvent;
import com.facebook.react.views.textinput.ReactTextChangedEvent;
import com.facebook.react.views.textinput.ReactTextInputEvent;
import com.facebook.react.views.textinput.ReactTextInputManager;
import com.facebook.react.views.textinput.ScrollWatcher;

import org.wordpress.aztec.Constants;
import org.wordpress.aztec.formatting.LinkFormatter;
import org.wordpress.aztec.glideloader.GlideImageLoader;
import org.wordpress.aztec.glideloader.GlideVideoThumbnailLoader;
Expand Down Expand Up @@ -677,7 +677,7 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {


if (mPreviousText.length() == 0
&& !TextUtils.isEmpty(newText)
&& !isTextEmpty(newText)
&& !TextUtils.isEmpty(mEditText.getTagName())
&& mEditText.getSelectedStyles().isEmpty()) {

Expand All @@ -691,6 +691,12 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
}
}

// This accounts for the END_OF_BUFFER_MARKER that is added to blocks to maintain the styling, if the only char
// is the zero width marker then it is considered "empty"
private boolean isTextEmpty(String text) {
return text.length() == 0 || (text.length() == 1 && text.charAt(0) == Constants.INSTANCE.getEND_OF_BUFFER_MARKER());
}

@Override
public void afterTextChanged(Editable s) {}
}
Expand Down

0 comments on commit 619f54b

Please sign in to comment.