summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2017-06-26 21:51:35 +0200
committerFlorian Bruhin <git@the-compiler.org>2017-06-26 21:51:35 +0200
commit5ec94f96fd4d5e4c5dbde9c31b12155a11e79d17 (patch)
treeafe10dfff66302491531468929f99b9e50ea98fa
parent92d5f6c41dbbbf43e0b2acee0be5b2200e7003d3 (diff)
downloadqutebrowser-5ec94f96fd4d5e4c5dbde9c31b12155a11e79d17.tar.gz
qutebrowser-5ec94f96fd4d5e4c5dbde9c31b12155a11e79d17.zip
Allow a trailing % for :zoom
-rw-r--r--qutebrowser/browser/commands.py9
-rw-r--r--tests/end2end/features/zoom.feature5
2 files changed, 13 insertions, 1 deletions
diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py
index 8fead7269..e0b89c693 100644
--- a/qutebrowser/browser/commands.py
+++ b/qutebrowser/browser/commands.py
@@ -868,7 +868,7 @@ class CommandDispatcher:
@cmdutils.register(instance='command-dispatcher', scope='window')
@cmdutils.argument('count', count=True)
- def zoom(self, zoom: int = None, count=None):
+ def zoom(self, zoom=None, count=None):
"""Set the zoom level for the current tab.
The zoom can be given as argument or as [count]. If neither is
@@ -879,6 +879,13 @@ class CommandDispatcher:
zoom: The zoom percentage to set.
count: The zoom percentage to set.
"""
+ if zoom is not None:
+ try:
+ zoom = int(zoom.rstrip('%'))
+ except ValueError:
+ raise cmdexc.CommandError("zoom: Invalid int value {}"
+ .format(zoom))
+
level = count if count is not None else zoom
if level is None:
level = config.get('ui', 'default-zoom')
diff --git a/tests/end2end/features/zoom.feature b/tests/end2end/features/zoom.feature
index 015b85b17..bc36afe0d 100644
--- a/tests/end2end/features/zoom.feature
+++ b/tests/end2end/features/zoom.feature
@@ -51,6 +51,11 @@ Feature: Zooming in and out
Then the message "Zoom level: 50%" should be shown
And the zoom should be 50%
+ Scenario: Setting zoom with trailing %
+ When I run :zoom 50%
+ Then the message "Zoom level: 50%" should be shown
+ And the zoom should be 50%
+
Scenario: Setting zoom with count
When I run :zoom with count 40
Then the message "Zoom level: 40%" should be shown