diff --git a/core/package.json b/core/package.json index cfdf61f..f31b994 100644 --- a/core/package.json +++ b/core/package.json @@ -3,7 +3,7 @@ "displayName": "Taipy Studio Configuration Builder", "description": "Visual Studio Code extension for Taipy: Configuration Builder", "publisher": "Avaiga", - "version": "0.0.5", + "version": "0.0.6", "homepage": "https://github.com/Avaiga/taipy-studio.git", "repository": { "type": "git", diff --git a/core/src/context.ts b/core/src/context.ts index 2ac2b5f..2986c35 100644 --- a/core/src/context.ts +++ b/core/src/context.ts @@ -147,6 +147,7 @@ export class Context { } private revealConfigNodesInTrees() { + this.unselectConfigNode(); this.treeProviders.forEach((p, idx) => { const nodeType = p.getNodeType(); const lastSelectedUri = this.selectionCache[nodeType]; @@ -215,6 +216,10 @@ export class Context { return workspace.openTextDocument(getOriginalUri(uri)); } + private async unselectConfigNode(): Promise { + this.configDetailsView.setEmptyContent(); + } + private async selectConfigNode(nodeType: string, name: string, configNode: object, uri: Uri, reveal = true): Promise { let updateCache = false; if (reveal || this.selectionCache.lastView === nodeType) { diff --git a/core/src/editors/ConfigEditor.ts b/core/src/editors/ConfigEditor.ts index d7ca4d7..4eafba9 100644 --- a/core/src/editors/ConfigEditor.ts +++ b/core/src/editors/ConfigEditor.ts @@ -299,7 +299,7 @@ export class ConfigEditorProvider implements CustomTextEditorProvider { } private async applyEdits(uri: Uri, edits: TextEdit[]) { - if (edits.length) { + if (edits?.length) { const we = new WorkspaceEdit(); we.set(uri, edits); return workspace.applyEdit(we); @@ -357,7 +357,7 @@ export class ConfigEditorProvider implements CustomTextEditorProvider { private async getNodeName(doc: TextDocument, nodeType: string, addNodeToActiveDiagram = true) { const symbols = this.taipyContext.getSymbols(doc.uri.toString()); const typeSymbol = getSymbol(symbols, nodeType); - const nodeName = typeSymbol.children + const nodeName = (typeSymbol?.children || []) .filter(s => s.name.toLowerCase().startsWith(nodeType.toLowerCase())) .sort() .reduce((pv, s) => { @@ -375,7 +375,7 @@ export class ConfigEditorProvider implements CustomTextEditorProvider { if (!value || /[\s\.]/.test(value) || value.toLowerCase() === "default") { return l10n.t("Entity {0} Name should not contain space, '.' or be empty or be default '{1}'", nodeType, value); } - if (typeSymbol.children.some(s => s.name.toLowerCase() === value.toLowerCase())) { + if (typeSymbol?.children.some(s => s.name.toLowerCase() === value.toLowerCase())) { return l10n.t("Another {0} entity has the name {1}", nodeType, value); } return undefined as string; diff --git a/core/src/providers/ConfigDetails.ts b/core/src/providers/ConfigDetails.ts index 87d78a0..47ac197 100644 --- a/core/src/providers/ConfigDetails.ts +++ b/core/src/providers/ConfigDetails.ts @@ -97,6 +97,9 @@ export class ConfigDetailsView implements WebviewViewProvider { private docListener(textDocument: TextDocument) { if (isUriEqual(this.configUri, textDocument.uri)) { const symbols = this.taipyContext.getSymbols(this.configUri.toString()); + if (!symbols) { + this.setEmptyContent(); + } const nameSymbol = getSymbol(symbols, this.nodeType, this.nodeName); const node = getNodeFromSymbol(textDocument, nameSymbol); this._view?.webview.postMessage({ @@ -108,6 +111,9 @@ export class ConfigDetailsView implements WebviewViewProvider { private async editProperty(nodeType: string, nodeName: string, propertyName?: string, propertyValue?: string | string[]) { const symbols = this.taipyContext.getSymbols(this.configUri.toString()); + if (!symbols) { + return; + } const insert = !propertyName; let propertyRange: Range; if (insert) { diff --git a/core/src/utils/errors.ts b/core/src/utils/errors.ts index 3f08a1e..0883ba1 100644 --- a/core/src/utils/errors.ts +++ b/core/src/utils/errors.ts @@ -13,6 +13,7 @@ const linkNodeTypes = [DataNode, Task, Pipeline]; export const reportInconsistencies = (doc: TextDocument, symbols: Array, schemaErrors: ErrorObject[] | null) => { const nodeIds = new Set(); const diagnostics = [] as Diagnostic[]; + if (Array.isArray(symbols)) { // Check the existence of the linked elements symbols.forEach((symbol) => { const childType = getChildType(symbol.name); @@ -62,7 +63,8 @@ export const reportInconsistencies = (doc: TextDocument, symbols: Array { const paths = err.instancePath.split("/").filter((p) => p); const symbol = getSymbol(symbols, ...paths); diff --git a/core/webviews/package.json b/core/webviews/package.json index ca10708..705a5ab 100644 --- a/core/webviews/package.json +++ b/core/webviews/package.json @@ -3,7 +3,7 @@ "displayName": "taipy-studio-webviews", "description": "Components for Visual Studio Code extension for Taipy", "publisher": "Avaiga", - "version": "0.0.5", + "version": "0.0.6", "categories": [ "Other" ],