mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-07-06 01:41:48 +02:00
#394: Ordering of snippet fields is based on their field definition
This commit is contained in:
@@ -79,15 +79,21 @@ const SnippetForm: React.ForwardRefRenderFunction<SnippetFormHandle, ISnippetFor
|
||||
const allFields: SnippetField[] = [];
|
||||
const snippetFields = snippet.fields || [];
|
||||
|
||||
for (const fieldName of placeholders) {
|
||||
const field = snippetFields.find(f => f.name === fieldName);
|
||||
|
||||
if (field) {
|
||||
// Loop over all fields to check if they are present in the snippet
|
||||
for (const field of snippetFields) {
|
||||
const idx = placeholders.findIndex(fieldName => fieldName === field.name);
|
||||
if (idx > -1) {
|
||||
allFields.push({
|
||||
...field,
|
||||
value: insertPlaceholderValues(field.default || "")
|
||||
});
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
// Loop over all placeholders to find the ones that are not present in the snippet fields
|
||||
for (const fieldName of placeholders) {
|
||||
const idx = snippetFields.findIndex(field => field.name === fieldName);
|
||||
if (idx === -1) {
|
||||
allFields.push({
|
||||
name: fieldName,
|
||||
title: fieldName,
|
||||
|
||||
Reference in New Issue
Block a user