Skip to content

Commit

Permalink
Tweaks to reflow
Browse files Browse the repository at this point in the history
  • Loading branch information
harshad1 committed Aug 27, 2024
1 parent 6b1bc6c commit 3a2daaa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ private boolean runHighlight(final boolean recompute) {

private void updateHighlighting() {
if (runHighlight(false)) {
batch(() -> _hl.clearDynamic().applyDynamic(hlRegion()));
// Do not batch as we do not want to reflow
_hl.clearDynamic().applyDynamic(hlRegion());
_oldHlRect.set(_hlRect);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,22 @@ public SyntaxHighlighterBase clearStatic() {
return this;
}

boolean hasStatic = false;
for (int i = _groups.size() - 1; i >= 0; i--) {
final SpanGroup group = _groups.get(i);
if (group.isStatic) {
hasStatic = true;
_spannable.removeSpan(group.span);
}
}

if (hasStatic) {
reflow();
}

_staticApplied = false;

return reflow();
return this;
}

/**
Expand Down Expand Up @@ -338,15 +344,21 @@ public SyntaxHighlighterBase applyStatic() {

applyFixup();

boolean hasStatic = false;
for (final SpanGroup group : _groups) {
if (group.isStatic) {
hasStatic = true;
_spannable.setSpan(group.span, group.start, group.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}

if (hasStatic) {
reflow();
}

_staticApplied = true;

return reflow();
return this;
}

public final SyntaxHighlighterBase reflow() {
Expand Down

0 comments on commit 3a2daaa

Please sign in to comment.