Skip to content

Commit

Permalink
Fixed graph computation issue
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardoferretti committed Mar 18, 2024
1 parent 7f58709 commit d8baa2f
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions packages/foam-vscode/src/core/model/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,32 +100,30 @@ export class FoamGraph implements IDisposable {
}

public update() {
withTiming(
() => {
this.backlinks.clear();
this.links.clear();
this.placeholders.clear();

for (const resource of this.workspace.resources()) {
for (const link of resource.links) {
try {
const targetUri = this.workspace.resolveLink(resource, link);
this.connect(resource.uri, targetUri, link);
} catch (e) {
Logger.error(
`Error while resolving link ${
link.rawText
} in ${resource.uri.toFsPath()}, skipping.`,
link,
e
);
}
}
this.onDidUpdateEmitter.fire();
const start = Date.now();
this.backlinks.clear();
this.links.clear();
this.placeholders.clear();

for (const resource of this.workspace.resources()) {
for (const link of resource.links) {
try {
const targetUri = this.workspace.resolveLink(resource, link);
this.connect(resource.uri, targetUri, link);
} catch (e) {
Logger.error(
`Error while resolving link ${
link.rawText
} in ${resource.uri.toFsPath()}, skipping.`,
link,
e
);
}
},
ms => Logger.debug(`Graph updated in ${ms}ms`)
);
}
this.onDidUpdateEmitter.fire();
}
const ms = Date.now() - start;
Logger.debug(`Graph updated in ${ms}ms`);
}

private connect(source: URI, target: URI, link: ResourceLink) {
Expand Down

0 comments on commit d8baa2f

Please sign in to comment.