Move trimToEnd at the end of message clean-up

This commit is contained in:
Cohee
2024-08-25 14:37:44 +03:00
parent e1b7660448
commit 87dd120ec0

View File

@@ -5345,17 +5345,10 @@ export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayInc
// Regex uses vars, so add before formatting // Regex uses vars, so add before formatting
getMessage = getRegexedString(getMessage, isImpersonate ? regex_placement.USER_INPUT : regex_placement.AI_OUTPUT); getMessage = getRegexedString(getMessage, isImpersonate ? regex_placement.USER_INPUT : regex_placement.AI_OUTPUT);
if (!displayIncompleteSentences && power_user.trim_sentences) {
getMessage = trimToEndSentence(getMessage, power_user.include_newline);
}
if (power_user.collapse_newlines) { if (power_user.collapse_newlines) {
getMessage = collapseNewlines(getMessage); getMessage = collapseNewlines(getMessage);
} }
if (power_user.trim_spaces) {
getMessage = getMessage.trim();
}
// trailing invisible whitespace before every newlines, on a multiline string // trailing invisible whitespace before every newlines, on a multiline string
// "trailing whitespace on newlines \nevery line of the string \n?sample text" -> // "trailing whitespace on newlines \nevery line of the string \n?sample text" ->
// "trailing whitespace on newlines\nevery line of the string\nsample text" // "trailing whitespace on newlines\nevery line of the string\nsample text"
@@ -5447,6 +5440,14 @@ export function cleanUpMessage(getMessage, isImpersonate, isContinue, displayInc
getMessage = getMessage.trim(); getMessage = getMessage.trim();
} }
if (!displayIncompleteSentences && power_user.trim_sentences) {
getMessage = trimToEndSentence(getMessage, power_user.include_newline);
}
if (power_user.trim_spaces) {
getMessage = getMessage.trim();
}
return getMessage; return getMessage;
} }