mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-31 11:35:37 +01:00
keep indent on enter
This commit is contained in:
parent
fcf1830887
commit
92f4402b63
@ -354,6 +354,21 @@ export class QuickReply {
|
||||
message.selectionStart = start - 1;
|
||||
message.selectionEnd = end - count;
|
||||
updateSyntax();
|
||||
} else if (evt.key == 'Enter' && !evt.ctrlKey && !evt.shiftKey && !evt.altKey) {
|
||||
evt.stopImmediatePropagation();
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
const start = message.selectionStart;
|
||||
const end = message.selectionEnd;
|
||||
const lineStart = message.value.lastIndexOf('\n', start - 1);
|
||||
const indent = /^(\s*)/.exec(message.value.slice(lineStart).replace(/^\n*/, ''))[1] ?? '';
|
||||
const x = message.value.slice(0, start);
|
||||
const y = message.value.slice(end);
|
||||
const z = message.value.slice(lineStart);
|
||||
message.value = `${message.value.slice(0, start)}\n${indent}${message.value.slice(end)}`;
|
||||
message.selectionStart = start + 1 + indent.length;
|
||||
message.selectionEnd = message.selectionStart;
|
||||
updateSyntax();
|
||||
} else if (evt.key == 'Enter' && evt.ctrlKey && !evt.shiftKey && !evt.altKey) {
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
|
Loading…
x
Reference in New Issue
Block a user