Address code review feedback and improve validation

Co-authored-by: estruyf <2900833+estruyf@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-03 15:07:43 +00:00
parent 4bee998d9b
commit c179364f2b
3 changed files with 9 additions and 5 deletions
+8 -3
View File
@@ -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
}
}
+1 -1
View File
@@ -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;
-1
View File
@@ -28,4 +28,3 @@ export * from './sleep';
export * from './sortPages';
export * from './unlinkAsync';
export * from './writeFileAsync';
export * from '../helpers/ContentTypeSchemaGenerator';