Skip to content

[BUG] Multiple Neovim instances overwrite stats file #16

@DrKJeff16

Description

@DrKJeff16

Originally posted by @Alexandre-Hilaire in #1 (comment)


First of all, you released this plugin just when I was starting to lose hope of ever seeing one for Neovim so thank you so much!
I’ve tested it a bit and absolutely love the concept. Great work !
I’ve noticed a small issue. I tend to run multiple Neovim instances at once. To explain the problem, I ran cat on the stats file.
Here’s the test I did :

  1. Before any changes
cat triforce_stats.json
{"lines_typed":70,"chars_typed":44,"chars_by_language":{"markdown":7},"last_session_start":0,"level":1,"sessions":3,"time_coding":260,"xp":164,"daily_activity":{"2025-11-10":22,"2025-11-09":48},"current_streak":2,"longest_streak":2,"achievements":{}}
  1. I saved some Markdown in the first instance it went from 7 to 13
{"current_streak":2,"longest_streak":2,"sessions":4,"lines_typed":71,"chars_typed":56,"chars_by_language":{"markdown":13},"level":1,"last_session_start":1762794847,"achievements":{},"time_coding":260,"xp":227,"daily_activity":{"2025-11-09":48,"2025-11-10":22}}
  1. I saved some PHP changes in the second instance I ended up with 7 in Markdown and 15 in PHP (note that the Markdown changes from instance 1 were no longer counted)
{"xp":236,"lines_typed":70,"last_session_start":0,"sessions":4,"chars_typed":66,"chars_by_language":{"markdown":7,"php":15},"daily_activity":{"2025-11-10":22,"2025-11-09":48},"current_streak":2,"longest_streak":2,"achievements":{},"level":1,"time_coding":351}
  1. I exited the PHP instance
  2. I exited the Markdown instance
  • Final result: I had 15 in Markdown and no PHP stats
{"current_streak":2,"longest_streak":2,"sessions":4,"lines_typed":71,"chars_typed":61,"chars_by_language":{"markdown":15},"level":1,"last_session_start":0,"achievements":{},"time_coding":373,"xp":232,"daily_activity":{"2025-11-09":48,"2025-11-10":23}}

I haven’t looked at the code yet, but from what I can tell, the file isn’t being validated it just gets overwritten.
To fix this, I think the plugin should read the existing file and merge the current session’s stats into it.

Metadata

Metadata

Labels

bugSomething isn't workingdiscussionThis warrants discussion among the comunity

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions