From dfab1ba94eb4036115c1f613da11c634ce9239c3 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 26 May 2025 14:49:55 -0700 Subject: [PATCH] fix yaml schema registration logic --- extensions/vscode/src/activation/activate.ts | 39 ++++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/extensions/vscode/src/activation/activate.ts b/extensions/vscode/src/activation/activate.ts index 62708effe..120e669ee 100644 --- a/extensions/vscode/src/activation/activate.ts +++ b/extensions/vscode/src/activation/activate.ts @@ -34,33 +34,32 @@ export async function activateExtension(context: vscode.ExtensionContext) { } // Register config.yaml schema by removing old entries and adding new one (uri.fsPath changes with each version) + const yamlMatcher = ".continue/**/*.yaml"; const yamlConfig = vscode.workspace.getConfiguration("yaml"); + const existingSchemas = yamlConfig.get("schemas") || {}; - - const oldContinueSchemaKeys = Object.entries(existingSchemas) - .filter( - ([_, value]) => - Array.isArray(value) && value.includes(".continue/**/*.yaml"), - ) - .map(([key]) => key); - - for (const oldKey of oldContinueSchemaKeys) { - await yamlConfig.update( - `schemas.${oldKey}`, - undefined, - vscode.ConfigurationTarget.Global, - ); - } + const newSchemas = Object.entries(existingSchemas).filter( + ([_, value]) => Array.isArray(value) && value.includes(yamlMatcher), // remove old ones + ); const newPath = path.join( context.extension.extensionUri.fsPath, "config-yaml-schema.json", ); - await yamlConfig.update( - `schemas.${newPath}`, - [".continue/**/*.yaml"], - vscode.ConfigurationTarget.Global, - ); + newSchemas.push([newPath, [yamlMatcher]]); + + try { + await yamlConfig.update( + "schemas", + Object.fromEntries(newSchemas), + vscode.ConfigurationTarget.Global, + ); + } catch (error) { + console.error( + "Failed to register Continue config.yaml schema, most likely, YAML extension is not installed", + error, + ); + } const api = new VsCodeContinueApi(vscodeExtension); const continuePublicApi = {