kevboh / longform

A plugin for Obsidian that helps you write and edit novels, screenplays, and other long projects.
Other
610 stars 30 forks source link

fix: calculate word count diff for new scenes in a session, fixes #93 #178

Closed neilgoodman closed 11 months ago

neilgoodman commented 11 months ago

I believe this fixes issue #93.

To repro the bug:

  1. Open existing Longform project and create a new scene
  2. Type words into the new scene

Expected: Word count will be added to the current session total Actual: New words are ignored

I debugged the plugin using the test vault and noticed that for new scenes, the startSceneCount in the WritingSessionTracker.tickSession method always ended up as null, which would cause the diff variable to be set to 0. My fix is to just return the sceneCount for this case.

I think this is the root cause to #93, I did test using copy/paste and it seems to be fine, but I also only reviewed the code base for a few hours, so I could be missing something. This does resolve the session word count issue I've been running into though.

kevboh commented 11 months ago

I honestly have no memory of writing any of this code and sort of suspect I entered some sort of fugue state, so your guess is as good as mine. Thank you!

neilgoodman commented 11 months ago

No problem. Thanks for all the work on the plugin! I've been finding it very helpful.