1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

CLI: Fixes #1096: Fixed search function in terminal app

This commit is contained in:
Laurent Cozic 2019-01-10 19:25:21 +00:00
parent 7c3e8547de
commit 6989f9fd16
2 changed files with 18 additions and 1 deletions

View File

@ -41,6 +41,7 @@ class Command extends BaseCommand {
title: pattern,
query_pattern: pattern,
query_folder_id: folder ? folder.id : '',
basic_search: true,
type_: BaseModel.TYPE_SEARCH,
},
});

View File

@ -220,7 +220,23 @@ class BaseApplication {
notes = await Tag.notes(parentId, options);
} else if (parentType === BaseModel.TYPE_SEARCH) {
const search = BaseModel.byId(state.searches, parentId);
notes = await SearchEngineUtils.notesForQuery(search.query_pattern);
if (search.basic_search) {
// NOTE: Copied and pasted from ReactNativeClient/lib/components/screens/search.js
let p = search.query_pattern.split(' ');
let temp = [];
for (let i = 0; i < p.length; i++) {
let t = p[i].trim();
if (!t) continue;
temp.push(t);
}
notes = await Note.previews(null, {
anywherePattern: '*' + temp.join('*') + '*',
});
} else {
notes = await SearchEngineUtils.notesForQuery(search.query_pattern);
}
}
}