Ignore leading spaces in search box

(imported from commit 098a8f288c8264cc804b737f804b866c64c0ff5b)
This commit is contained in:
Leo Franchi 2013-05-30 17:47:32 -04:00 committed by Steve Howell
parent b1f1f2b978
commit 0524c14c8c
2 changed files with 15 additions and 7 deletions

View File

@ -296,7 +296,11 @@ exports.set_compose_defaults = function (opts) {
exports.parse = function (str) {
var operators = [];
var search_term = [];
$.each(str.match(/"[^"]+"|\S+/g), function (idx, token) {
var matches = str.match(/"[^"]+"|\S+/g);
if (matches === null) {
return operators;
}
$.each(matches, function (idx, token) {
var parts, operator;
if (token.length === 0)
return;

View File

@ -203,12 +203,16 @@ exports.initialize = function () {
// Add an entry for narrow by operators.
var operators = narrow.parse(query);
var obj = {action: 'operators', query: query, operators: operators};
var label = render_object(obj);
mapped[label] = obj;
labels.unshift(label);
if (operators.length !== 0) {
var obj = {action: 'operators', query: query, operators: operators};
var label = render_object(obj);
mapped[label] = obj;
labels.unshift(label);
return labels;
return labels;
} else {
return [];
}
},
items: 20,
highlighter: function (item) {
@ -283,7 +287,7 @@ exports.initialize = function () {
// operators. (The reason the other actions don't call
// this codepath is that they first all blur the box to
// indicate that they've done what they need to do)
if (search_query_box.val()) {
if (search_query_box.val().trim()) {
narrow.activate(narrow.parse(search_query_box.val()));
}
search_query_box.blur();