fix(web): better predictive-text handling of text wordbreaking transitions #12864
+54
−7
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.
Fixes: #12494.
Replaces #12860.
The underlying issue was occurring due to a previously unforeseen consequence of default wordbreaker use, combined with some of our custom handling.
Good case: suppose the text just typed reads
isn'
. A natural suggestion for English is the wordisn't
. While end-of-token'
is cause for wordbreaking, since the text insertion point is adjacent to the'
, we disable wordbreaking for that'
to facilitate theisn't
suggestion.Bad case: suppose we just typed
text'
and then add another character that should trigger wordbreaking - like a"
- gets typed. At this point, due to our handling for the "good case", we transition from a tokenized context of [text'
] to [text
,'
,"
]. The "old context" no longer matches - [text'
] vs [text
,'
] - but the method responsible for detecting this previously did not do so, which is what led to the original error.Additionally, I added a unit test for this case to the testing suite. It checks the circumstance that leads to the error, rather than the original error itself, so user testing is still wise here.
User Testing
TEST_NOCRASH: follow the steps outlined in #12494 and verify that the crash no longer happens.