1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00

Desktop: Fixes #9958: Highlight partial matches in search results

This commit is contained in:
Laurent Cozic 2024-02-19 10:01:54 +00:00
parent f378662196
commit 0b2bb80bb8

View File

@ -24,10 +24,17 @@ markJsUtils.markKeyword = (mark, keyword, stringUtils, extraOptions = null) => {
const isBasicSearch = ['ja', 'zh', 'ko'].indexOf(keyword.scriptType) >= 0; const isBasicSearch = ['ja', 'zh', 'ko'].indexOf(keyword.scriptType) >= 0;
let value = keyword.value; let value = keyword.value;
let accuracy = keyword.accuracy ? keyword.accuracy : { value: 'exactly', limiters: ':;.,-–—‒_(){}[]!\'"+='.split('') };
if (isBasicSearch) accuracy = 'partially'; const getAccuracy = (keyword) => {
if (isBasicSearch) return 'partially';
if (keyword.type === 'regex') return 'complementary';
if (keyword.accuracy) return keyword.accuracy;
return keyword.value.length >= 2 ? 'partially' : { value: 'exactly', limiters: ':;.,-–—‒_(){}[]!\'"+='.split('') };
};
const accuracy = getAccuracy(keyword);
if (keyword.type === 'regex') { if (keyword.type === 'regex') {
accuracy = 'complementary';
// Remove the trailing wildcard and "accuracy = complementary" will take // Remove the trailing wildcard and "accuracy = complementary" will take
// care of highlighting the relevant keywords. // care of highlighting the relevant keywords.