Skip to content

Commit

Permalink
updates cache fileinfo on changes in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Heiss committed Aug 1, 2024
1 parent 425a975 commit b51b2be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ export default class VikunjaPlugin extends Plugin {
const cachedTask = this.cache.get(task.task.id);
if (cachedTask === undefined || !cachedTask.isTaskEqual(task.task)) {
this.cache.update(task);
} else {
if (cachedTask.lineno !== task.lineno || cachedTask.filepath !== task.filepath) {
this.cache.updateFileInfos(task.task.id, task.filepath, task.lineno);
}
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/settings/VaultTaskCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ export default class VaultTaskCache {
this.changesMade = false;
}

updateFileInfos(id: number, filepath: string, lineno: number) {
const cachedTask = this.get(id);
if (cachedTask === undefined) {
throw new Error("VaultTaskCache: Task is not in cache");
}
if (this.plugin.settings.debugging) console.log("VaultTaskCache: Updating task", id, "with updated file infos", filepath, lineno);
cachedTask.filepath = filepath;
cachedTask.lineno = lineno;
this.cache.set(id, cachedTask);
this.changesMade = true;
}

update(local: PluginTask) {
if (local.task.id === undefined) {
throw new Error("VaultTaskCache: Task id is not defined");
Expand Down

0 comments on commit b51b2be

Please sign in to comment.