diff --git a/NEWS b/NEWS index be012fd9..14f40802 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@
 2007-XX-XX:
 	* version 0.5.3
+	* :q doesn't close the whole browser, if there are more than one windows
 	* new :winclose command
 	* b calls :buffer! now instead of :buffer
 	* [+], [-] and [+-] in the statusline, whether we can go back, forward, or both
diff --git a/content/commands.js b/content/commands.js
index 260aed67..6aa954b8 100644
--- a/content/commands.js
+++ b/content/commands.js
@@ -1121,8 +1121,9 @@ function Commands() //{{{
     addDefaultCommand(new Command(["q[uit]"],
         function() { vimperator.tabs.remove(getBrowser().mCurrentTab, 1, false, 1); },
         {
-            short_help: "Quit current tab or quit Vimperator if this was the last tab",
-            help: "When quitting Vimperator, the session is not stored."
+            short_help: "Quit current tab",
+            help: "If this is the last tab in the window, close the window. If this was the " +
+                  "last window, close Vimperator. When quitting Vimperator, the session is not stored."
         }
     ));
     addDefaultCommand(new Command(["quita[ll]", "qa[ll]"],
diff --git a/content/tabs.js b/content/tabs.js
index e0e25d7c..95c84841 100644
--- a/content/tabs.js
+++ b/content/tabs.js
@@ -172,8 +172,14 @@ function Tabs() //{{{
             count = 1;
 
         if (quit_on_last_tab >= 1 && getBrowser().mTabs.length <= count)
-            vimperator.quit(quit_on_last_tab == 2);
+        {
+            if (vimperator.windows.length > 1)
+                window.close();
+            else
+                vimperator.quit(quit_on_last_tab == 2);
 
+            return;
+        }
 
         var index = this.index(tab);
         if (focus_left_tab)
diff --git a/content/vimperator.js b/content/vimperator.js
index e7e98a12..a334bd63 100644
--- a/content/vimperator.js
+++ b/content/vimperator.js
@@ -896,8 +896,17 @@ const vimperator = (function() //{{{
             for (; now - then < ms; now = new Date().getTime()) { 
                 mainThread.processNextEvent(true); 
             } 
-        } 
+        },
 
+        get windows() 
+        {
+            var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
+            var wa = [];
+            var enumerator = wm.getEnumerator("navigator:browser");
+            while (enumerator.hasMoreElements())
+                wa.push(enumerator.getNext());
+            return wa;
+        }
     } //}}}
 })(); //}}}