Skip to content

Eliminate setText call in applyNewStyles on Android - #608

Merged
tomekzaw merged 2 commits into
mainfrom
@tomekzaw/apply-new-styles
Jan 31, 2025
Merged

tomekzaw merged 2 commits into
mainfrom
@tomekzaw/apply-new-styles

Conversation

@tomekzaw

Copy link
Copy Markdown
Contributor

Details

This PR refactors the implementation of applyNewStyles method on Android.

Currently, in applyNewStyles we obtain the current value using getText method and pass it to setText method in order to trigger MarkdownTextWatcher. This works fine but can lead to infinite loop because calling setText (or even setTextKeepState) generates a selection update event. In live-markdown example app, onSelectionChange callback always calls setSelection (without comparing start and end fields so it updates the reference to selection state) which results in render that leads to another applyNewStyles call (not sure how exactly, though).

Instead, we call applyMarkdownFormatting which doesn't emit selection change event.

Related Issues

Required by #607.

Manual Tests

Linked PRs

j-piasecki
j-piasecki previously approved these changes Jan 30, 2025
@tomekzaw
tomekzaw merged commit 8ba4b56 into main Jan 31, 2025
@tomekzaw
tomekzaw deleted the @tomekzaw/apply-new-styles branch January 31, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants