diff --git a/NEWS b/NEWS index c33ffb29..bdfe8ee0 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ 2007-xx-xx: * version 0.6 * THIS VERSION ONLY WORKS WITH FIREFOX 3.0 + * :undoall support, and tabcompletion for :undo * new :redraw and Ctrl-L commands for forced redrawing of the screen * added new 'laststatus' option and removed "s" value from 'guioptions' * Tab-completion improvements for :javascript and :open diff --git a/content/commands.js b/content/commands.js index 3a35e5f8..163e9ae7 100644 --- a/content/commands.js +++ b/content/commands.js @@ -1506,13 +1506,62 @@ function Commands() //{{{ } )); addDefaultCommand(new Command(["u[ndo]"], - function(args, special, count) { if (count < 1) count = 1; undoCloseTab(count-1); }, + function(args, special, count) { - usage: ["[count]u[ndo]"], + if (count < 1) + count = 1; + + if (args) + { + var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); + var undoItems = eval("(" + ss.getClosedTabData(window) + ")"); + for (var i = 0; i < undoItems.length; i++) + { + if (undoItems[i].state.entries[0].url == args) + { + count = i+1; + break; + } + } + } + undoCloseTab(count-1); + }, + { + usage: ["[count]u[ndo][!] [url]"], short_help: "Undo closing of a tab", - help: "If a count is given, don't close the last but the [count]th last tab." + help: "If a count is given, don't close the last but the [count]th last tab. " + + "With [url] restores the tab matching the url.", + completer: function(filter) + { + // get closed-tabs from nsSessionStore + var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); + var undoItems = eval("(" + ss.getClosedTabData(window) + ")"); + var completions = []; + for (var i = 0; i < undoItems.length; i++) + { + // undoItems[i].image is also available if need for favicons + completions.push([undoItems[i].state.entries[0].url, undoItems[i].title]); + } + return completions; + } } )); + addDefaultCommand(new Command(["undoa[ll]"], + function(args, special, count) + { + if (count || special) + return vimperator.echoerr("E488: Trailing characters"); + + var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); + var undoItems = eval("(" + ss.getClosedTabData(window) + ")"); + for (var i = 0; i < undoItems.length; i++) + undoCloseTab(); // doesn't work with i as the index to undoCloseTab + }, + { + short_help: "Undo closing of all closed tabs", + help: "Firefox stores up to 10 closed tabs, even after a browser restart." + } + )), addDefaultCommand(new Command(["unl[et]"], function(args, special) {