lukeleppan / better-word-count

Counts the words of selected text in the editor.
MIT License
263 stars 41 forks source link

Only display rounded statistics #103

Open StephenWeber opened 1 year ago

StephenWeber commented 1 year ago

I'm displaying "daily page count" from the calculated statistics. This is just a division (words / constant) and regularly gives me full decimals for the floating point value. For example today it's displaying 1.8999999999999997 for the current value.

I would expect to have this limited to a more useful number of digits, for example two digits so the above number would be displayed 1.9 or 1.90. As a human, I don't want to be distracted trying to interpret that number more meaningfully, it's just an estimation tool for me.

I also expect the statistics calculated and stored would have the full accurate number, so this would be more how Better Word Count displays values, not how it stores them.

I don't personally care if I can configure it or not.

StephenWeber commented 1 year ago

I may submit a PR, but to document what I'm seeing in code:

StatusBar.ts#L167 is where the Daily Page Count is pulled in. Lots of other values pulled from statsManager that could have this same problem.

The display variable gets built up:

So either each calculated field should get formatted individually, or we build the display text at the end after we've had a chance to format whatever value we pull out of statsManager.