From c620feb75c05851f9a3dcb776e1c52ff5ac50f2a Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Mon, 26 Aug 2024 17:56:10 -0700 Subject: [PATCH] Switching back to start end as it made no difference --- .../textview/SyntaxHighlighterBase.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/net/gsantner/markor/frontend/textview/SyntaxHighlighterBase.java b/app/src/main/java/net/gsantner/markor/frontend/textview/SyntaxHighlighterBase.java index 245b840b2d..a30b3ce7cf 100644 --- a/app/src/main/java/net/gsantner/markor/frontend/textview/SyntaxHighlighterBase.java +++ b/app/src/main/java/net/gsantner/markor/frontend/textview/SyntaxHighlighterBase.java @@ -106,14 +106,14 @@ public SyntaxHighlighterBase configure(@Nullable final Paint paint) { * A class representing any span */ public static class SpanGroup implements Comparable { - int start, length; + int start, end; final Object span; final boolean isStatic; - SpanGroup(Object o, int s, int l) { + SpanGroup(Object o, int s, int e) { span = o; start = s; - length = l; + end = e; isStatic = o instanceof UpdateLayout; } @@ -226,11 +226,11 @@ public SyntaxHighlighterBase fixup(final int start, final int before, final int } /** - * Adjust all currently computed spans. Use to adjust spans after text edited. + * Adjust all currently computed spans so that the spans are still valid after text changes * We internally buffer / batch these fixes for increased performance * * @param after Apply to spans with region starting after 'after' - * @param delta Apply to + * @param delta How much to shift each span * @return this */ public SyntaxHighlighterBase fixup(final int after, final int delta) { @@ -315,10 +315,9 @@ public SyntaxHighlighterBase applyDynamic(final int[] range) { break; } - final int end = group.start + group.length; - final boolean valid = group.start >= 0 && end > range[0] && end <= length; + final boolean valid = group.start >= 0 && group.end > range[0] && group.end <= length; if (valid && !_appliedDynamic.contains(i)) { - _spannable.setSpan(group.span, group.start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + _spannable.setSpan(group.span, group.start, group.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); _appliedDynamic.add(i); } } @@ -335,7 +334,7 @@ public SyntaxHighlighterBase applyStatic() { for (final SpanGroup group : _groups) { if (group.isStatic) { - _spannable.setSpan(group.span, group.start, group.start + group.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + _spannable.setSpan(group.span, group.start, group.start + group.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } @@ -409,7 +408,7 @@ public final SyntaxHighlighterBase compute() { protected final void addSpanGroup(final Object span, final int start, final int end) { if (end > start && span != null) { - _groupBuffer.add(new SpanGroup(span, start, end - start)); + _groupBuffer.add(new SpanGroup(span, start, end)); } }