Fix empty-note threshold, drop dead orphan-link code, dedupe byte formatting#91
Merged
Conversation
… word count The threshold setting was dead — the scanner only checked for zero-length content and never read ctx.emptyNoteWordThreshold, so the slider had no effect. Count words with a CJK-aware counter (each Han/kana/hangul char counts as one word; Latin text splits on whitespace) so the threshold works for both Chinese and English notes. Short non-empty notes now get a stub-specific message and a wordCount evidence field.
The optimization cast resolvedLinks values to string and checked typeof === "string", but Obsidian stores link counts there as numbers, so the branch never ran. resolvedLinks also only tracks markdown-to-markdown references and cannot resolve attachment link targets anyway. Drop the dead branch; every link already falls through to resolveVaultLinkTargets, so behavior is unchanged.
render-issues.ts and markdown-export.ts each carried a near-identical local formatBytes while utils/format.ts already exports formatSize for the same purpose. Remove both copies and route all byte formatting through the shared helper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three fixes found while auditing the codebase for obvious issues. lint / build / test (163 passing) all green; split into one commit per logical change.
1.
emptyNoteWordThresholdsetting had no effect (functional bug)The empty-notes scanner only checked for zero-length content and never read
ctx.emptyNoteWordThreshold, so the settings slider did nothing — only completely empty notes were ever flagged.countWords()with CJK-aware counting: each Han / Hiragana / Katakana / Hangul character counts as one word (CJK text has no word separators), Latin/other text splits on whitespace, mixed content sums correctly. Without this the threshold is meaningless on Chinese vaults.countWords(body) <= ctx.emptyNoteWordThreshold."only has N words") and awordCountevidence field.2. Dead
resolvedLinksfast path inorphan-attachmentsThe optimization cast
resolvedLinksvalues tostringand checkedtypeof === "string", but Obsidian stores link counts there asnumber, so the branch never executed. It also couldn't work as intended:resolvedLinksonly tracks markdown-to-markdown references and cannot resolve attachment link targets to disk paths. Removed the dead branch; every link already falls through toresolveVaultLinkTargets, so behavior is unchanged.3. Duplicated
formatByteshelpersrender-issues.tsandmarkdown-export.tseach carried a near-identical localformatBytes, whileutils/format.tsalready exportsformatSizefor the same purpose. Removed both copies and routed all byte formatting through the shared helper.Validation
npm run lint✅npm run lint:obsidian-warnings✅npm run build✅npm test✅ 163/163