[gnome-shell] systemActions: Filter out empty (folded) terms
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] systemActions: Filter out empty (folded) terms
- Date: Mon, 14 Sep 2020 21:14:26 +0000 (UTC)
commit b2d6c11ec39042855910f36d59e0789e16593fb9
Author: Florian Müllner <fmuellner gnome org>
Date: Sat Sep 12 18:32:57 2020 +0200
systemActions: Filter out empty (folded) terms
We split the search string into words using whitespace, while
GLib.tokenize_and_fold() splits on any non-alphanumeric characters.
That is, a valid search term like ',' will be tokenized as [], so
the original non-empty terms may get mapped to an empty array.
And as [].every() returns true for any condition[0], we end up
matching *all* system actions in that case. We want the exact
opposite and not return any results, so handle that case explicitly.
[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3169
js/misc/systemActions.js | 4 ++++
1 file changed, 4 insertions(+)
---
diff --git a/js/misc/systemActions.js b/js/misc/systemActions.js
index 4c2f3a2905..1cd6576488 100644
--- a/js/misc/systemActions.js
+++ b/js/misc/systemActions.js
@@ -269,6 +269,10 @@ const SystemActions = GObject.registerClass({
terms = terms.map(
term => GLib.str_tokenize_and_fold(term, null)[0]).flat(2);
+ // tokenizing may return an empty array
+ if (terms.length === 0)
+ return [];
+
let results = [];
for (let [key, { available, keywords }] of this._actions) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]