Prevent execution of InputFilter for new lines #809
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix
Fixes #808
This PR avoids handling a
new line
addition within the InputFilter introduced in #801, especially as it was causing a problem in Span handling when such an insertion was properly being made byFullWidthImageElementWatcher
in its methodinsertVisualNewline()
, in occasion of making images separated from paragraphs as per the existing implementation of Aztec in the mentionedTextWatcher
.Explanation
Managed to reproduce this one finding a smaller case - it seemed to me that Aztec was trying to insert an image before a paragraph ending tag, and this is where things seemingly went wrong. Got the hint from looking into the logs of session
5CB4AFF902DF000142875D0BC9D164D7_DNE_0_v2
in case5c94288ef8b88c296305c342-fabric
.Using this following HTML code as per a blog Post body on WPAndroid:
<p style="box-sizing:border-box;">This is just a test.</p>
This is just a test|.
First of all, the filter shouldn't be activated by this condition, as this is not what we wanted to capture originally. The situation that we meant to capture was the addition of a character right before an
AztecImageSpan
, and this is effectively an insertion of a character but it's being done artificially (and on purpose) by Aztec during this operation as can be seen in the stacktrace.See specifically:
So, this PR lets that particular situation happen as it shouldn't be captured by the InputFilter.
Test
Using WPAndroid on Android 8.0 or 8.1, make sure to use the commit hash
aztecVersion = '89f94f0407dffba19227cdfeba8a5981b1570344'
This is just a test|.
Also, verify the case described in #729 doesn't crash.