summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoofar <toofar@spalge.com>2023-12-26 19:37:22 +1300
committertoofar <toofar@spalge.com>2024-01-06 21:02:24 +1300
commit96a37b0a61174c09f1c4e7bbccb8da151481316b (patch)
treeac7a18ae57e185c271fab101f65a21914a51d5cd
parent69582406a6bdf7dfa946d46a405adf425f9236c6 (diff)
downloadqutebrowser-96a37b0a61174c09f1c4e7bbccb8da151481316b.tar.gz
qutebrowser-96a37b0a61174c09f1c4e7bbccb8da151481316b.zip
Use `TreeUndoEntry.from_node()` for un-collapsed nodes too.
Little bit of tidy up. This was already being used in the conditional branch for collapsed nodes, I have no idea why it wasn't being used for the un-collapsed case.
-rw-r--r--qutebrowser/mainwindow/treetabbedbrowser.py58
1 files changed, 21 insertions, 37 deletions
diff --git a/qutebrowser/mainwindow/treetabbedbrowser.py b/qutebrowser/mainwindow/treetabbedbrowser.py
index f93e7c98d..b749b6969 100644
--- a/qutebrowser/mainwindow/treetabbedbrowser.py
+++ b/qutebrowser/mainwindow/treetabbedbrowser.py
@@ -134,45 +134,29 @@ class TreeTabbedBrowser(TabbedBrowser):
"""
# TODO see if it's possible to remove duplicate code from
# super()._add_undo_entry
- try:
- history_data = tab.history.private_api.serialize()
- except browsertab.WebTabError:
- pass # special URL
+ node = tab.node
+ if not node.collapsed:
+ entry = _TreeUndoEntry.from_node(node, 0)
+ if new_undo or not self.undo_stack:
+ self.undo_stack.append([entry])
+ else:
+ self.undo_stack[-1].append(entry)
else:
- node = tab.node
- uid = node.uid
- parent_uid = node.parent.uid
- if not node.collapsed:
- children = [n.uid for n in node.children]
- local_idx = node.index
- entry = _TreeUndoEntry(url=tab.url(),
- history=history_data,
- index=idx,
- pinned=tab.data.pinned,
- uid=uid,
- parent_node_uid=parent_uid,
- children_node_uids=children,
- local_index=local_idx)
- if new_undo or not self.undo_stack:
- self.undo_stack.append([entry])
- else:
- self.undo_stack[-1].append(entry)
+ entries = []
+ for descendent in node.traverse(notree.TraverseOrder.POST_R):
+ entry = _TreeUndoEntry.from_node(descendent, 0)
+ # Recursively removed nodes will never have any children
+ # in the tree they are being added into. Children will
+ # always be added later as the undo stack is worked
+ # through.
+ # UndoEntry.from_node() is not clever enough enough to
+ # handle this case on its own currently.
+ entry.children_node_uids = []
+ entries.append(entry)
+ if new_undo:
+ self.undo_stack.append(entries)
else:
- entries = []
- for descendent in node.traverse(notree.TraverseOrder.POST_R):
- entry = _TreeUndoEntry.from_node(descendent, 0)
- # Recursively removed nodes will never have any children
- # in the tree they are being added into. Children will
- # always be added later as the undo stack is worked
- # through.
- # UndoEntry.from_node() is not clever enough enough to
- # handle this case on its own currently.
- entry.children_node_uids = []
- entries.append(entry)
- if new_undo:
- self.undo_stack.append(entries)
- else:
- self.undo_stack[-1] += entries
+ self.undo_stack[-1] += entries
def undo(self, depth=1):
"""Undo removing of a tab or tabs."""