Sorting of Component Browser Entries #5649
-
After some initial feedback, I looked at one of the currents of irregular sorting. Specifically, we had the case where It does seem that our scoring algorithm does NOT consider the placement of the match in the target text. That is, whether The only place where we do consider the placement is the search pattern. So, a match against the pattern "list" scores lower than "lis" or "list", but the placement of the match in the target text is not relevant. I think both of these should be considered, as both of them make sense, so I would propose we add both with separate configurable weights that can be tweaked. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Theoretically it should. The code is: let is_first_pattern_char = vertex.layer == 0;
let is_last_pattern_char = text.len().checked_sub(1).contains(&vertex.layer);
let first_char_bonus = if is_first_pattern_char {
self.base_weight / (vertex.position_in_text as f32 + 1.0) * self.beginning_weight
} else {
0.0
};
let last_char_bonus = if is_last_pattern_char {
self.base_weight / (text.len() - vertex.position_in_text) as f32 * self.ending_weight
} else {
0.0
}; As you see, if we are measuring first char in the pattern, we can add "first_char_bonus" which is lessened by (What looks suspicious, is the line |
Beta Was this translation helpful? Give feedback.
-
You are right. I was misled by the main checks, first looking at the pattern position of the match. You are double right about the |
Beta Was this translation helpful? Give feedback.
Theoretically it should. The code is:
As you see, if we…