From d7cc0b041e26b1c59cc2f37826575e1a51dea98b Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Mon, 20 Oct 2008 08:44:40 +0000 Subject: [PATCH] fix :undo - it shouldn't open the last tab when given a non-matching arg --- content/tabs.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/content/tabs.js b/content/tabs.js index fd3e8e1a..f99417df 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -584,18 +584,28 @@ function Tabs() //{{{ if (args) { - var ss = Components.classes["@mozilla.org/browser/sessionstore;1"] + let ss = Components.classes["@mozilla.org/browser/sessionstore;1"] .getService(Components.interfaces.nsISessionStore); - var undoItems = eval("(" + ss.getClosedTabData(window) + ")"); + let undoItems = eval("(" + ss.getClosedTabData(window) + ")"); + let found = false; + for (let i = 0; i < undoItems.length; i++) { if (undoItems[i].state.entries[0].url == args) { count = i + 1; + found = true; break; } } + + if (!found) + { + liberator.echoerr("Exxx: No matching closed tab"); + return; + } } + undoCloseTab(count - 1); }, {