@@ -34,34 +34,33 @@ export async function activateExtension(context: vscode.ExtensionContext) {
34
34
}
35
35
36
36
// Register config.yaml schema by removing old entries and adding new one (uri.fsPath changes with each version)
37
+ const yamlMatcher = ".continue/**/*.yaml" ;
37
38
const yamlConfig = vscode . workspace . getConfiguration ( "yaml" ) ;
39
+
38
40
const existingSchemas = yamlConfig . get ( "schemas" ) || { } ;
41
+ const newSchemas = Object . entries ( existingSchemas ) . filter (
42
+ ( [ _ , value ] ) => Array . isArray ( value ) && value . includes ( yamlMatcher ) , // remove old ones
43
+ ) ;
39
44
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 ] ] ) ;
46
50
47
- for ( const oldKey of oldContinueSchemaKeys ) {
51
+ try {
48
52
await yamlConfig . update (
49
- ` schemas. ${ oldKey } ` ,
50
- undefined ,
53
+ " schemas" ,
54
+ Object . fromEntries ( newSchemas ) ,
51
55
vscode . ConfigurationTarget . Global ,
52
56
) ;
57
+ } catch ( error ) {
58
+ console . error (
59
+ "Failed to register Continue config.yaml schema, most likely, YAML extension is not installed" ,
60
+ error ,
61
+ ) ;
53
62
}
54
63
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
-
65
64
const api = new VsCodeContinueApi ( vscodeExtension ) ;
66
65
const continuePublicApi = {
67
66
registerCustomContextProvider : api . registerCustomContextProvider . bind ( api ) ,
0 commit comments