Skip to content

Commit dfab1ba

Browse files
committed
fix yaml schema registration logic
1 parent 3cd474b commit dfab1ba

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

extensions/vscode/src/activation/activate.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,33 @@ export async function activateExtension(context: vscode.ExtensionContext) {
3434
}
3535

3636
// Register config.yaml schema by removing old entries and adding new one (uri.fsPath changes with each version)
37+
const yamlMatcher = ".continue/**/*.yaml";
3738
const yamlConfig = vscode.workspace.getConfiguration("yaml");
39+
3840
const existingSchemas = yamlConfig.get("schemas") || {};
41+
const newSchemas = Object.entries(existingSchemas).filter(
42+
([_, value]) => Array.isArray(value) && value.includes(yamlMatcher), // remove old ones
43+
);
3944

40-
const oldContinueSchemaKeys = Object.entries(existingSchemas)
41-
.filter(
42-
([_, value]) =>
43-
Array.isArray(value) && value.includes(".continue/**/*.yaml"),
44-
)
45-
.map(([key]) => key);
45+
const newPath = path.join(
46+
context.extension.extensionUri.fsPath,
47+
"config-yaml-schema.json",
48+
);
49+
newSchemas.push([newPath, [yamlMatcher]]);
4650

47-
for (const oldKey of oldContinueSchemaKeys) {
51+
try {
4852
await yamlConfig.update(
49-
`schemas.${oldKey}`,
50-
undefined,
53+
"schemas",
54+
Object.fromEntries(newSchemas),
5155
vscode.ConfigurationTarget.Global,
5256
);
57+
} catch (error) {
58+
console.error(
59+
"Failed to register Continue config.yaml schema, most likely, YAML extension is not installed",
60+
error,
61+
);
5362
}
5463

55-
const newPath = path.join(
56-
context.extension.extensionUri.fsPath,
57-
"config-yaml-schema.json",
58-
);
59-
await yamlConfig.update(
60-
`schemas.${newPath}`,
61-
[".continue/**/*.yaml"],
62-
vscode.ConfigurationTarget.Global,
63-
);
64-
6564
const api = new VsCodeContinueApi(vscodeExtension);
6665
const continuePublicApi = {
6766
registerCustomContextProvider: api.registerCustomContextProvider.bind(api),

0 commit comments

Comments
 (0)