diff --git a/src/dashboardWebView/components/SnippetsView/SnippetForm.tsx b/src/dashboardWebView/components/SnippetsView/SnippetForm.tsx index 8259a9a3..804091dc 100644 --- a/src/dashboardWebView/components/SnippetsView/SnippetForm.tsx +++ b/src/dashboardWebView/components/SnippetsView/SnippetForm.tsx @@ -42,6 +42,10 @@ const SnippetForm: React.ForwardRefRenderFunction { + if (!value) { + return ''; + } + if (value === 'FM_SELECTED_TEXT') { return selection || ''; } @@ -141,13 +145,23 @@ ${snippetBody} const snippetFields = snippet.fields || []; // Loop over all fields to check if they are present in the snippet - for (const field of snippetFields) { + console.log('placeholders', placeholders); + console.log('snippetFields', snippetFields); + + for await (const field of snippetFields) { + console.log('field', field); const idx = placeholders.findIndex((fieldName) => fieldName === field.name); if (idx > -1) { - allFields.push({ - ...field, - value: await insertPlaceholderValues(field.default || '') - }); + try { + const value = await insertPlaceholderValues(field.default || ''); + console.log('value', value); + allFields.push({ + ...field, + value + }); + } catch (e) { + console.log('Error', (e as Error).message) + } } } diff --git a/src/listeners/dashboard/SnippetListener.ts b/src/listeners/dashboard/SnippetListener.ts index 744dc631..b29d3b24 100644 --- a/src/listeners/dashboard/SnippetListener.ts +++ b/src/listeners/dashboard/SnippetListener.ts @@ -140,7 +140,7 @@ export class SnippetListener extends BaseListener { data: { value: string; filePath: string }, requestId?: string ) { - if (!data.value || !command || !requestId) { + if (!command || !requestId) { return; }