Skip to content

Commit

Permalink
fix(vscode): Provide fallback for VSCode catalog
Browse files Browse the repository at this point in the history
The lifecycle of a VSCode settings is like follows:

1. It starts with `null`
2. When the user updates it, it stores that value
3. When the user clears it, the value gets to be an empty string '""'

In case the `catalogUrl` is an empty string, we provide a fallback to
use the embedded catalog.

fix: #1109
relates: #1204
  • Loading branch information
lordrip committed Jul 8, 2024
1 parent fd7f9ca commit 0dc0a02
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ export class KaotoEditorFactory implements EditorFactory<Editor, KaotoEditorChan
envelopeContext: KogitoEditorEnvelopeContextType<KaotoEditorChannelApi>,
initArgs: EditorInitArgs,
): Promise<Editor> {
let catalogUrl;
const catalogUrlFromChannelApi = await envelopeContext.channelApi.requests.getCatalogURL();
if (isDefined(catalogUrlFromChannelApi)) {
catalogUrl = catalogUrlFromChannelApi;
} else {
let catalogUrl = await envelopeContext.channelApi.requests.getCatalogURL();

if (!isDefined(catalogUrl) || catalogUrl === '') {
catalogUrl = `${initArgs.resourcesPathPrefix}${CatalogSchemaLoader.DEFAULT_CATALOG_PATH.replace('.', '')}`;
}

return Promise.resolve(new KaotoEditorApp(envelopeContext, initArgs, catalogUrl));
}
}

0 comments on commit 0dc0a02

Please sign in to comment.