diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index 4ce944652..0e519e2a8 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -128,7 +128,7 @@ possible to run or bind multiple commands by separating them with `;;`. |<>|Switch to the previous tab, or switch [count] tabs back. |<>|Take a tab from another window. |<>|Unbind a keychain. -|<>|Re-open the last closed tab or tabs. +|<>|Re-open the last closed tab(s) or window. |<>|Show version information. |<>|Show the source of the current page in a new tab. |<>|Close all windows except for the current one. @@ -1467,7 +1467,12 @@ Unbind a keychain. [[undo]] === undo -Re-open the last closed tab or tabs. +Syntax: +:undo [*--window*]+ + +Re-open the last closed tab(s) or window. + +==== optional arguments +* +*-w*+, +*--window*+: Re-open the last closed window (and its tabs). [[version]] === version diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index e4eb8bc54..0ec9f1e1a 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -606,6 +606,7 @@ Default: * +pass:[Sq]+: +pass:[open qute://bookmarks]+ * +pass:[Ss]+: +pass:[open qute://settings]+ * +pass:[T]+: +pass:[tab-focus]+ +* +pass:[U]+: +pass:[undo -w]+ * +pass:[V]+: +pass:[enter-mode caret ;; toggle-selection --line]+ * +pass:[ZQ]+: +pass:[quit]+ * +pass:[ZZ]+: +pass:[quit --save]+ diff --git a/qutebrowser/app.py b/qutebrowser/app.py index a1e633ff5..d9fcbfa0d 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -533,8 +533,11 @@ class Application(QApplication): tab_stack=window.tabbed_browser._undo_stack, )) - @cmdutils.register(instance='app') def undo_last_window_close(self): + """Restore the last window to be closed. + + It will have the same tab and undo stack as when it was closed. + """ event = self._undos.pop() window = mainwindow.MainWindow( private=event.private, diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index e2cef8003..1b39ea062 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -780,10 +780,18 @@ class CommandDispatcher: text="Are you sure you want to close pinned tabs?") @cmdutils.register(instance='command-dispatcher', scope='window') - def undo(self): - """Re-open the last closed tab or tabs.""" + def undo(self, window: bool = False): + """Re-open the last closed tab(s) or window. + + Args: + window: Re-open the last closed window (and its tabs). + """ try: - self._tabbed_browser.undo() + if window: + app = QApplication.instance() + app.undo_last_window_close() + else: + self._tabbed_browser.undo() except IndexError: raise cmdutils.CommandError("Nothing to undo!") diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 8b3d2a373..e5e762ca5 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -3099,6 +3099,7 @@ bindings.default: k: scroll up l: scroll right u: undo + U: undo -w : undo gg: scroll-to-perc 0 G: scroll-to-perc