Skip to content

Fix Config.yaml schema registration #5851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions extensions/vscode/src/activation/activate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,32 @@ export async function activateExtension(context: vscode.ExtensionContext) {
);
}

// Only set the YAML schema configuration if it hasn't been set before
if (!context.globalState.get("yamlSchemaConfigured")) {
vscode.workspace.getConfiguration("yaml").update(
// 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 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",
);
newSchemas.push([newPath, [yamlMatcher]]);

try {
await yamlConfig.update(
"schemas",
{
[path.join(
context.extension.extensionUri.fsPath,
"config-yaml-schema.json",
)]: [".continue/**/*.yaml"],
},
Object.fromEntries(newSchemas),
vscode.ConfigurationTarget.Global,
);
// Mark that we've configured the YAML schema
context.globalState.update("yamlSchemaConfigured", true);
} catch (error) {
console.error(
"Failed to register Continue config.yaml schema, most likely, YAML extension is not installed",
error,
);
}

const api = new VsCodeContinueApi(vscodeExtension);
Expand Down
Loading