Skip to content

Commit

Permalink
Fix android crash when modifying the markdown through selection
Browse files Browse the repository at this point in the history
  • Loading branch information
wildan-m committed Sep 3, 2024
1 parent 3065877 commit c974bdc
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,20 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
if (mShouldSkip) {
return;
}
if (s instanceof SpannableStringBuilder) {
mMarkdownUtils.applyMarkdownFormatting((SpannableStringBuilder) s);
mShouldSkip = true;
}
// Set the flag to indicate text is being changed
mShouldSkip = true;
}

@Override
public void afterTextChanged(Editable editable) {
mShouldSkip = false;
}
}
if (!mShouldSkip) {
return;
}

if (editable instanceof SpannableStringBuilder) {
mMarkdownUtils.applyMarkdownFormatting((SpannableStringBuilder) editable);
}

// Reset the flag after formatting is applied
mShouldSkip = false;
}}

0 comments on commit c974bdc

Please sign in to comment.