fix search: search should not be case-sensisitve

This commit is contained in:
Mahdi Dibaiee 2015-09-06 19:37:14 +04:30
parent a265f13cca
commit a9757f86bf
3 changed files with 8 additions and 6 deletions

View File

@ -32135,13 +32135,14 @@ exports['default'] = function (state, action) {
function search(keywords) { function search(keywords) {
if (!keywords) { if (!keywords) {
var cwd = _store2['default'].getState().get('cwd'); var cwd = _store2['default'].getState().get('cwd');
console.log(cwd);
(0, _apiFiles.children)(cwd, true).then(function (files) { (0, _apiFiles.children)(cwd, true).then(function (files) {
_store2['default'].dispatch((0, _actionsFilesView.listFiles)(files)); _store2['default'].dispatch((0, _actionsFilesView.listFiles)(files));
}, _utils.reportError); }, _utils.reportError);
return ''; return '';
} }
var keys = keywords.split(' '); var keys = keywords.split(' ').map(function (key) {
return key.toLowerCase();
});
// We don't want to show all the currently visible files from the // We don't want to show all the currently visible files from the
// first iteration // first iteration
@ -32158,10 +32159,11 @@ function search(keywords) {
(0, _apiFiles.children)(path, true).then(showResults, _utils.reportError); (0, _apiFiles.children)(path, true).then(showResults, _utils.reportError);
} }
return keys.some(function (key) { return keys.some(function (key) {
return file.name.indexOf(key) > -1; return file.name.toLowerCase().indexOf(key) > -1;
}); });
}); });
if (!filtered.length) return;
_store2['default'].dispatch((0, _actionsFilesView.listFiles)(current.concat(filtered))); _store2['default'].dispatch((0, _actionsFilesView.listFiles)(current.concat(filtered)));
}, _utils.reportError); }, _utils.reportError);
} }

Binary file not shown.

View File

@ -18,13 +18,12 @@ export default function(state = '', action) {
function search(keywords) { function search(keywords) {
if (!keywords) { if (!keywords) {
let cwd = store.getState().get('cwd'); let cwd = store.getState().get('cwd');
console.log(cwd);
children(cwd, true).then(files => { children(cwd, true).then(files => {
store.dispatch(listFiles(files)); store.dispatch(listFiles(files));
}, reportError); }, reportError);
return ''; return '';
} }
let keys = keywords.split(' '); let keys = keywords.split(' ').map(key => key.toLowerCase());
// We don't want to show all the currently visible files from the // We don't want to show all the currently visible files from the
// first iteration // first iteration
@ -41,10 +40,11 @@ function search(keywords) {
children(path, true).then(showResults, reportError); children(path, true).then(showResults, reportError);
} }
return keys.some(key => { return keys.some(key => {
return file.name.indexOf(key) > -1; return file.name.toLowerCase().indexOf(key) > -1;
}); });
}); });
if (!filtered.length) return;
store.dispatch(listFiles(current.concat(filtered))); store.dispatch(listFiles(current.concat(filtered)));
}, reportError); }, reportError);
} }