Merge branch 'airodactyl-fix/undo-tab-detach'

This commit is contained in:
Florian Bruhin 2016-08-11 13:14:46 +02:00
commit 93db3886e8
4 changed files with 11 additions and 7 deletions

View File

@ -89,6 +89,7 @@ Fixed
- `:bind` can now be used to bind to an alias (binding by editing `keys.conf` - `:bind` can now be used to bind to an alias (binding by editing `keys.conf`
already worked before) already worked before)
- The command completion now updates correctly when changing aliases - The command completion now updates correctly when changing aliases
- `:undo` now doesn't undo tabs "closed" by `:tab-detach` anymore.
v0.8.3 (unreleased) v0.8.3 (unreleased)
------------------- -------------------

View File

@ -192,6 +192,7 @@ Contributors, sorted by the number of commits in descending order:
* Nick Ginther * Nick Ginther
* Michał Góral * Michał Góral
* Michael Ilsaas * Michael Ilsaas
* Michael Hoang
* Martin Zimmermann * Martin Zimmermann
* Fritz Reichwald * Fritz Reichwald
* Brian Jackson * Brian Jackson
@ -213,7 +214,6 @@ Contributors, sorted by the number of commits in descending order:
* adam * adam
* Samir Benmendil * Samir Benmendil
* Regina Hug * Regina Hug
* Michael Hoang
* Mathias Fussenegger * Mathias Fussenegger
* Marcelo Santos * Marcelo Santos
* Jean-Louis Fuchs * Jean-Louis Fuchs

View File

@ -427,7 +427,7 @@ class CommandDispatcher:
url = self._current_url() url = self._current_url()
self._open(url, window=True) self._open(url, window=True)
cur_widget = self._current_widget() cur_widget = self._current_widget()
self._tabbed_browser.close_tab(cur_widget) self._tabbed_browser.close_tab(cur_widget, add_undo=False)
def _back_forward(self, tab, bg, window, count, forward): def _back_forward(self, tab, bg, window, count, forward):
"""Helper function for :back/:forward.""" """Helper function for :back/:forward."""

View File

@ -217,11 +217,12 @@ class TabbedBrowser(tabwidget.TabWidget):
for tab in self.widgets(): for tab in self.widgets():
self._remove_tab(tab) self._remove_tab(tab)
def close_tab(self, tab): def close_tab(self, tab, *, add_undo=True):
"""Close a tab. """Close a tab.
Args: Args:
tab: The QWebView to be closed. tab: The QWebView to be closed.
add_undo: Whether the tab close can be undone.
""" """
last_close = config.get('tabs', 'last-close') last_close = config.get('tabs', 'last-close')
count = self.count() count = self.count()
@ -229,7 +230,7 @@ class TabbedBrowser(tabwidget.TabWidget):
if last_close == 'ignore' and count == 1: if last_close == 'ignore' and count == 1:
return return
self._remove_tab(tab) self._remove_tab(tab, add_undo=add_undo)
if count == 1: # We just closed the last tab above. if count == 1: # We just closed the last tab above.
if last_close == 'close': if last_close == 'close':
@ -243,11 +244,12 @@ class TabbedBrowser(tabwidget.TabWidget):
url = config.get('general', 'default-page') url = config.get('general', 'default-page')
self.openurl(url, newtab=True) self.openurl(url, newtab=True)
def _remove_tab(self, tab): def _remove_tab(self, tab, *, add_undo=True):
"""Remove a tab from the tab list and delete it properly. """Remove a tab from the tab list and delete it properly.
Args: Args:
tab: The QWebView to be closed. tab: The QWebView to be closed.
add_undo: Whether the tab close can be undone.
""" """
idx = self.indexOf(tab) idx = self.indexOf(tab)
if idx == -1: if idx == -1:
@ -261,6 +263,7 @@ class TabbedBrowser(tabwidget.TabWidget):
window=self._win_id) window=self._win_id)
if tab.url().isValid(): if tab.url().isValid():
history_data = tab.history.serialize() history_data = tab.history.serialize()
if add_undo:
entry = UndoEntry(tab.url(), history_data, idx) entry = UndoEntry(tab.url(), history_data, idx)
self._undo_stack.append(entry) self._undo_stack.append(entry)
elif tab.url().isEmpty(): elif tab.url().isEmpty():