diff options
| author | Timotheus Kampik <timotheus.kampik@gmail.com> | 2019-01-27 20:32:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-27 20:32:56 +0100 |
| commit | 97d99f830258a4612a6c77f5be084819634dcbad (patch) | |
| tree | cc858f5809b730f29b6bdd9dc101979156971b39 | |
| parent | 1ea41ed6ca885faf277fcea0d12783f462565fbc (diff) | |
| parent | 25fd9d82a6ab5fbb996a36e146c3be4970d844f2 (diff) | |
| download | sphinx-git-97d99f830258a4612a6c77f5be084819634dcbad.tar.gz | |
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).
| -rw-r--r-- | CHANGES | 2 | ||||
| -rw-r--r-- | sphinx/themes/basic/static/searchtools.js | 8 |
2 files changed, 8 insertions, 2 deletions
@@ -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 -------- diff --git a/sphinx/themes/basic/static/searchtools.js b/sphinx/themes/basic/static/searchtools.js index d462f76e2..e15d80036 100644 --- a/sphinx/themes/basic/static/searchtools.js +++ b/sphinx/themes/basic/static/searchtools.js @@ -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++) { |
