Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Option Do not close the last tab #4385

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion background_scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,16 @@ const BackgroundCommands = {
// In Firefox, Ctrl-W will not close a pinned tab, but on Chrome, it will. We try to be
// consistent with each browser's UX for pinned tabs.
if (tab.pinned && BgUtils.isFirefox()) return;
chrome.tabs.remove(tab.id);
if(Settings.get("keepLastTabOpen")){
chrome.tabs.query({ currentWindow: true }, function (tabs) {
if(tabs.length == 1){
chrome.tabs.create({ url: Settings.get("newTabUrl") });
}
chrome.tabs.remove(tab.id);
});
} else {
chrome.tabs.remove(tab.id);
}
});
},
restoreTab: mkRepeatCommand((request, callback) =>
Expand Down
1 change: 1 addition & 0 deletions lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ w: https://www.wikipedia.org/w/index.php?title=Special:Search&search=%s Wikipedi
waitForEnterForFilteredHints: true,
helpDialog_showAdvancedCommands: false,
ignoreKeyboardLayout: false,
keepLastTabOpen: false,
};

/*
Expand Down
14 changes: 14 additions & 0 deletions pages/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,20 @@
</label>
</td>
</tr>
<tr>
<td class="caption"></td>
<td verticalAlign="top" class="booleanOption">
<div class="help">
<div class="example">
Do not close the last tab
</div>
</div>
<label>
<input id="keepLastTabOpen" type="checkbox" />
Do not close the last tab
</label>
</td>
</tr>
<tr>
<td class="caption">Default search<br />engine</td>
<td verticalAlign="top">
Expand Down
1 change: 1 addition & 0 deletions pages/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const options = {
searchUrl: "string",
settingsVersion: "string", // This is a hidden field.
userDefinedLinkHintCss: "string",
keepLastTabOpen: "boolean",
};

const OptionsPage = {
Expand Down