From 04d1572133f077c785f2c5467170b9b73c85037a Mon Sep 17 00:00:00 2001 From: MsfPablo <129399053+MsfPablo@users.noreply.github.com> Date: Mon, 3 Aug 2026 17:53:07 +0200 Subject: [PATCH] fix(word-count): treat apostrophes as part of a word WORD_COUNT_REGEX didn't include the apostrophe character, so contractions like "can't" were split into two matches ("can" and "t") and counted as two words instead of one. Add ' alongside the existing hyphen in the word-character class, so contractions and possessives ("can't", "Sarah's") count as a single word, consistent with how hyphenated words are already handled. Fixes #324 --- src/model/writing-session-tracker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/model/writing-session-tracker.ts b/src/model/writing-session-tracker.ts index 8ff738f..e0c44fa 100644 --- a/src/model/writing-session-tracker.ts +++ b/src/model/writing-session-tracker.ts @@ -30,7 +30,7 @@ const WORD_COUNT_REGEX = (() => { .source; return new RegExp( [ - "(?:[0-9]+(?:(?:,|\\.)[0-9]+)*|[\\-" + spaceDelimitedChars + "])+", + "(?:[0-9]+(?:(?:,|\\.)[0-9]+)*|['\\-" + spaceDelimitedChars + "])+", nonSpaceDelimitedWords, ].join("|"), "g"