diff --git a/qutebrowser/commands/runners.py b/qutebrowser/commands/runners.py index 80782d504..edb3720f9 100644 --- a/qutebrowser/commands/runners.py +++ b/qutebrowser/commands/runners.py @@ -275,6 +275,10 @@ class CommandRunner(QObject): count: The count to pass to the command. """ for result in self.parse_all(text): + mode_manager = objreg.get('mode-manager', scope='window', + window=self._win_id) + cur_mode = mode_manager.mode + args = replace_variables(self._win_id, result.args) if count is not None: if result.count is not None: @@ -286,11 +290,8 @@ class CommandRunner(QObject): else: result.cmd.run(self._win_id, args) - mode_manager = objreg.get('mode-manager', scope='window', - window=self._win_id) - if result.cmdline[0] not in ['leave-mode', 'command-accept', - 'repeat-command']: - last_command[mode_manager.mode] = ( + if result.cmdline[0] != 'repeat-command': + last_command[cur_mode] = ( self._parse_count(text)[1], count if count is not None else result.count) diff --git a/tests/end2end/features/misc.feature b/tests/end2end/features/misc.feature index 8f458f1a3..50c36715a 100644 --- a/tests/end2end/features/misc.feature +++ b/tests/end2end/features/misc.feature @@ -490,3 +490,15 @@ Feature: Various utility commands. And I run :repeat-command with count 2 Then the page should not be scrolled And the error "prompt-accept: This command is only allowed in prompt/yesno mode." should be shown + + Scenario: :repeat-command with mode-switching command + Given I open data/hints/link_blank.html + And I run :tab-only + When I run :hint + And I run :leave-mode + And I run :repeat-command + And I run :follow-hint a + And I wait until data/hello.txt is loaded + Then the following tabs should be open: + - data/hints/link_blank.html + - data/hello.txt (active)