Move repeat-command, make it work with multiple modes, improve tests
This commit is contained in:
parent
64731c2053
commit
320b9cac3f
@ -1972,17 +1972,3 @@ class CommandDispatcher:
|
|||||||
key: mark identifier; capital indicates a global mark
|
key: mark identifier; capital indicates a global mark
|
||||||
"""
|
"""
|
||||||
self._tabbed_browser.jump_mark(key)
|
self._tabbed_browser.jump_mark(key)
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
|
||||||
@cmdutils.argument('count', count=True)
|
|
||||||
def repeat_command(self, count=None):
|
|
||||||
"""Repeat the last executed command, like '.' in vi.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
count: Which numeric argument to give the command.
|
|
||||||
"""
|
|
||||||
if runners.last_command is None:
|
|
||||||
raise cmdexc.CommandError("You didn't do anything yet.")
|
|
||||||
runners.CommandRunner(self._win_id).run(
|
|
||||||
runners.last_command[0],
|
|
||||||
count if count is not None else runners.last_command[1])
|
|
||||||
|
@ -32,7 +32,7 @@ from qutebrowser.misc import split
|
|||||||
|
|
||||||
ParseResult = collections.namedtuple('ParseResult', ['cmd', 'args', 'cmdline',
|
ParseResult = collections.namedtuple('ParseResult', ['cmd', 'args', 'cmdline',
|
||||||
'count'])
|
'count'])
|
||||||
last_command = None
|
last_command = {}
|
||||||
|
|
||||||
|
|
||||||
def _current_url(tabbed_browser):
|
def _current_url(tabbed_browser):
|
||||||
@ -286,11 +286,14 @@ class CommandRunner(QObject):
|
|||||||
else:
|
else:
|
||||||
result.cmd.run(self._win_id, args)
|
result.cmd.run(self._win_id, args)
|
||||||
|
|
||||||
|
mode_manager = objreg.get('mode-manager', scope='window',
|
||||||
|
window=self._win_id)
|
||||||
if (result.cmdline[0] != 'repeat-command' and
|
if (result.cmdline[0] != 'repeat-command' and
|
||||||
result.cmd.mode_allowed(usertypes.KeyMode.normal)):
|
result.cmd.mode_allowed(mode_manager.mode)):
|
||||||
global last_command
|
global last_command
|
||||||
last_command = (self._parse_count(text)[1],
|
last_command[mode_manager.mode] = (
|
||||||
count if count is not None else result.count)
|
self._parse_count(text)[1],
|
||||||
|
count if count is not None else result.count)
|
||||||
|
|
||||||
@pyqtSlot(str, int)
|
@pyqtSlot(str, int)
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
|
@ -217,3 +217,19 @@ def debug_set_fake_clipboard(s=None):
|
|||||||
utils.log_clipboard = True
|
utils.log_clipboard = True
|
||||||
else:
|
else:
|
||||||
utils.fake_clipboard = s
|
utils.fake_clipboard = s
|
||||||
|
|
||||||
|
@cmdutils.register()
|
||||||
|
@cmdutils.argument('win_id', win_id=True)
|
||||||
|
@cmdutils.argument('count', count=True)
|
||||||
|
def repeat_command(win_id, count=None):
|
||||||
|
"""Repeat the last executed command, like '.' in vi.
|
||||||
|
Args:
|
||||||
|
count: Which numeric argument to give the command.
|
||||||
|
"""
|
||||||
|
mode_manager = objreg.get('mode-manager', scope='window',
|
||||||
|
window=win_id)
|
||||||
|
if mode_manager.mode not in runners.last_command:
|
||||||
|
raise cmdexc.CommandError("You didn't do anything yet.")
|
||||||
|
cmd = runners.last_command[mode_manager.mode]
|
||||||
|
commandrunner = runners.CommandRunner(win_id)
|
||||||
|
commandrunner.run(cmd[0], count if count is not None else cmd[1])
|
||||||
|
@ -464,3 +464,26 @@ Feature: Various utility commands.
|
|||||||
And I wait until cookies is loaded
|
And I wait until cookies is loaded
|
||||||
And I open cookies in a new tab
|
And I open cookies in a new tab
|
||||||
Then the cookie qute-test should be set to 42
|
Then the cookie qute-test should be set to 42
|
||||||
|
|
||||||
|
Scenario: :repeat-command
|
||||||
|
Given I open data/scroll.html
|
||||||
|
When I run :scroll down
|
||||||
|
And I run :repeat-command
|
||||||
|
And I run :scroll up
|
||||||
|
Then the page should be scrolled vertically
|
||||||
|
|
||||||
|
Scenario: :repeat-command with count
|
||||||
|
Given I open data/scroll.html
|
||||||
|
When I run :scroll down with count 3
|
||||||
|
And I run :scroll up
|
||||||
|
And I run :repeat-command with count 2
|
||||||
|
Then the page should not be scrolled
|
||||||
|
|
||||||
|
Scenario: :repeat-command with not-normal command inbetween
|
||||||
|
Given I open data/scroll.html
|
||||||
|
When I run :scroll down with count 3
|
||||||
|
And I run :scroll up
|
||||||
|
And I run :prompt-accept
|
||||||
|
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
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
Feature: Repeating
|
|
||||||
Test the repeat-command command.
|
|
||||||
|
|
||||||
Background:
|
|
||||||
Given I run :tab-only
|
|
||||||
|
|
||||||
Scenario: :repeat-command
|
|
||||||
When I open data/numbers/1.txt
|
|
||||||
And I open data/numbers/2.txt in a new tab
|
|
||||||
And I open data/numbers/3.txt in a new tab
|
|
||||||
And I run :tab-close with count 1
|
|
||||||
And I run :repeat-command
|
|
||||||
Then the following tabs should be open:
|
|
||||||
- data/numbers/3.txt (active)
|
|
||||||
|
|
||||||
Scenario: :repeat-command with count
|
|
||||||
When I open data/numbers/1.txt
|
|
||||||
And I open data/numbers/2.txt in a new tab
|
|
||||||
And I open data/numbers/3.txt in a new tab
|
|
||||||
And I run :tab-close with count 1
|
|
||||||
And I run :repeat-command with count 2
|
|
||||||
Then the following tabs should be open:
|
|
||||||
- data/numbers/2.txt (active)
|
|
||||||
|
|
||||||
Scenario: :repeat-command with not-normal command inbetween
|
|
||||||
When I open data/numbers/1.txt
|
|
||||||
And I open data/numbers/2.txt in a new tab
|
|
||||||
And I open data/numbers/3.txt in a new tab
|
|
||||||
And I run :tab-close with count 1
|
|
||||||
And I run :prompt-accept
|
|
||||||
And I run :repeat-command
|
|
||||||
Then the following tabs should be open:
|
|
||||||
- data/numbers/3.txt (active)
|
|
||||||
And the error "prompt-accept: This command is only allowed in prompt/yesno mode." should be shown
|
|
@ -29,6 +29,7 @@ import qutebrowser
|
|||||||
from qutebrowser.utils import docutils
|
from qutebrowser.utils import docutils
|
||||||
from qutebrowser.browser import pdfjs
|
from qutebrowser.browser import pdfjs
|
||||||
|
|
||||||
|
from end2end.features.test_scroll_bdd import check_scrolled, check_not_scrolled
|
||||||
|
|
||||||
bdd.scenarios('misc.feature')
|
bdd.scenarios('misc.feature')
|
||||||
|
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
|
||||||
|
|
||||||
# Copyright 2016 Jan Verbeek (blyxxyz) <ring@openmailbox.org>
|
|
||||||
#
|
|
||||||
# This file is part of qutebrowser.
|
|
||||||
#
|
|
||||||
# qutebrowser is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# qutebrowser is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import pytest_bdd as bdd
|
|
||||||
bdd.scenarios('repeatcommand.feature')
|
|
Loading…
Reference in New Issue
Block a user