From a0b05422188d7afd8200f8a541a89d46baff2c20 Mon Sep 17 00:00:00 2001 From: Timotheus Kampik Date: Wed, 20 Nov 2019 21:13:54 +0100 Subject: [PATCH] 6824 fix search js bug (#6844) * #6824: Fix search logic (front end) Prevent duplicate additions of terms to a file in ``fileMap``, document search fix in change log --- CHANGES | 3 +++ sphinx/themes/basic/static/searchtools.js | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 9780573c9..9e3550e1d 100644 --- a/CHANGES +++ b/CHANGES @@ -70,6 +70,9 @@ Bugs fixed * #6813: An orphan warning is emitted for included document on Windows. Thanks to @drillan * #6850: Fix smartypants module calls re.sub() with wrong options +* #6824: HTML search: If a search term is partially matched in the title and + fully matched in a text paragraph on the same page, the search does not + include this match. Testing -------- diff --git a/sphinx/themes/basic/static/searchtools.js b/sphinx/themes/basic/static/searchtools.js index 7e0174e1c..ad845872e 100644 --- a/sphinx/themes/basic/static/searchtools.js +++ b/sphinx/themes/basic/static/searchtools.js @@ -424,7 +424,7 @@ var Search = { for (j = 0; j < _files.length; j++) { file = _files[j]; if (!(file in scoreMap)) - scoreMap[file] = {} + scoreMap[file] = {}; scoreMap[file][word] = o.score; } }); @@ -432,7 +432,7 @@ var Search = { // create the mapping for (j = 0; j < files.length; j++) { file = files[j]; - if (file in fileMap) + if (file in fileMap && fileMap[file].indexOf(word) === -1) fileMap[file].push(word); else fileMap[file] = [word];