diff --git a/README.md b/README.md index cdca81c..1c8647e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Better Word Count +# Better Word Count ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/lukeleppan/better-word-count/Build%20Release?logo=github&style=for-the-badge) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/lukeleppan/better-word-count?style=for-the-badge) ![GitHub All Releases](https://img.shields.io/github/downloads/lukeleppan/better-word-count/total?style=for-the-badge) @@ -6,7 +6,7 @@ This plugin is the same as the built-in **Word Count** plugin, except when you s ![Better Count Word](https://raw.githubusercontent.com/lukeleppan/better-word-count/master/assets/better-word-count.gif) -### Features +## Features - Allows you to store statistics about your vault. - Works with all languages. @@ -17,16 +17,18 @@ This plugin is the same as the built-in **Word Count** plugin, except when you s - Total Files in vault. - Highly Customizable status bar that can be adapted to your needs. -#### TODO: +### TODO - [ ] add statistic view - [ ] add more statistics (make suggestions) - [ ] add goals -### Contributors +## Contributors - @leoccyao - Added all word, char, sentence count when not viewing a markdown file. +- @lishid + - Helped solve the performace issue. ### Special Thanks diff --git a/manifest.json b/manifest.json index 9f884e4..4a1d349 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "better-word-count", "name": "Better Word Count", - "version": "0.7.6", + "version": "0.7.7", "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 faecbf9..226df4f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "better-word-count", - "version": "0.7.6", + "version": "0.7.7", "description": "Counts the words of selected text in the editor.", "main": "main.js", "scripts": { diff --git a/src/data/collector.ts b/src/data/collector.ts index dff837d..195d45f 100644 --- a/src/data/collector.ts +++ b/src/data/collector.ts @@ -12,7 +12,7 @@ export class DataCollector { } getTotalFileCount() { - return Object.keys(this.metadataCache.resolvedLinks).length; + return this.vault.getMarkdownFiles().length; } async getTotalWordCount() { @@ -20,7 +20,9 @@ export class DataCollector { const files = this.vault.getFiles(); for (const i in files) { const file = files[i]; - words += getWordCount(await this.vault.cachedRead(file)); + if (file.extension === "md") { + words += getWordCount(await this.vault.cachedRead(file)); + } } return words; @@ -31,7 +33,9 @@ export class DataCollector { const files = this.vault.getFiles(); for (const i in files) { const file = files[i]; - characters += getCharacterCount(await this.vault.cachedRead(file)); + if (file.extension === "md") { + characters += getCharacterCount(await this.vault.cachedRead(file)); + } } return characters; @@ -42,7 +46,9 @@ export class DataCollector { const files = this.vault.getFiles(); for (const i in files) { const file = files[i]; - sentence += getSentenceCount(await this.vault.cachedRead(file)); + if (file.extension === "md") { + sentence += getSentenceCount(await this.vault.cachedRead(file)); + } } return sentence;