Skip to content

Commit

Permalink
(cherry picked from commit 3e8003c)
Browse files Browse the repository at this point in the history
  • Loading branch information
FredLL-Avaiga committed Jan 23, 2023
1 parent b69c053 commit 14ad1f2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Taipy Studio Configuration Builder",
"description": "Visual Studio Code extension for Taipy: Configuration Builder",
"publisher": "Taipy",
"version": "0.3.0",
"version": "0.3.1",
"homepage": "https://github.com/Avaiga/taipy-studio-config.git",
"repository": {
"type": "git",
Expand Down
6 changes: 3 additions & 3 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class Context {
this.configDetailsView.setEmptyContent();
}

private async selectConfigNode(nodeType: string, name: string, configNode: object, uri: Uri, reveal = true): Promise<void> {
private async selectConfigNode(nodeType: string, name: string, configNode: object, uri: Uri, reveal = true, fromInEditor = true): Promise<void> {
let updateCache = false;
if (reveal || this.selectionCache.lastView === nodeType) {
this.configDetailsView.setConfigNodeContent(nodeType, name, configNode, uri);
Expand All @@ -255,7 +255,7 @@ export class Context {
if (updateCache) {
this.vsContext.workspaceState.update(Context.cacheName, this.selectionCache);
}
if (reveal) {
if (reveal && fromInEditor) {
this.revealConfigNodeInEditors(uri, nodeType, name);
}
}
Expand All @@ -270,7 +270,7 @@ export class Context {
const item = this.treeProviders[providerIndex].getItem(name);
if (item) {
this.treeViews[providerIndex].reveal(item, { select: true });
this.selectConfigNode(nodeType, name, item.getNode(), docUri, false);
this.selectConfigNode(nodeType, name, item.getNode(), docUri, true, false);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion webviews/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "taipy-studio-webviews",
"description": "Components for Visual Studio Code extension for Taipy",
"publisher": "Avaiga",
"version": "0.3.0",
"version": "0.3.1",
"categories": [
"Other"
],
Expand Down
11 changes: 7 additions & 4 deletions webviews/src/utils/diagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export const getLinkId = (link: LinkModel) =>
export const getNodeId = (node: DefaultNodeModel) => `${node.getType()}.${node.getOptions().name}`;

const fireNodeSelected = (nodeType: string, name?: string) => name && postActionMessage(nodeType, name, Select);

export const cachePositions = (model: DiagramModel) => {
const pos = getModelNodes(model).reduce((ps, node) => {
const pNode = node as DefaultNodeModel;
Expand Down Expand Up @@ -157,9 +158,11 @@ const debouncedPostPoss = debounce(postPoss, 500);

const nodeListener = {
selectionChanged: (e: BaseEvent) => {
const node = (e as BaseEntityEvent<DefaultNodeModel>).entity;
if (node.getType() && node.getOptions().name) {
fireNodeSelected(node.getType(), node.getOptions().name);
if ((e as any).isSelected) {
const node = (e as BaseEntityEvent<DefaultNodeModel>).entity;
if (node.getType() && node.getOptions().name) {
fireNodeSelected(node.getType(), node.getOptions().name);
}
}
},
positionChanged: (e: BaseEvent) => debouncedPostPoss(getNodeAndLinksPositions, (e as BaseEntityEvent<DefaultNodeModel>).entity),
Expand Down Expand Up @@ -250,7 +253,7 @@ export const showNode = (engine: DiagramEngine, message: EditorAddNodeMessage) =
const isInLine = (pnt: PointModel, startLine: PointModel, endLine: PointModel) => {
const L2 =
(endLine.getX() - startLine.getX()) * (endLine.getX() - startLine.getX()) + (endLine.getY() - startLine.getY()) * (endLine.getY() - startLine.getY());
if (L2 == 0) {
if (L2 === 0) {
return false;
}
const r = ((pnt.getX() - startLine.getX()) * (endLine.getX() - startLine.getX()) + (pnt.getY() - startLine.getY()) * (endLine.getY() - startLine.getY())) / L2;
Expand Down

0 comments on commit 14ad1f2

Please sign in to comment.