Fix crash with :tab-{prev,next,focus} with 0 tabs
When using :tab-prev/:tab-next (or :tab-focus which uses :tab-next internally) immediately after the last tab, those functions could be called with 0 tabs open, which caused a ZeroDivisionError when trying to do % 0. Fixes #1448.
This commit is contained in:
parent
a5679dff04
commit
6349c00c72
@ -36,6 +36,13 @@ Changed
|
|||||||
the right.
|
the right.
|
||||||
- `:yank` can now yank the pretty/decoded URL by adding `--pretty`
|
- `:yank` can now yank the pretty/decoded URL by adding `--pretty`
|
||||||
|
|
||||||
|
Fixed
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
- Fixed crash when using `:tab-{prev,next,focus}` right after closing the last
|
||||||
|
tab with `last-close` set to `close`.
|
||||||
|
|
||||||
|
|
||||||
v0.6.1
|
v0.6.1
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -785,6 +785,10 @@ class CommandDispatcher:
|
|||||||
Args:
|
Args:
|
||||||
count: How many tabs to switch back.
|
count: How many tabs to switch back.
|
||||||
"""
|
"""
|
||||||
|
if self._count() == 0:
|
||||||
|
# Running :tab-prev after last tab was closed
|
||||||
|
# See https://github.com/The-Compiler/qutebrowser/issues/1448
|
||||||
|
return
|
||||||
newidx = self._current_index() - count
|
newidx = self._current_index() - count
|
||||||
if newidx >= 0:
|
if newidx >= 0:
|
||||||
self._set_current_index(newidx)
|
self._set_current_index(newidx)
|
||||||
@ -801,6 +805,10 @@ class CommandDispatcher:
|
|||||||
Args:
|
Args:
|
||||||
count: How many tabs to switch forward.
|
count: How many tabs to switch forward.
|
||||||
"""
|
"""
|
||||||
|
if self._count() == 0:
|
||||||
|
# Running :tab-next after last tab was closed
|
||||||
|
# See https://github.com/The-Compiler/qutebrowser/issues/1448
|
||||||
|
return
|
||||||
newidx = self._current_index() + count
|
newidx = self._current_index() + count
|
||||||
if newidx < self._count():
|
if newidx < self._count():
|
||||||
self._set_current_index(newidx)
|
self._set_current_index(newidx)
|
||||||
|
@ -851,3 +851,17 @@ Feature: Tab management
|
|||||||
When I open data/title.html
|
When I open data/title.html
|
||||||
And I run :buffer "1/2/3"
|
And I run :buffer "1/2/3"
|
||||||
Then the error "No matching tab for: 1/2/3" should be shown
|
Then the error "No matching tab for: 1/2/3" should be shown
|
||||||
|
|
||||||
|
Scenario: Using :tab-next after closing last tab (#1448)
|
||||||
|
When I set tabs -> last-close to close
|
||||||
|
And I run :tab-only
|
||||||
|
And I run :tab-close ;; :tab-next
|
||||||
|
Then qutebrowser should quit
|
||||||
|
And no crash should happen
|
||||||
|
|
||||||
|
Scenario: Using :tab-prev after closing last tab (#1448)
|
||||||
|
When I set tabs -> last-close to close
|
||||||
|
And I run :tab-only
|
||||||
|
And I run :tab-close ;; :tab-prev
|
||||||
|
Then qutebrowser should quit
|
||||||
|
And no crash should happen
|
||||||
|
Loading…
Reference in New Issue
Block a user