fixed IndexOutOfBounds when rendering quotes

This commit is contained in:
Daniel Gultsch 2021-10-31 10:20:34 +01:00
parent 226eb739bd
commit ba4a47204b
2 changed files with 24 additions and 26 deletions

View File

@ -370,9 +370,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
char current = body.length() > i ? body.charAt(i) : '\n';
if (lineStart == -1) {
if (previous == '\n') {
if (
QuoteHelper.isPositionQuoteStart(body, i)
) {
if (i < body.length() && QuoteHelper.isPositionQuoteStart(body, i)) {
// Line start with quote
lineStart = i;
if (quoteStart == -1) quoteStart = i;

View File

@ -38,13 +38,13 @@ public class QuoteHelper {
}
// 'Prequote' means anything we require or can accept in front of a QuoteChar
public static boolean isPositionPrecededByPrequote(CharSequence body, int pos){
public static boolean isPositionPrecededByPreQuote(CharSequence body, int pos) {
return UIHelper.isPositionPrecededByLineStart(body, pos);
}
public static boolean isPositionQuoteStart(CharSequence body, int pos) {
return (isPositionQuoteCharacter(body, pos)
&& isPositionPrecededByPrequote(body, pos)
&& isPositionPrecededByPreQuote(body, pos)
&& (UIHelper.isPositionFollowedByQuoteableCharacter(body, pos)
|| isPositionFollowedByQuoteChar(body, pos)));
}