diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 2e8f071a3..6e4b0429a 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -36,6 +36,13 @@ Changed the right. - `: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 ----- diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 36e8f5781..8641bfc7b 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -785,6 +785,10 @@ class CommandDispatcher: Args: 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 if newidx >= 0: self._set_current_index(newidx) @@ -801,6 +805,10 @@ class CommandDispatcher: Args: 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 if newidx < self._count(): self._set_current_index(newidx) diff --git a/tests/integration/features/tabs.feature b/tests/integration/features/tabs.feature index 968516905..cb7b54da8 100644 --- a/tests/integration/features/tabs.feature +++ b/tests/integration/features/tabs.feature @@ -851,3 +851,17 @@ Feature: Tab management When I open data/title.html And I run :buffer "1/2/3" 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