Skip to content

fix(library): rank exact matches first in tag search sorting - #1582

Closed
sanketpatel32 wants to merge 1 commit into
TagStudioDev:mainfrom
sanketpatel32:devin/fix-tag-search-sorting
Closed

sanketpatel32 wants to merge 1 commit into
TagStudioDev:mainfrom
sanketpatel32:devin/fix-tag-search-sorting

Conversation

@sanketpatel32

Copy link
Copy Markdown

Summary

Fixes #1381 and fixes #1413. search_tags ranked results by name.startswith(query) on the raw stored name against an already-lowered query, so:

The sort key now compares normalized text (strip().lower()), ranks exact matches first, then prefix matches by length, then alphabetically. Verified: anatomy → Anatomy, Anthro; b → black, blue.

Tasks Completed

  • Platforms Tested:
    • Windows x86
    • Windows ARM
    • macOS x86
    • macOS ARM
    • Linux x86
    • Linux ARM
  • Tested For:
    • Basic functionality (reproduced both issue cases against a scratch library; pre-commit hooks passing)
    • PyInstaller executable

search_tags sorted by whether the raw name startswith the query, so
names with leading whitespace never got prefix priority and an exact
alias/shorthand match lost to shorter prefix matches. The sort key
now compares normalized text, ranks exact matches first, then prefix
matches.

Fixes TagStudioDev#1381, fixes TagStudioDev#1413
@CyanVoxel CyanVoxel added the Type: Invalid This doesn't seem right label Nov 23, 2026
@CyanVoxel CyanVoxel closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Unexpected Tag Sorting Results [Bug][UX]: entering a shorthand does not cause that tag to present at the top of the tag search results

2 participants