Abort :back/:forward at beginning/end of history.
This commit is contained in:
parent
eef760359c
commit
a4d15b550e
@ -413,20 +413,27 @@ class CommandDispatcher:
|
||||
|
||||
def _back_forward(self, tab, bg, window, count, forward):
|
||||
"""Helper function for :back/:forward."""
|
||||
if (not forward and not
|
||||
self._current_widget().page().history().canGoBack()):
|
||||
# Catch common cases before e.g. cloning tab
|
||||
history = self._current_widget().page().history()
|
||||
if not forward and not history.canGoBack():
|
||||
raise cmdexc.CommandError("At beginning of history.")
|
||||
if (forward and not
|
||||
self._current_widget().page().history().canGoForward()):
|
||||
elif forward and not history.canGoForward():
|
||||
raise cmdexc.CommandError("At end of history.")
|
||||
|
||||
if tab or bg or window:
|
||||
widget = self.tab_clone(bg, window)
|
||||
else:
|
||||
widget = self._current_widget()
|
||||
|
||||
history = widget.page().history()
|
||||
for _ in range(count):
|
||||
if forward:
|
||||
if not history.canGoForward():
|
||||
raise cmdexc.CommandError("At end of history.")
|
||||
widget.forward()
|
||||
else:
|
||||
if not history.canGoBack():
|
||||
raise cmdexc.CommandError("At beginning of history.")
|
||||
widget.back()
|
||||
|
||||
@cmdutils.register(instance='command-dispatcher', scope='window',
|
||||
|
@ -43,6 +43,19 @@ Feature: Going back and forward.
|
||||
url: http://localhost:*/data/backforward/1.txt
|
||||
- url: http://localhost:*/data/backforward/2.txt
|
||||
|
||||
Scenario: Going back in a new tab without history
|
||||
Given I open data/backforward/1.txt
|
||||
When I run :tab-only
|
||||
And I run :back -t
|
||||
Then the error "At beginning of history." should be shown.
|
||||
Then the session should look like:
|
||||
windows:
|
||||
- tabs:
|
||||
- active: true
|
||||
history:
|
||||
- active: true
|
||||
url: http://localhost:*/data/backforward/1.txt
|
||||
|
||||
Scenario: Going back in a new background tab
|
||||
Given I open data/backforward/1.txt
|
||||
When I open data/backforward/2.txt
|
||||
|
Loading…
Reference in New Issue
Block a user