diff --git a/qutebrowser/completion/models/miscmodels.py b/qutebrowser/completion/models/miscmodels.py index 0803f3508..36e334955 100644 --- a/qutebrowser/completion/models/miscmodels.py +++ b/qutebrowser/completion/models/miscmodels.py @@ -280,12 +280,14 @@ def undo(*, info): """A model to complete undo entries.""" tabbed_browser = objreg.get('tabbed-browser', scope='window', window=info.win_id) - model = completionmodel.CompletionModel(column_widths=(6, 94, 0)) + model = completionmodel.CompletionModel(column_widths=(6, 84, 10)) + timestamp_format = config.val.completion.timestamp_format entries = [ ( str(idx), - ', '.join(entry.url.toDisplayString() for entry in group) + ', '.join(entry.url.toDisplayString() for entry in group), + group[-1].created_at.strftime(timestamp_format) ) for idx, group in enumerate(reversed(tabbed_browser.undo_stack), start=1) diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index b60de50dc..0f9cafac0 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -23,6 +23,7 @@ import collections import functools import weakref import typing +import datetime import attr from PyQt5.QtWidgets import QSizePolicy, QWidget, QApplication @@ -47,6 +48,7 @@ class _UndoEntry: history = attr.ib() index = attr.ib() pinned = attr.ib() + created_at = attr.ib(attr.Factory(datetime.datetime.now)) class TabDeque: diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py index f105d2b8a..e602f0ab6 100644 --- a/tests/unit/completion/test_models.py +++ b/tests/unit/completion/test_models.py @@ -1269,11 +1269,14 @@ def test_forward_completion(tab_with_history, info): def test_undo_completion(tabbed_browser_stubs, info): """Test :undo completion.""" entry1 = tabbedbrowser._UndoEntry(url=QUrl('https://example.org/'), - history=None, index=None, pinned=None) + history=None, index=None, pinned=None, + created_at=datetime(2020, 1, 1)) entry2 = tabbedbrowser._UndoEntry(url=QUrl('https://example.com/'), - history=None, index=None, pinned=None) + history=None, index=None, pinned=None, + created_at=datetime(2020, 1, 2)) entry3 = tabbedbrowser._UndoEntry(url=QUrl('https://example.net/'), - history=None, index=None, pinned=None) + history=None, index=None, pinned=None, + created_at=datetime(2020, 1, 2)) # Most recently closed is at the end tabbed_browser_stubs[0].undo_stack = [ @@ -1288,7 +1291,11 @@ def test_undo_completion(tabbed_browser_stubs, info): # undo stack. _check_completions(model, { "Closed tabs": [ - ("1", "https://example.com/, https://example.net/", None), - ("2", "https://example.org/", None), + ("1", + "https://example.com/, https://example.net/", + "2020-01-02 00:00"), + ("2", + "https://example.org/", + "2020-01-01 00:00"), ], })