mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5979 from TimKam/4649-fix-search-for-filenames
The search function considers every page a "miss"/no match if the search contains a term with length <= 2; This is problem when users search for filenames, identifiers, et cetera. This PR changes the behavior to be more lenient in such cases: if an additional search term is of length <= 2, it is ignored (no longer a necessary condition for a match).
This commit is contained in:
commit
97d99f8302
2
CHANGES
2
CHANGES
@ -188,6 +188,8 @@ Bugs fixed
|
||||
* HTML: Invalid HTML5 file is generated for a glossary having multiple terms for
|
||||
one description (refs: #4611)
|
||||
* QtHelp: OS dependent path separator is used in .qhp file
|
||||
* HTML search: search always returns nothing when multiple search terms are
|
||||
used and one term is shorter than three characters
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -443,8 +443,12 @@ var Search = {
|
||||
var valid = true;
|
||||
|
||||
// check if all requirements are matched
|
||||
if (fileMap[file].length != searchterms.length)
|
||||
continue;
|
||||
var filteredTermCount = // as search terms with length < 3 are discarded: ignore
|
||||
searchterms.filter(function(term){return term.length > 2}).length
|
||||
if (
|
||||
fileMap[file].length != searchterms.length &&
|
||||
fileMap[file].length != filteredTermCount
|
||||
) continue;
|
||||
|
||||
// ensure that none of the excluded terms is in the search result
|
||||
for (i = 0; i < excluded.length; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user