preserve new lines when quoting. fixes #3876
This commit is contained in:
parent
22f4129262
commit
562ffd2003
|
@ -84,13 +84,13 @@ public class QuoteHelper {
|
|||
if (isPositionQuoteStart(line, 0)) {
|
||||
int nestingDepth = 1;
|
||||
for (int i = 1; i < line.length(); i++) {
|
||||
if (isPositionQuoteStart(line, i)) {
|
||||
if (isPositionQuoteCharacter(line, i)) {
|
||||
nestingDepth++;
|
||||
}
|
||||
if (nestingDepth > (Config.QUOTING_MAX_DEPTH - 1)) {
|
||||
return true;
|
||||
} else if (line.charAt(i) != ' ') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return nestingDepth >= (Config.QUOTING_MAX_DEPTH);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -145,7 +145,13 @@ public class EditMessage extends AppCompatEditText {
|
|||
|
||||
public void insertAsQuote(String text) {
|
||||
text = QuoteHelper.replaceAltQuoteCharsInText(text);
|
||||
text = text.replaceAll("(\n *){2,}", "\n").replaceAll("(^|\n)(" + QuoteHelper.QUOTE_CHAR + ")", "$1$2$2").replaceAll("(^|\n)([^" + QuoteHelper.QUOTE_CHAR + "])", "$1> $2").replaceAll("\n$", "");
|
||||
text = text
|
||||
// first replace all '>' at the beginning of the line with nice and tidy '>>'
|
||||
// for nested quoting
|
||||
.replaceAll("(^|\n)(" + QuoteHelper.QUOTE_CHAR + ")", "$1$2$2")
|
||||
// then find all other lines and have them start with a '> '
|
||||
.replaceAll("(^|\n)(?!" + QuoteHelper.QUOTE_CHAR + ")(.*)", "$1> $2")
|
||||
;
|
||||
Editable editable = getEditableText();
|
||||
int position = getSelectionEnd();
|
||||
if (position == -1) position = editable.length();
|
||||
|
|
|
@ -66,11 +66,7 @@ public class MessageUtils {
|
|||
body = message.getMergedBody().toString();
|
||||
}
|
||||
for (String line : body.split("\n")) {
|
||||
if (line.length() <= 0) {
|
||||
continue;
|
||||
}
|
||||
final char c = line.charAt(0);
|
||||
if (QuoteHelper.isNestedTooDeeply(line)) {
|
||||
if (!(line.length() <= 0) && QuoteHelper.isNestedTooDeeply(line)) {
|
||||
continue;
|
||||
}
|
||||
if (builder.length() != 0) {
|
||||
|
|
Loading…
Reference in a new issue