BetterCommands: Add option to allow newlines (#393)

This commit is contained in:
Suffocate 2025-09-15 12:33:43 +01:00 • committed by GitHub
parent 675da92c3c
commit 54dc1550f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15,6 +15,11 @@ const settings = definePluginSettings({
description: "Automatically fill command with all arguements instead of just required ones",
type: OptionType.BOOLEAN,
default: true,
},
allowNewlinesInCommands: {
description: "Allow newlines in command inputs (Shift + Enter)",
type: OptionType.BOOLEAN,
default: true,
}
});
@ -40,6 +45,26 @@ export default definePlugin({
replace: "true"
},
]
},
{
find: '"italics"),!0;',
predicate: () => settings.store.allowNewlinesInCommands,
replacement: [
{
match: /case (\i\.\i)\.TAB:if\(null!=(\i).selection&&\i\((\i)(?=.{0,300}(\i\.\i\.insertText))/,
replace: (orig, keys, editor, event, insertText) => {
return `case ${keys}.ENTER:
if(${event}.shiftKey){
${event}.preventDefault();
${event}.stopPropagation();
${insertText}(${editor},'\\n');
return true;
}
break;
${orig}`;
}
}
]
}
],
commands: [