From 67c81622963edad3f301e4baae1531b508672d93 Mon Sep 17 00:00:00 2001 From: Davide Aversa Date: Tue, 24 Jan 2023 19:53:26 +0100 Subject: [PATCH 1/2] add listerner for renamed file This change avoid to create duplicate data in `vault-stats.json` when a file is renamed by copying the data from the old path to the new one. --- src/stats/StatsManager.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/stats/StatsManager.ts b/src/stats/StatsManager.ts index 2934c25..a8f59b9 100644 --- a/src/stats/StatsManager.ts +++ b/src/stats/StatsManager.ts @@ -24,6 +24,12 @@ export default class StatsManager { false ); + this.vault.on("rename", (new_name, old_path) => { + const content = this.vaultStats.modifiedFiles[old_path]; + delete this.vaultStats.modifiedFiles[old_path]; + this.vaultStats.modifiedFiles[new_name.path] = content; + }); + this.vault.adapter.exists(STATS_FILE).then(async (exists) => { if (!exists) { const vaultSt: VaultStatistics = { From 0ae40119e79fe38191c31e16599baba641b5fbc4 Mon Sep 17 00:00:00 2001 From: Luke Leppan Date: Tue, 24 Jan 2023 21:13:27 +0200 Subject: [PATCH 2/2] bump --- README.md | 4 ++++ manifest.json | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 413f4e7..19cddc2 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ This plugin is the same as the built-in **Word Count** plugin, except when you s - Added all word, char, sentence count when not viewing a markdown file. - @lishid - Helped solve the performace issue. +- @THeK3nger + - Fixed issue that occured when renaming files. +- @bakuzan + - Fixed issue that caused errors at start up. ### Special Thanks diff --git a/manifest.json b/manifest.json index 5e5289d..a7b282c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "better-word-count", "name": "Better Word Count", - "version": "0.9.1", + "version": "0.9.2", "description": "Counts the words of selected text in the editor.", "author": "Luke Leppan", "authorUrl": "https://lukeleppan.com", diff --git a/package.json b/package.json index 46a2fec..b970db8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "better-word-count", - "version": "0.9.1", + "version": "0.9.2", "description": "Counts the words of selected text in the editor.", "main": "main.js", "scripts": {