Merge branch 'airodactyl-feature/undo-to-old-pos'

This commit is contained in:
Florian Bruhin 2016-08-10 17:50:34 +02:00
commit d4f30bd100
4 changed files with 57 additions and 6 deletions

View File

@ -61,6 +61,7 @@ Changed
- Word hints now are more clever about getting the element text from some elements.
- Completions for `:help` and `:bind` now also show hidden commands
- The `:buffer` completion now also filters using the first column (id).
- `:undo` has been improved to reopen tabs at the position they were closed.
Removed
~~~~~~~

View File

@ -213,6 +213,7 @@ Contributors, sorted by the number of commits in descending order:
* adam
* Samir Benmendil
* Regina Hug
* Michael Hoang
* Mathias Fussenegger
* Marcelo Santos
* Jean-Louis Fuchs

View File

@ -34,7 +34,7 @@ from qutebrowser.utils import (log, usertypes, utils, qtutils, objreg,
urlutils, message)
UndoEntry = collections.namedtuple('UndoEntry', ['url', 'history'])
UndoEntry = collections.namedtuple('UndoEntry', ['url', 'history', 'index'])
class TabDeletedError(Exception):
@ -261,7 +261,7 @@ class TabbedBrowser(tabwidget.TabWidget):
window=self._win_id)
if tab.url().isValid():
history_data = tab.history.serialize()
entry = UndoEntry(tab.url(), history_data)
entry = UndoEntry(tab.url(), history_data, idx)
self._undo_stack.append(entry)
elif tab.url().isEmpty():
# There are some good reasons why a URL could be empty
@ -298,13 +298,13 @@ class TabbedBrowser(tabwidget.TabWidget):
use_current_tab = (only_one_tab_open and no_history and
last_close_url_used)
url, history_data = self._undo_stack.pop()
url, history_data, idx = self._undo_stack.pop()
if use_current_tab:
self.openurl(url, newtab=False)
newtab = self.widget(0)
else:
newtab = self.tabopen(url, background=False)
newtab = self.tabopen(url, background=False, idx=idx)
newtab.history.deserialize(history_data)
@ -343,7 +343,7 @@ class TabbedBrowser(tabwidget.TabWidget):
@pyqtSlot('QUrl')
@pyqtSlot('QUrl', bool)
def tabopen(self, url=None, background=None, explicit=False):
def tabopen(self, url=None, background=None, explicit=False, idx=None):
"""Open a new tab with a given URL.
Inner logic for open-tab and open-tab-bg.
@ -359,6 +359,7 @@ class TabbedBrowser(tabwidget.TabWidget):
- Tabs from clicked links etc. are to the right of
the current.
- Explicitly opened tabs are at the very right.
idx: The index where the new tab should be opened.
Return:
The opened WebView instance.
@ -377,7 +378,8 @@ class TabbedBrowser(tabwidget.TabWidget):
tab = browsertab.create(win_id=self._win_id, parent=self)
self._connect_tab_signals(tab)
idx = self._get_new_tab_idx(explicit)
if idx is None:
idx = self._get_new_tab_idx(explicit)
self.insertTab(idx, tab, "")
if url is not None:

View File

@ -703,6 +703,53 @@ Feature: Tab management
Then the error "Nothing to undo!" should be shown
And the error "Nothing to undo!" should be shown
Scenario: Undo a tab closed by index
When I open data/numbers/1.txt
And I open data/numbers/2.txt in a new tab
And I open data/numbers/3.txt in a new tab
And I run :tab-close with count 1
And I run :undo
Then the following tabs should be open:
- data/numbers/1.txt (active)
- data/numbers/2.txt
- data/numbers/3.txt
Scenario: Undo a tab closed after switching tabs
When I open data/numbers/1.txt
And I open data/numbers/2.txt in a new tab
And I open data/numbers/3.txt in a new tab
And I run :tab-close with count 1
And I run :tab-focus 2
And I run :undo
Then the following tabs should be open:
- data/numbers/1.txt (active)
- data/numbers/2.txt
- data/numbers/3.txt
Scenario: Undo a tab closed after rearranging tabs
When I open data/numbers/1.txt
And I open data/numbers/2.txt in a new tab
And I open data/numbers/3.txt in a new tab
And I run :tab-close with count 1
And I run :tab-focus 2
And I run :tab-move with count 1
And I run :undo
Then the following tabs should be open:
- data/numbers/1.txt (active)
- data/numbers/3.txt
- data/numbers/2.txt
Scenario: Undo a tab closed after new tab opened
When I open data/numbers/1.txt
And I open data/numbers/2.txt in a new tab
And I run :tab-close with count 1
And I open data/numbers/3.txt in a new tab
And I run :undo
Then the following tabs should be open:
- data/numbers/1.txt (active)
- data/numbers/2.txt
- data/numbers/3.txt
# last-close
Scenario: last-close = blank