Skip to content

Commit 66e29f8

Browse files
committed
Merge pull request #414 from Quicksaver/no-tabview
Quick fixes for TabView removal from Firefox
2 parents 6de6aa3 + 49bbd48 commit 66e29f8

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

common/content/buffer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,7 @@ const Buffer = Module("buffer", {
14451445
context.completions = [item for (item in generateTabs(tabs || config.tabbrowser.visibleTabs))];
14461446
}
14471447

1448-
if (!liberator.has("tabgroup"))
1448+
if (!liberator.has("tabgroup") || !tabGroup.TV)
14491449
return;
14501450

14511451
let groups = tabGroup.tabView.GroupItems;

common/content/tabs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ const Tabs = Module("tabs", {
406406
let matches = buffer.match(/^(\d+):?/);
407407
if (matches)
408408
return [tabs.getTab(parseInt(matches[1], 10) - 1)];
409-
else if (liberator.has("tabgroup")) {
409+
else if (liberator.has("tabgroup") && tabGroup.TV) {
410410
matches = buffer.match(/^(.+?)\.(\d+):?/);
411411
if (matches) {
412412
let [, groupName, tabNum] = matches;

vimperator/content/tabgroup.js

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ var TabGroup = Module("tabGroup", {
4646
* @return {GroupItem}
4747
*/
4848
getGroup: function getGroup (name, count) {
49+
if (!this.TV)
50+
return null;
51+
4952
let i = 0;
5053
if (!count)
5154
count = 1;
@@ -83,6 +86,9 @@ var TabGroup = Module("tabGroup", {
8386
* @param {Boolean} wrap
8487
*/
8588
switchTo: function (spec, wrap) {
89+
if (!tabGroup.TV)
90+
return;
91+
8692
const GI = tabGroup.tabView.GroupItems;
8793
let current = GI.getActiveGroupItem() || GI.getActiveOrphanTab();
8894
let groups = GI.groupItems;
@@ -150,6 +156,9 @@ var TabGroup = Module("tabGroup", {
150156
* @return {GroupItem} created GroupItem instance
151157
*/
152158
createGroup: function createGroup (name, shouldSwitch, tab) {
159+
if (!tabGroup.TV)
160+
return null;
161+
153162
let pageBounds = tabGroup.tabView.Items.getPageBounds();
154163
pageBounds.inset(20, 20);
155164
let box = new tabGroup.tabView.Rect(pageBounds);
@@ -185,6 +194,9 @@ var TabGroup = Module("tabGroup", {
185194
* if {group} doesn't exist.
186195
*/
187196
moveTab: function moveTabToGroup (tab, group, shouldSwitch) {
197+
if (!tabGroup.TV)
198+
return;
199+
188200
liberator.assert(tab && !tab.pinned, "Cannot move an AppTab");
189201

190202
let groupItem = (group instanceof tabGroup.tabView.GroupItem) ? group : tabGroup.getGroup(group);
@@ -202,6 +214,9 @@ var TabGroup = Module("tabGroup", {
202214
* @param {string} groupName
203215
*/
204216
remove: function removeGroup (groupName) {
217+
if (!tabGroup.TV)
218+
return;
219+
205220
const GI = tabGroup.tabView.GroupItems;
206221
let activeGroup = GI.getActiveGroupItem();
207222
let group = groupName ? tabGroup.getGroup(groupName) : activeGroup;
@@ -252,12 +267,12 @@ var TabGroup = Module("tabGroup", {
252267

253268
mappings.add([modes.NORMAL], ["<C-S-n>", "<C-S-PageDown>"],
254269
"Switch to next tab group",
255-
function (count) { tabGroup.switchTo("+" + (count || 1), true); },
270+
function (count) { if (tabGroup.TV) tabGroup.switchTo("+" + (count || 1), true); },
256271
{ count: true });
257272

258273
mappings.add([modes.NORMAL], ["<C-S-p>", "<C-S-PageUp>"],
259274
"Switch to previous tab group",
260-
function (count) { tabGroup.switchTo("-" + (count || 1), true); },
275+
function (count) { if (tabGroup.TV) tabGroup.switchTo("-" + (count || 1), true); },
261276
{ count: true });
262277
},
263278

@@ -269,21 +284,24 @@ var TabGroup = Module("tabGroup", {
269284
* take up the current tab to the group if bang(!) specified.
270285
*/
271286
new Command(["add"], "Create a new tab group",
272-
function (args) { tabGroup.createGroup(args.literalArg, true, args.bang ? tabs.getTab() : null); },
287+
function (args) { if (tabGroup.TV) tabGroup.createGroup(args.literalArg, true, args.bang ? tabs.getTab() : null); },
273288
{ bang: true, literal: 0 }),
274289
/**
275290
* Panorama SubCommand list
276291
* list current tab groups
277292
*/
278293
new Command(["list", "ls"], "List current tab groups",
279-
function (args) { completion.listCompleter("tabgroup"); },
294+
function (args) { if (tabGroup.TV) completion.listCompleter("tabgroup"); },
280295
{ bang: false, argCount: 0 }),
281296
/**
282297
* Panorama SubCommad pullTab
283298
* pull the other group's tab
284299
*/
285300
new Command(["pull[tab]"], "Pull a tab from another group",
286301
function (args) {
302+
if (!tabGroup.TV)
303+
return;
304+
287305
let activeGroup = tabGroup.tabView.GroupItems.getActiveGroupItem();
288306
if (!activeGroup) {
289307
liberator.echoerr("Cannot pull tab to the current group");
@@ -314,6 +332,9 @@ var TabGroup = Module("tabGroup", {
314332
*/
315333
new Command(["push[tab]", "stash"], "Move the current tab to another group",
316334
function (args) {
335+
if (!tabGroup.TV)
336+
return;
337+
317338
let currentTab = tabs.getTab();
318339
if (currentTab.pinned) {
319340
liberator.echoerr("Cannot move an App Tab");
@@ -341,7 +362,7 @@ var TabGroup = Module("tabGroup", {
341362
* remove the current group if {group} is ommited.
342363
*/
343364
new Command(["remove", "rm"], "Close the tab group (including all tabs!)",
344-
function (args) { tabGroup.remove(args.literalArg); },
365+
function (args) { if (tabGroup.TV) tabGroup.remove(args.literalArg); },
345366
{
346367
literal: 0,
347368
completer: function (context) completion.tabgroup(context, false),
@@ -353,6 +374,9 @@ var TabGroup = Module("tabGroup", {
353374
*/
354375
new Command(["rename", "mv"], "Rename current tab group (or reset to '(Untitled)').",
355376
function (args) {
377+
if (!tabGroup.TV)
378+
return;
379+
356380
let title = args.literalArg;
357381
if (!title) {
358382
if (args.bang)
@@ -370,7 +394,7 @@ var TabGroup = Module("tabGroup", {
370394
literal: 0,
371395
completer: function (context) {
372396
context.title = ["Rename current group"];
373-
let activeGroup = tabGroup.tabView.GroupItems.getActiveGroupItem();
397+
let activeGroup = tabGroup.TV && tabGroup.tabView.GroupItems.getActiveGroupItem();
374398
let title = activeGroup ? activeGroup.getTitle() : "";
375399
context.completions = title ? [[title, ""]] : [];
376400
}
@@ -382,6 +406,9 @@ var TabGroup = Module("tabGroup", {
382406
*/
383407
new Command(["switch"], "Switch to another group",
384408
function (args) {
409+
if (!tabGroup.TV)
410+
return;
411+
385412
if (args.count > 0)
386413
tabGroup.switchTo("+" + args.count, true);
387414
else
@@ -404,15 +431,20 @@ var TabGroup = Module("tabGroup", {
404431

405432
completion: function () {
406433
completion.tabgroup = function TabGroupCompleter (context, excludeActiveGroup) {
434+
context.title = ["Tab Group"];
435+
context.anchored = false;
436+
if (!tabGroup.TV) {
437+
context.completions = [];
438+
return;
439+
}
440+
407441
const GI = tabGroup.tabView.GroupItems;
408442
let groupItems = GI.groupItems;
409443
if (excludeActiveGroup) {
410444
let activeGroup = GI.getActiveGroupItem();
411445
if (activeGroup)
412446
groupItems = groupItems.filter(function(group) group.id != activeGroup.id);
413447
}
414-
context.title = ["Tab Group"];
415-
context.anchored = false;
416448
context.completions = groupItems.map(function(group) {
417449
let title = group.id + ": " + (group.getTitle() || "(Untitled)");
418450
let desc = "Tabs: " + group.getChildren().length;

0 commit comments

Comments
 (0)