x/pkgsite: "jump to" search improvement #42489
What is the URL of the page with the issue?
What is your user agent?
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36
What did you do?
I really like the "jump to" feature ('f' keyboard shortcut).
I press 'f', then 'H' in the search box. gin has a type named
What did you expect to see?
I'd expect the
What did you see instead?
A whole bunch of test results before the
This search should be more than just subset match. It should prioritize whole matches (e.g. if I search
As of now, this search is less useful than it could be due to this (and it could be very useful indeed!!)
The text was updated successfully, but these errors were encountered:
Yes, that would be the best outcome! The plain (full match)
I'll take a look to evaluate.
Your JS code is very clean and easy to grok, kudos :-)
The current algorithm is coded in https://github.com/golang/pkgsite/blob/244535af9dc4b75ff3d387c93e35c60467cbf85e/content/static/js/jump.js#L152
A case-insensitive regexp for the search filter is matched with each potential item in the jump list, and the matching ones are shown - in order of original appearance (which is the alphabetic order). To fix this, the algorithm can be modified as follows:
Then concatenate them in the order outlined above and display.
I'm looking into setting up a local pkgsite instance to try this