Closed Bug 273654 Opened 20 years ago Closed 20 years ago

A preference for Ctrl-W to always keep one tab open instead of closing the window.

Categories

(Firefox :: Tabbed Browser, enhancement)

enhancement
Not set
normal

Tracking

()

VERIFIED DUPLICATE of bug 236721

People

(Reporter: moz-spam-filtered.20.nickj, Assigned: bugs)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0

Pressing Ctrl-W closes the current active tab. If there is only one active tab,
then it closes the window. Closing the window is annoying if you have many tabs
open, and you want to close them all, but also want the browser to stay open, as
holding down ctrl-W closes everything. What is being requested is some way of
specifying that one blank tab should always stay open instead of closing the
window (e.g. via a preference, or a UI option, or a change to default behaviour
- any mechanism is fine).

A small patch that I use on my Firefox 1.0 installation to achieve this
behaviour is as follows:

From browser.jar, edit chrome\browser\content\browser\browser.js  ~line 1372:

==========================================================
function BrowserCloseTabOrWindow()
{
  if (gBrowser.localName == 'tabbrowser' &&
gBrowser.tabContainer.childNodes.length > 1) {
    // Just close up a tab.
    gBrowser.removeCurrentTab();
    return;
  }
+  if (gBrowser.localName == 'tabbrowser' &&
gBrowser.mTabContainer.childNodes.length == 1) {
+    // If this is the last tab, open "about:blank" tab, and don't close the window
+    loadURI('about:blank', null);  // still leaves back & forward buttons
active though
+    return;
+  }

  BrowserCloseWindow();
}
==========================================================


Note that this patch has 2 problems though, which make it unsuitable for
inclusion in its current form:
1) It doesn't check a pref (it's just a straight change to the default behaviour)
2) It leaves the back and forward buttons active (i.e. the user can press back,
and get the previous page). [An alternative is to go
"gBrowser.addTab('about:blank');" and then "gBrowser.removeCurrentTab();", which
opens a new tab and then closes the current one, but this causes an ugly brief
flashing effect.]

Related bugs: 206142 and 253949. Note that those 2 reports defined the
window-closing behaviour as buggy, whereas this report does not claim this
behaviour is buggy (as the software is doing what it's been designed to do) -
rather it requests some way of changing this behaviour to keep the window open
when the last tab is closed.

Reproducible: Always
Steps to Reproduce:
Will be handled under 236721.

*** This bug has been marked as a duplicate of 236721 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
Nick, since you've made the changes that are needed, you might as well make a
patch and attach it to bug 236721.
Status: RESOLVED → VERIFIED
I just used notepad for these changes (the work machine I'm using doesn't have
diff/patch/etc). I'll copy and paste the changes into bug 236721, so that
someone can attach a proper patch, but some way of clearing the back and forward
buttons out probably still needs to be found.

You need to log in before you can comment on or make changes to this bug.