Skip to content

Commit ff78867

Browse files
committed
favor first item
1 parent 723e754 commit ff78867

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/textual/fuzzy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ def score(search: _Search) -> float:
124124
"""
125125
# This is a heuristic, and can be tweaked for better results
126126
# Boost first letter matches
127-
score: float = sum(
128-
(2.0 if offset in first_letters else 1.0) for offset in search.offsets
127+
score: float = len(search.offsets) + len(
128+
first_letters.intersection(search.offsets)
129129
)
130130
# Boost to favor less groups
131131
offset_count = len(search.offsets)
@@ -151,8 +151,8 @@ def score(search: _Search) -> float:
151151
yield score(advance_branch), advance_branch.offsets
152152
push(branch)
153153
else:
154-
push(advance_branch)
155154
push(branch)
155+
push(advance_branch)
156156

157157

158158
@rich.repr.auto

0 commit comments

Comments
 (0)