-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
search.js: split out nested functions #91992
Conversation
`execSearch` was a giant function with a number of other very large functions embedded inside it. This moves the embedded functions out of execSearch, so execSearch's function signature can be read next to its code. `sortResults` was relying on capturing certain variables from its environment, so I made those into explicity parameters passed into `sortResults`.
Some changes occurred in HTML/CSS/JS. |
The job Click to see the possible cause of the failure (guessed by this bot)
|
It looks like this runs into a problem with src/tools/rustdoc-js/tester.js. The tester doesn't actually load search.js as a module; instead it processes search.js to try and find certain functions and variables and extract them. So it's extracting execQuery but not the functions execQuery depends on. I think the fix may be to just load search.js as a module. |
It's actually complicated to import Also, can you wait for #91977 to be merged first please? :) |
Yes, definitely happy to wait for #91977, just wanted to get this idea up for a look.
Yes, this is true, but I think it's worthwhile to refactor somewhat so it doesn't need global variables. Then we can have a pure function that takes as input the corpus, a query, and some config options. That should make it simpler to test and we can remove a lot of the tester code. That will also open up the possibility of using JS code coverage tools to see what needs more testing. |
☔ The latest upstream changes (presumably #92064) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm going to close this for now since it would generate a lot of conflicts with #90630, and this is a fairly straightforward refactoring that can be applied after that PR lands. |
execSearch
was a giant function with a number of other very large functions embedded inside it. This moves the embedded functions out of execSearch, so execSearch's function signature can be read next to its code.sortResults
was relying on capturing certain variables from its environment, so I made those into explicity parameters passed intosortResults
.This doesn't change any functionality. It also doesn't change any comments or parameters other than those used by
sortResults
. It just moves lines from one place to another and changes indentation.Discussed on Discord.
r? @GuillaumeGomez