Fixed list renum

This commit is contained in:
M66B 2021-05-06 20:46:50 +02:00
parent df6938fd83
commit dc1f437f2f
1 changed files with 3 additions and 7 deletions

View File

@ -309,7 +309,6 @@ public class StyleHelper {
int i = s; int i = s;
int j = s + 1; int j = s + 1;
int index = 1; int index = 1;
boolean renum = false;
while (j < e) { while (j < e) {
if (i > 0 && edit.charAt(i - 1) == '\n' && edit.charAt(j) == '\n') { if (i > 0 && edit.charAt(i - 1) == '\n' && edit.charAt(j) == '\n') {
Log.i("Insert " + i + "..." + (j + 1) + " size=" + e); Log.i("Insert " + i + "..." + (j + 1) + " size=" + e);
@ -318,18 +317,15 @@ public class StyleHelper {
edit.setSpan(new BulletSpanEx(dp24, dp6, colorAccent, 0), i, j + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_PARAGRAPH); edit.setSpan(new BulletSpanEx(dp24, dp6, colorAccent, 0), i, j + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_PARAGRAPH);
else else
edit.setSpan(new BulletSpanEx(dp24, dp6, colorAccent, dp3, 0), i, j + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_PARAGRAPH); edit.setSpan(new BulletSpanEx(dp24, dp6, colorAccent, dp3, 0), i, j + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_PARAGRAPH);
else { else
renum = true;
edit.setSpan(new NumberSpan(dp24, dp6, colorAccent, textSize, 0, index++), i, j + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_PARAGRAPH); edit.setSpan(new NumberSpan(dp24, dp6, colorAccent, textSize, 0, index++), i, j + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_PARAGRAPH);
}
i = j + 1; i = j + 1;
} }
j++; j++;
} }
if (renum) renumber(edit, false, context);
renumber(edit, false, context);
etBody.setText(edit); etBody.setText(edit);
etBody.setSelection(s, e); etBody.setSelection(s, e);
@ -585,7 +581,7 @@ public class StyleHelper {
while (levels.size() > level + 1) while (levels.size() > level + 1)
levels.remove(levels.size() - 1); levels.remove(levels.size() - 1);
if (levels.size() == level + 1 && !(span instanceof NumberSpan)) if (levels.size() == level + 1 && !(span instanceof NumberSpan))
levels.remove(level - 1); levels.remove(level);
while (levels.size() < level + 1) while (levels.size() < level + 1)
levels.add(0); levels.add(0);