Avoid double line break when revealing MQness of spirit temple (#6912)

This commit is contained in:
Philip Dubé
2026-07-12 17:51:55 +00:00
committed by GitHub
parent a44197712c
commit ba08197d3b
@@ -506,7 +506,10 @@ size_t CustomMessage::FindNEWLINE(std::string& str, size_t lastNewline) const {
bool CustomMessage::AddBreakString(std::string& str, size_t pos, std::string breakString) const {
if (str[pos] == ' ' || str[pos] == '&') {
str.replace(pos, 1, breakString);
// don't add a break next to an existing newline
if (str[pos] != ' ' || (str[pos + 1] != '&' && str[pos + 1] != NEWLINE()[0])) {
str.replace(pos, 1, breakString);
}
return false;
} else {
if (pos <= str.size() - 1) {
@@ -515,7 +518,10 @@ bool CustomMessage::AddBreakString(std::string& str, size_t pos, std::string bre
return false;
// otherwise, if it is a line break or space, replace it
} else if (str[pos + 1] == ' ' || str[pos + 1] == '&') {
str.replace(pos + 1, 1, breakString);
// don't add a break next to an existing newline
if (str[pos + 1] != ' ' || (str[pos + 2] != '&' && str[pos + 2] != NEWLINE()[0])) {
str.replace(pos + 1, 1, breakString);
}
return false;
}
}