Skip to content

Commit

Permalink
Re-apply "remove unit-test and fix code related to sphinx-doc#12040"
Browse files Browse the repository at this point in the history
This reverts commit 23da660.
  • Loading branch information
jayaddison committed Mar 2, 2024
1 parent 23da660 commit 36bfce9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sphinx/themes/basic/static/searchtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ const Search = {
});
Object.keys(titleTerms).forEach((term) => {
if (term.match(escapedWord) && titleTerms[word] === undefined)
arr.push({ files: titleTerms[word], score: Scorer.partialTitle });
arr.push({ files: titleTerms[term], score: Scorer.partialTitle });
});
}

Expand Down
25 changes: 25 additions & 0 deletions tests/js/searchtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,31 @@ describe('Basic html theme search', function() {
expect(Search.performTermsSearch(searchterms, excluded, terms, titleterms)).toEqual(hits);
});

it('should partially-match "sphinx" when in title index', function() {
index = {
docnames:["index"],
filenames:["index.rst"],
terms:{'useful': 0, 'utilities': 0},
titles:["sphinx_utils module"],
titleterms:{'sphinx_utils': 0}
}
Search.setIndex(index);
searchterms = ['sphinx'];
excluded = [];
terms = index.terms;
titleterms = index.titleterms;

hits = [[
"index",
"sphinx_utils module",
"",
null,
7,
"index.rst"
]];
expect(Search.performTermsSearch(searchterms, excluded, terms, titleterms)).toEqual(hits);
});

});

});
Expand Down

0 comments on commit 36bfce9

Please sign in to comment.