-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug 1930985 - Implement search engine order handling on the Rust based SearchEngineSelector. #6563
base: main
Are you sure you want to change the base?
Conversation
…d SearchEngineSelector.
This PR is still work in progress and there will be more changes soon. I've added the implemention for The part I need some feedback on right now is the first test I wrote, and of course everything else if there's any suggestions. I converted this test into Rust in the And I'm copying over this engine config from the top of the file: As I was following the test structure in My aim is to continue writing tests for starts_with and defaults engines. But that would mean I'll need to create another json config and another expected_engines list -- which I think is fine to do but there's a lot of duplication. Curious to know what your thoughts on this are? |
) -> std::cmp::Ordering { | ||
let b_index = get_priority(b, default_engine_id, default_private_engine_id); | ||
let a_index = get_priority(a, default_engine_id, default_private_engine_id); | ||
b_index.cmp(&a_index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a piece missing here, which the engine selector on desktop doesn't do - the items which aren't default/have an order hint set, need to be sorted alphabetically by their display name.
This is the full function we use: https://searchfox.org/mozilla-central/rev/5b061cdc4d40d44988dc61aa941cfbd98e31791f/toolkit/components/search/SearchUtils.sys.mjs#362-440
One thing I'm not sure about is how we'll handle the locale-based sorting like we do on desktop. I haven't looked into the options for sort functions on Rust.
@@ -221,7 +235,18 @@ fn find_engine_id(engines: &[SearchEngineDefinition], engine_id: String) -> Opti | |||
} | |||
} | |||
|
|||
fn find_engine_with_match( | |||
fn set_engine_order(engines: &mut [SearchEngineDefinition], ordered_engines: &[String]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm tempted to say we could put the sort related functions into a separate module, which might make it easier to write unit tests for them (and smaller module sizes), what do you think?
Pull Request checklist
[ci full]
to the PR title.Branch builds: add
[firefox-android: branch-name]
to the PR title.