feat: Add setting for trailing comma in auto-formatting

This commit is contained in:
BlakeNeko
2025-11-23 11:28:45 +08:00
parent 3f84125262
commit b6d4fb5590
3 changed files with 14 additions and 2 deletions
+2 -2
View File
@@ -100,8 +100,8 @@ export function formatPromptText(text) {
// Rejoin cleaned tags with ", "
let formattedLine = cleanedTags.join(', ');
// Add a trailing comma and space if the line contains valid tags
if (formattedLine.length > 0) {
// Add a trailing comma and space if the setting is enabled and line contains valid tags
if (formattedLine.length > 0 && settingValues.addTrailingComma) {
formattedLine += ', ';
}
+11
View File
@@ -512,5 +512,16 @@ app.registerExtension({
settingValues.enableAutoFormat = newVal;
},
},
{
id: id + '.AutoFormatter.AddTrailingComma',
name: 'Add Trailing Comma',
tooltip: 'Add a comma at the end of each line when auto-formatting',
type: 'boolean',
defaultValue: false,
category: [name, 'AutoFormatter', 'Add Trailing Comma'],
onChange: (newVal, oldVal) => {
settingValues.addTrailingComma = newVal;
},
},
]
});
+1
View File
@@ -24,6 +24,7 @@ export const settingValues = {
// Auto format settings
enableAutoFormat: true,
autoFormatTrigger: 'auto', // Options: 'auto' (format on blur + shortcut), 'manual' (shortcut only)
addTrailingComma: false, // Whether to add comma at the end of each line
// Internal logic settings