Feature: warning for similar tags#2064
Open
hanbeex wants to merge 3 commits into
Open
Conversation
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.
Description
This PR adds a fuzzy tag similarity warning when writing a new journal entry. If any tag in the new entry closely resembles an existing tag in the journal, jrnl prints a warning suggesting the user double-check for typos.
Motivation: Tag typos silently fragment what should be a single tag group. For example, accidentally writing
@worksinstead of@workresults in two separate tags that are hard to notice and tedious to fix later. Surfacing this immediately after writing to make it easy to catch and correct.What it does:
difflib.get_close_matcheswith a similarity cutoff of 0.8@for people,#for topics) don't produce false positives — this also means customtagsymbolsfrom the config file are handled correctlyOnly outputs a warning and doesn't ask 'Are you sure?' to the user Some similar-looking tags are perfectly meaningful to keep separate. For example,
@healthand@wealth,@friendand@fiend, or@hikingand@bikingare all ≥80% similar but represent distinct concepts. Asking "are you sure?" every time would be more annoying than helpful.Example output:
Files changed:
jrnl/controller.py- added_check_similar_tags()helper and hooked it intoappend_modejrnl/messages/MsgText.py- addedSimilarTagsFoundwarning messagetests/unit/test_controller.py- addedTestCheckSimilarTagswith 8 unit testsdocs/usage.md- documented the warning and explained why no confirmation is shownjrnl/__version__.py/pyproject.toml- fixed a pre-existing version string mismatch (v4.3vs4.3) that was causing 6 BDD test failures on thedevelopbranchChecklist
for the same issue.