lookingGlass: Let history trim input
Checking whether the item is empty is now the history’s job, per the previous two commits. The history also trims the input for us. The effect of this is that we call _history.addItem(), and thereby move to the end of the history, even if the input is empty (or consists only of whitespace); clearing the input field and pressing Enter becomes a quick way to jump back to the end of the history. (The current history item is not overwritten if the input is empty.) Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1653>
This commit is contained in:
parent
df94055c58
commit
bbf1fc28ca
@ -1129,10 +1129,6 @@ class LookingGlass extends St.BoxLayout {
|
|||||||
// Ensure we don't get newlines in the command; the history file is
|
// Ensure we don't get newlines in the command; the history file is
|
||||||
// newline-separated.
|
// newline-separated.
|
||||||
text = text.replace('\n', ' ');
|
text = text.replace('\n', ' ');
|
||||||
// Strip leading and trailing whitespace
|
|
||||||
text = text.replace(/^\s+/g, '').replace(/\s+$/g, '');
|
|
||||||
if (text == '')
|
|
||||||
return true;
|
|
||||||
this._evaluate(text);
|
this._evaluate(text);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@ -1240,7 +1236,9 @@ class LookingGlass extends St.BoxLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_evaluate(command) {
|
_evaluate(command) {
|
||||||
this._history.addItem(command);
|
command = this._history.addItem(command); // trims command
|
||||||
|
if (!command)
|
||||||
|
return;
|
||||||
|
|
||||||
let lines = command.split(';');
|
let lines = command.split(';');
|
||||||
lines.push('return %s'.format(lines.pop()));
|
lines.push('return %s'.format(lines.pop()));
|
||||||
|
Loading…
Reference in New Issue
Block a user