summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimotheus Kampik <timotheus.kampik@gmail.com>2019-01-27 20:32:56 +0100
committerGitHub <noreply@github.com>2019-01-27 20:32:56 +0100
commit97d99f830258a4612a6c77f5be084819634dcbad (patch)
treecc858f5809b730f29b6bdd9dc101979156971b39
parent1ea41ed6ca885faf277fcea0d12783f462565fbc (diff)
parent25fd9d82a6ab5fbb996a36e146c3be4970d844f2 (diff)
downloadsphinx-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--CHANGES2
-rw-r--r--sphinx/themes/basic/static/searchtools.js8
2 files changed, 8 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 6f4b321ef..c7d8e4786 100644
--- a/CHANGES
+++ b/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
--------
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++) {