diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 881853b91..1761b6758 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -68,6 +68,7 @@ Changed finished. When set to `-1`, downloads are never removed. - The `:follow-hint` command now optionally takes the keystring of a hint to follow. +- `:scroll-px` now doesn't take floats anymore, which made little sense. Deprecated ~~~~~~~~~~ diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 6c8b12344..b8581bc7b 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -521,7 +521,7 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', hide=True, scope='window', count='count') - def scroll_px(self, dx: {'type': float}, dy: {'type': float}, count=1): + def scroll_px(self, dx: {'type': int}, dy: {'type': int}, count=1): """Scroll the current tab by 'count * dx/dy' pixels. Args: @@ -538,8 +538,8 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', hide=True, scope='window', count='count') def scroll(self, - direction: {'type': (str, float)}, - dy: {'type': float, 'hide': True}=None, + direction: {'type': (str, int)}, + dy: {'type': int, 'hide': True}=None, count=1): """Scroll the current tab in the given direction. @@ -552,8 +552,8 @@ class CommandDispatcher: # pylint: disable=too-many-locals try: # Check for deprecated dx/dy form (like with scroll-px). - dx = float(direction) - dy = float(dy) + dx = int(direction) + dy = int(dy) except (ValueError, TypeError): # Invalid values will get handled later. pass diff --git a/tests/integration/features/scroll.feature b/tests/integration/features/scroll.feature index 4cb23ad81..524f4fdcf 100644 --- a/tests/integration/features/scroll.feature +++ b/tests/integration/features/scroll.feature @@ -46,6 +46,12 @@ Feature: Scrolling And I run :scroll-px 10 10 Then no crash should happen + Scenario: :scroll-px with floats + # This used to be allowed, but doesn't make much sense. + When I run :scroll-px 2.5 2.5 + Then the error "scroll-px: Argument dx: invalid int value: '2.5'" should be shown. + And the page should not be scrolled. + ## :scroll Scenario: Scrolling down @@ -94,6 +100,11 @@ Feature: Scrolling Then the warning ":scroll with dx/dy arguments is deprecated - use :scroll-px instead!" should be shown. Then the page should be scrolled vertically. + Scenario: :scroll with deprecated pixel argument (float) + When I run :scroll 2.5 2.5 + Then the error "scroll: Argument dy: invalid int value: '2.5'" should be shown. + And the page should not be scrolled. + Scenario: Scrolling down and up with count When I run :scroll down with count 2 And I run :scroll up