diff --git a/public/index.html b/public/index.html index d88998a1d..c54ff4563 100644 --- a/public/index.html +++ b/public/index.html @@ -1221,9 +1221,9 @@ Trim Sentences - - - Keep Newlines + + + Include Newline diff --git a/public/script.js b/public/script.js index ae5215b27..a8dda903e 100644 --- a/public/script.js +++ b/public/script.js @@ -1664,7 +1664,7 @@ async function Generate(type, { automatic_trigger, force_name2, resolve, reject, $("#send_textarea").val('').trigger('input'); if (power_user.trim_sentences) { - textareaText = end_trim_to_sentence(textareaText, power_user.keep_newlines); + textareaText = end_trim_to_sentence(textareaText, power_user.include_newline); } } else { textareaText = ""; diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index c0acbd1ad..a0bbb9c94 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -77,7 +77,7 @@ let power_user = { disable_examples_formatting: false, disable_start_formatting: false, trim_sentences: false, - keep_newlines: false, + include_newline: false, always_force_name2: false, multigen: false, multigen_first_chunk: 50, @@ -495,7 +495,7 @@ function loadPowerUserSettings(settings, data) { $("#disable-examples-formatting-checkbox").prop("checked", power_user.disable_examples_formatting); $('#disable-start-formatting-checkbox').prop("checked", power_user.disable_start_formatting); $("#trim_sentences_checkbox").prop("checked", power_user.trim_sentences); - $("#keep_newlines_checkbox").prop("checked", power_user.keep_newlines); + $("#include_newline_checkbox").prop("checked", power_user.include_newline); $('#render_formulas').prop("checked", power_user.render_formulas); $("#custom_chat_separator").val(power_user.custom_chat_separator); $("#fast_ui_mode").prop("checked", power_user.fast_ui_mode); @@ -860,20 +860,20 @@ $(document).ready(() => { saveSettingsDebounced(); }); - // keep newlines is the child of trim sentences - // if keep newlines is checked, trim sentences must be checked - // if trim sentences is unchecked, keep newlines must be unchecked + // include newline is the child of trim sentences + // if include newline is checked, trim sentences must be checked + // if trim sentences is unchecked, include newline must be unchecked $("#trim_sentences_checkbox").change(function() { power_user.trim_sentences = !!$(this).prop("checked"); if (!$(this).prop("checked")) { - $("#keep_newlines_checkbox").prop("checked", false); - power_user.keep_newlines = false; + $("#include_newline_checkbox").prop("checked", false); + power_user.include_newline = false; } saveSettingsDebounced(); }); - $("#keep_newlines_checkbox").change(function() { - power_user.keep_newlines = !!$(this).prop("checked"); + $("#include_newline_checkbox").change(function() { + power_user.include_newline = !!$(this).prop("checked"); if ($(this).prop("checked")) { $("#trim_sentences_checkbox").prop("checked", true); power_user.trim_sentences = true; diff --git a/public/scripts/utils.js b/public/scripts/utils.js index 796cb59f6..de5000ac4 100644 --- a/public/scripts/utils.js +++ b/public/scripts/utils.js @@ -190,19 +190,19 @@ export function sortByCssOrder(a, b) { return _a - _b; } -export function end_trim_to_sentence(input, keep_newlines = false) { +export function end_trim_to_sentence(input, include_newline = false) { // inspired from https://github.com/kaihordewebui/kaihordewebui.github.io/blob/06b95e6b7720eb85177fbaf1a7f52955d7cdbc02/index.html#L4853-L4867 - + const punctuation = new Set(['.', '!', '?']); // extend this as you see fit for (let i = input.length - 1; i >= 0; i--) { const char = input[i]; - + if (punctuation.has(char)) { last = i; break; } - + if (include_newline && char === '\n') { last = i; break;