feat: auto-generate snippet names based on existing snippets for better organization

This commit is contained in:
2025-01-19 04:00:28 +02:00
parent 811d981ab9
commit 2664b12c12

View File

@@ -53,9 +53,13 @@ export class SnippetManager {
}
createNewSnippet() {
const name = prompt('Enter snippet name:', 'New Snippet');
if (!name) return;
const existingNames = this.snippets
.filter(s => s.name.startsWith('Snippet #'))
.map(s => parseInt(s.name.replace('Snippet #', '')))
.filter(n => !isNaN(n));
const nextNumber = existingNames.length > 0 ? Math.max(...existingNames) + 1 : 1;
const name = `Snippet #${nextNumber}`;
const id = 'snippet-' + Date.now();
const newSnippet = {
id,