diff --git a/manifest.json b/manifest.json index 8325a94..a4b09da 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "better-word-count", "name": "Better Word Count", - "version": "0.7.4", + "version": "0.7.5", "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 f67cc1b..0d9d4ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "better-word-count", - "version": "0.7.4", + "version": "0.7.5", "description": "Counts the words of selected text in the editor.", "main": "main.js", "scripts": { diff --git a/src/data/manager.ts b/src/data/manager.ts index 44615fb..8162202 100644 --- a/src/data/manager.ts +++ b/src/data/manager.ts @@ -32,6 +32,12 @@ export interface TodayCounts { sentences: number; } +export interface TotalCounts { + words: number; + characters: number; + sentences: number; +} + export class DataManager { private vault: Vault; private metadataCache: MetadataCache; @@ -171,6 +177,14 @@ export class DataManager { return this.todayCounts; } + getTotalCounts(): TotalCounts { + return { + words: this.history[this.today].totalWords, + characters: this.history[this.today].totalCharacters, + sentences: this.history[this.today].totalSentences, + }; + } + async updateFromFile() { this.history = Object.assign( JSON.parse(await this.vault.adapter.read(".vault-stats")) diff --git a/src/status/manager.ts b/src/status/manager.ts index 89e7d11..655432e 100644 --- a/src/status/manager.ts +++ b/src/status/manager.ts @@ -65,13 +65,13 @@ export class BarManager { newText = newText + getSentenceCount(text); break; case 3: - newText = newText + this.dataManager.getTodayCounts().words; + newText = newText + this.dataManager.getTotalCounts().words; break; case 4: - newText = newText + this.dataManager.getTodayCounts().characters; + newText = newText + this.dataManager.getTotalCounts().characters; break; case 5: - newText = newText + this.dataManager.getTodayCounts().sentences; + newText = newText + this.dataManager.getTotalCounts().sentences; break; case 6: newText = newText + this.dataCollector.getTotalFileCount(); @@ -92,7 +92,7 @@ export class BarManager { this.statusBar.displayText(newText); } - updateAltStatusBar(): void { + async updateAltStatusBar(): Promise { let newText = ""; const expression: Expression = parse(this.settings.statusBarAltQuery); if (this.settings.collectStats) { @@ -118,13 +118,15 @@ export class BarManager { newText = newText + getSentenceCount(""); break; case 3: - newText = newText + this.dataManager.getTodayCounts().words; + newText = newText + (await this.dataCollector.getTotalWordCount()); break; case 4: - newText = newText + this.dataManager.getTodayCounts().characters; + newText = + newText + (await this.dataCollector.getTotalCharacterCount()); break; case 5: - newText = newText + this.dataManager.getTodayCounts().sentences; + newText = + newText + (await this.dataCollector.getTotalSentenceCount()); break; case 6: newText = newText + this.dataCollector.getTotalFileCount();