Skip to content

fix(Scorer): honour _preScored for no-query when value exceeds typeBonus#2065

Merged
bbedward merged 1 commit intoAvengeMedia:masterfrom
devnullvoid:fix/scorer-prescored-no-query
Mar 23, 2026
Merged

fix(Scorer): honour _preScored for no-query when value exceeds typeBonus#2065
bbedward merged 1 commit intoAvengeMedia:masterfrom
devnullvoid:fix/scorer-prescored-no-query

Conversation

@devnullvoid
Copy link
Copy Markdown
Contributor

Summary

  • _preScored was only respected by the Scorer when an active search query existed. In no-query (default) mode all plugin items fell back to typeBonus + frecency scoring (900 for plugins), making plugin-controlled ordering of the default list impossible.
  • Change the condition to also honour _preScored in no-query mode when the value exceeds 900 (the plugin typeBonus). Values ≤ 900 continue to use the existing formula, so items whose _preScored is set to 900 - j by the controller in "all" mode are unaffected.

Change

// Before
if (query && item._preScored !== undefined) {

// After
if (item._preScored !== undefined && (query || item._preScored > 900)) {

Motivation

This unblocks plugins that want to surface priority items (e.g. recently-used) at the top of their default no-query list. Without this fix a plugin can sort its getItems("") return value correctly but DMS will re-score everything equally and discard that ordering.

The specific use-case is the dms-emoji-launcher plugin surfacing recently-used emojis at the top of the :e trigger default list.

Test plan

  • Open launcher with no query — plugin items with _preScored > 900 appear above other plugin items
  • Open launcher and type a search query — existing scoring behaviour unchanged
  • Verify "all" mode default list (apps, files) is unaffected (their _preScored ≤ 900 or undefined)

Plugin items can set _preScored to signal a priority boost (e.g. recently
used items). Previously _preScored was only respected when a search query
was active, so no-query default lists always fell back to typeBonus+frecency
scoring, making plugin-controlled ordering impossible.

Change the condition from:
  if (query && item._preScored !== undefined)
to:
  if (item._preScored !== undefined && (query || item._preScored > 900))

This respects _preScored in no-query mode only when the value exceeds 900
(the plugin typeBonus), which avoids changing behaviour for "all" mode items
whose _preScored is set to 900-j by the controller (≤ 900). Items without
_preScored set continue to use the existing typeBonus + frecency formula.
devnullvoid added a commit to devnullvoid/dms-emoji-launcher that referenced this pull request Mar 23, 2026
Merges fix/issues-12-13-14

#12 — Heart emoji search: skin-tone variants were flooding results and
pushing colored hearts past the 50-item cutoff. Fixed by only applying
the SKIN_TONE_PENALTY when score > 0, so variants don't score 1 in the
unfiltered default list.

#13 — Unicode v17.0: added 8 new emojis (distorted face, fight cloud,
orca, hairy creature, trombone, landslide, treasure chest, ballet dancer)
and regenerated catalog.js.

#14 — Recently used: tracks the last 20 selected emojis and surfaces them
at the top of the default (no-query) list using _preScored > 900. Requires
AvengeMedia/DankMaterialShell#2065 to be merged for the float-to-top
behaviour; tracking and persistence work independently of that fix.
@bbedward bbedward merged commit 3804d2f into AvengeMedia:master Mar 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants