[gnome-shell] history: Trim input and ignore if empty
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] history: Trim input and ignore if empty
- Date: Sat, 13 Feb 2021 09:01:23 +0000 (UTC)
commit d31f805817970fe42e3c0dae5e3faa6eca2ef88e
Author: Lucas Werkmeister <mail lucaswerkmeister de>
Date: Mon Feb 8 22:20:42 2021 +0100
history: Trim input and ignore if empty
This ports the runDialog changes of [1] to the underlying history
component, where they can benefit looking glass as well: the history is
now responsible for trimming the input and deciding that it shouldn’t be
stored if empty. (Note that _setPrevItem and _setNextItem already
skipped updating the history if the entry was empty.)
Since both users, runDialog and lookingGlass, also need the trimmed
input for other reasons – runDialog to avoid issues when interpreting
the command as a file path (if it can’t be executed as a command),
lookingGlass to decide whether a command should be run at all – have
addItem return the trimmed input. (runDialog and lookingGlass are not
yet changed to take advantage of this – that will be done in separate
commits.)
[1]: https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1442
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1653>
js/misc/history.js | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/js/misc/history.js b/js/misc/history.js
index c7859953d6..4152588818 100644
--- a/js/misc/history.js
+++ b/js/misc/history.js
@@ -69,21 +69,24 @@ var HistoryManager = class {
}
addItem(input) {
- if (this._history.length === 0 ||
- this._history[this._history.length - 1] !== input) {
+ input = input.trim();
+ if (input &&
+ (this._history.length === 0 ||
+ this._history[this._history.length - 1] !== input)) {
this._history = this._history.filter(entry => entry !== input);
this._history.push(input);
this._save();
}
this._historyIndex = this._history.length;
+ return input; // trimmed
}
_onEntryKeyPress(entry, event) {
let symbol = event.get_key_symbol();
if (symbol === Clutter.KEY_Up)
- return this._setPrevItem(entry.get_text());
+ return this._setPrevItem(entry.get_text().trim());
else if (symbol === Clutter.KEY_Down)
- return this._setNextItem(entry.get_text());
+ return this._setNextItem(entry.get_text().trim());
return Clutter.EVENT_PROPAGATE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]