Allow a trailing % for :zoom
This commit is contained in:
parent
92d5f6c41d
commit
5ec94f96fd
@ -868,7 +868,7 @@ class CommandDispatcher:
|
|||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||||
@cmdutils.argument('count', count=True)
|
@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.
|
"""Set the zoom level for the current tab.
|
||||||
|
|
||||||
The zoom can be given as argument or as [count]. If neither is
|
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.
|
zoom: The zoom percentage to set.
|
||||||
count: 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
|
level = count if count is not None else zoom
|
||||||
if level is None:
|
if level is None:
|
||||||
level = config.get('ui', 'default-zoom')
|
level = config.get('ui', 'default-zoom')
|
||||||
|
@ -51,6 +51,11 @@ Feature: Zooming in and out
|
|||||||
Then the message "Zoom level: 50%" should be shown
|
Then the message "Zoom level: 50%" should be shown
|
||||||
And the zoom should be 50%
|
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
|
Scenario: Setting zoom with count
|
||||||
When I run :zoom with count 40
|
When I run :zoom with count 40
|
||||||
Then the message "Zoom level: 40%" should be shown
|
Then the message "Zoom level: 40%" should be shown
|
||||||
|
Loading…
Reference in New Issue
Block a user