Skip to content

Commit

Permalink
Reverted some highlighting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 committed Aug 17, 2024
1 parent c0e7b5c commit 587c005
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public void afterTextChanged(final Editable s) {
// Listen to and update highlighting
final ViewTreeObserver observer = getViewTreeObserver();
observer.addOnScrollChangedListener(() -> updateHighlighting(false));
observer.addOnGlobalLayoutListener(() -> updateHighlighting(false));

// Fix for Android 12 perf issues - https://github.com/gsantner/markor/discussions/1794
setEmojiCompatEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public SyntaxHighlighterBase clearAll() {
*
* @return this
*/
public SyntaxHighlighterBase clearDynamic() {
public synchronized SyntaxHighlighterBase clearDynamic() {
if (_spannable == null) {
return this;
}
Expand All @@ -173,7 +173,7 @@ public SyntaxHighlighterBase clearDynamic() {
*
* @return this
*/
public SyntaxHighlighterBase clearStatic() {
public synchronized SyntaxHighlighterBase clearStatic() {
if (_spannable == null) {
return this;
}
Expand All @@ -197,7 +197,7 @@ public SyntaxHighlighterBase clearStatic() {
* @param spannable Spannable to work on
* @return this
*/
public SyntaxHighlighterBase setSpannable(@Nullable final Spannable spannable) {
public synchronized SyntaxHighlighterBase setSpannable(@Nullable final Spannable spannable) {
if (spannable != _spannable) {
_groups.clear();
_appliedDynamic.clear();
Expand All @@ -213,7 +213,7 @@ public Spannable getSpannable() {
}

public boolean hasSpans() {
return _spannable != null && !_groups.isEmpty();
return _spannable != null && _groups.size() > 0;
}

/**
Expand All @@ -232,7 +232,7 @@ public SyntaxHighlighterBase fixup(final int start, final int before, final int
* @param delta Apply to
* @return this
*/
public SyntaxHighlighterBase fixup(final int after, final int delta) {
public synchronized SyntaxHighlighterBase fixup(final int after, final int delta) {
for (int i = _groups.size() - 1; i >= 0; i--) {
final SpanGroup group = _groups.get(i);
// Very simple fixup. If the group is entirely after 'after', adjust it's region
Expand Down Expand Up @@ -260,7 +260,7 @@ public SyntaxHighlighterBase applyDynamic() {
*
* @return this
*/
public SyntaxHighlighterBase applyDynamic(final int[] range) {
public synchronized SyntaxHighlighterBase applyDynamic(final int[] range) {
if (_spannable == null) {
return this;
}
Expand Down Expand Up @@ -292,7 +292,7 @@ public SyntaxHighlighterBase applyDynamic(final int[] range) {
return this;
}

public SyntaxHighlighterBase applyStatic() {
public synchronized SyntaxHighlighterBase applyStatic() {
if (_spannable == null || _staticApplied) {
return this;
}
Expand All @@ -314,7 +314,7 @@ public final SyntaxHighlighterBase reflow() {
}

// Reflow selected region's lines
public final SyntaxHighlighterBase reflow(final int[] range) {
public final synchronized SyntaxHighlighterBase reflow(final int[] range) {
if (TextViewUtils.checkRange(_spannable, range)) {
_spannable.setSpan(_layoutUpdater, range[0], range[1], Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
_spannable.removeSpan(_layoutUpdater);
Expand All @@ -328,7 +328,7 @@ public final SyntaxHighlighterBase reflow(final int[] range) {
*
* @return this
*/
public final SyntaxHighlighterBase recompute() {
public synchronized final SyntaxHighlighterBase recompute() {
_groups.clear();
_appliedDynamic.clear();
_staticApplied = false;
Expand Down

0 comments on commit 587c005

Please sign in to comment.