feat: Add setting for trailing comma in auto-formatting
This commit is contained in:
@@ -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 += ', ';
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
},
|
||||
]
|
||||
});
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user