From c179364f2bdd07aecf3b383061e2604dc2dbbf57 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Dec 2025 15:07:43 +0000 Subject: [PATCH] Address code review feedback and improve validation Co-authored-by: estruyf <2900833+estruyf@users.noreply.github.com> --- src/commands/StatusListener.ts | 11 ++++++++--- src/helpers/ContentTypeSchemaGenerator.ts | 2 +- src/utils/index.ts | 1 - 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/commands/StatusListener.ts b/src/commands/StatusListener.ts index c6cea19b..b2327d66 100644 --- a/src/commands/StatusListener.ts +++ b/src/commands/StatusListener.ts @@ -203,14 +203,19 @@ export class StatusListener { const text = editor.document.getText(); const schemaDiagnostics: vscode.Diagnostic[] = []; + + // Find the front matter section (between --- markers) + const frontMatterMatch = text.match(/^---\r?\n([\s\S]*?)\r?\n---/); + const frontMatterEnd = frontMatterMatch ? frontMatterMatch[0].length : text.length; for (const error of errors) { // Find the field in the document const fieldPath = error.field.split('.'); const fieldName = fieldPath[fieldPath.length - 1]; - // Try to find the field location in the document - const fieldIdx = text.indexOf(fieldName); + // Try to find the field location in the front matter section only + const searchText = text.substring(0, frontMatterEnd); + const fieldIdx = searchText.indexOf(fieldName); if (fieldIdx !== -1) { const posStart = editor.document.positionAt(fieldIdx); @@ -238,7 +243,7 @@ export class StatusListener { } } catch (error) { // Silently fail validation errors to not disrupt the user experience - console.error('Schema validation error:', error); + // Logger can be used here if needed for debugging } } diff --git a/src/helpers/ContentTypeSchemaGenerator.ts b/src/helpers/ContentTypeSchemaGenerator.ts index ccab28de..8783d4cd 100644 --- a/src/helpers/ContentTypeSchemaGenerator.ts +++ b/src/helpers/ContentTypeSchemaGenerator.ts @@ -254,7 +254,7 @@ export class ContentTypeSchemaGenerator { } const fieldGroupIds = Array.isArray(field.fieldGroup) ? field.fieldGroup : [field.fieldGroup]; - const fieldGroups = Settings.get(SETTING_TAXONOMY_FIELD_GROUPS) as any[]; + const fieldGroups = Settings.get(SETTING_TAXONOMY_FIELD_GROUPS) as { id: string; fields: Field[] }[] | undefined; if (!fieldGroups || fieldGroups.length === 0) { return schemas; diff --git a/src/utils/index.ts b/src/utils/index.ts index a2e342a5..b6d73cfc 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -28,4 +28,3 @@ export * from './sleep'; export * from './sortPages'; export * from './unlinkAsync'; export * from './writeFileAsync'; -export * from '../helpers/ContentTypeSchemaGenerator';