From 12112e0fc799541a60432e9bcbfd5c959cfeeb57 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Wed, 13 Dec 2017 16:28:08 -0500 Subject: [PATCH] Implement command-accept --rapid. command-accept --rapid will run the command without clearing the prompt, allowing "rapid fire" commands. For example, one could open completion for `open -t` and open several tabs in a row. The default binding is ctrl+enter. Resolves #588. --- qutebrowser/config/configdata.yml | 1 + qutebrowser/mainwindow/statusbar/command.py | 12 +++++++++--- tests/end2end/features/misc.feature | 7 +++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 15be675ae..8778cc013 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -2307,6 +2307,7 @@ bindings.default: : completion-item-yank : completion-item-yank --sel : command-accept + : command-accept --rapid : rl-backward-char : rl-forward-char : rl-backward-word diff --git a/qutebrowser/mainwindow/statusbar/command.py b/qutebrowser/mainwindow/statusbar/command.py index 8ae4fd566..3e0a339a3 100644 --- a/qutebrowser/mainwindow/statusbar/command.py +++ b/qutebrowser/mainwindow/statusbar/command.py @@ -156,8 +156,12 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): @cmdutils.register(instance='status-command', modes=[usertypes.KeyMode.command], scope='window') - def command_accept(self): - """Execute the command currently in the commandline.""" + def command_accept(self, rapid=False): + """Execute the command currently in the commandline. + + Args: + rapid: Run the command without closing or clearing the command bar. + """ prefixes = { ':': '', '/': 'search -- ', @@ -165,7 +169,9 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): } text = self.text() self.history.append(text) - modeman.leave(self._win_id, usertypes.KeyMode.command, 'cmd accept') + if not rapid: + modeman.leave(self._win_id, usertypes.KeyMode.command, + 'cmd accept') self.got_cmd[str].emit(prefixes[text[0]] + text[1:]) @cmdutils.register(instance='status-command', scope='window') diff --git a/tests/end2end/features/misc.feature b/tests/end2end/features/misc.feature index 82ae8cf91..8f21b7421 100644 --- a/tests/end2end/features/misc.feature +++ b/tests/end2end/features/misc.feature @@ -9,6 +9,13 @@ Feature: Various utility commands. And I run :command-accept Then the message "Hello World" should be shown + Scenario: :set-cmd-text and :command-accept --rapid + When I run :set-cmd-text :message-info "Hello World" + And I run :command-accept --rapid + And I run :command-accept + Then the message "Hello World" should be shown + And the message "Hello World" should be shown + Scenario: :set-cmd-text with two commands When I run :set-cmd-text :message-info test ;; message-error error And I run :command-accept