Skip to content

Commit 130dd53

Browse files
committed
no-op all groups command if TabView doesn't exist
1 parent 9d706a2 commit 130dd53

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

vimperator/content/tabgroup.js

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,12 @@ var TabGroup = Module("tabGroup", {
252252

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

258258
mappings.add([modes.NORMAL], ["<C-S-p>", "<C-S-PageUp>"],
259259
"Switch to previous tab group",
260-
function (count) { tabGroup.switchTo("-" + (count || 1), true); },
260+
function (count) { if (tabGroup.TV) tabGroup.switchTo("-" + (count || 1), true); },
261261
{ count: true });
262262
},
263263

@@ -269,21 +269,24 @@ var TabGroup = Module("tabGroup", {
269269
* take up the current tab to the group if bang(!) specified.
270270
*/
271271
new Command(["add"], "Create a new tab group",
272-
function (args) { tabGroup.createGroup(args.literalArg, true, args.bang ? tabs.getTab() : null); },
272+
function (args) { if (tabGroup.TV) tabGroup.createGroup(args.literalArg, true, args.bang ? tabs.getTab() : null); },
273273
{ bang: true, literal: 0 }),
274274
/**
275275
* Panorama SubCommand list
276276
* list current tab groups
277277
*/
278278
new Command(["list", "ls"], "List current tab groups",
279-
function (args) { completion.listCompleter("tabgroup"); },
279+
function (args) { if (tabGroup.TV) completion.listCompleter("tabgroup"); },
280280
{ bang: false, argCount: 0 }),
281281
/**
282282
* Panorama SubCommad pullTab
283283
* pull the other group's tab
284284
*/
285285
new Command(["pull[tab]"], "Pull a tab from another group",
286286
function (args) {
287+
if (!tabGroup.TV)
288+
return;
289+
287290
let activeGroup = tabGroup.tabView.GroupItems.getActiveGroupItem();
288291
if (!activeGroup) {
289292
liberator.echoerr("Cannot pull tab to the current group");
@@ -314,6 +317,9 @@ var TabGroup = Module("tabGroup", {
314317
*/
315318
new Command(["push[tab]", "stash"], "Move the current tab to another group",
316319
function (args) {
320+
if (!tabGroup.TV)
321+
return;
322+
317323
let currentTab = tabs.getTab();
318324
if (currentTab.pinned) {
319325
liberator.echoerr("Cannot move an App Tab");
@@ -341,7 +347,7 @@ var TabGroup = Module("tabGroup", {
341347
* remove the current group if {group} is ommited.
342348
*/
343349
new Command(["remove", "rm"], "Close the tab group (including all tabs!)",
344-
function (args) { tabGroup.remove(args.literalArg); },
350+
function (args) { if (tabGroup.TV) tabGroup.remove(args.literalArg); },
345351
{
346352
literal: 0,
347353
completer: function (context) completion.tabgroup(context, false),
@@ -353,6 +359,9 @@ var TabGroup = Module("tabGroup", {
353359
*/
354360
new Command(["rename", "mv"], "Rename current tab group (or reset to '(Untitled)').",
355361
function (args) {
362+
if (!tabGroup.TV)
363+
return;
364+
356365
let title = args.literalArg;
357366
if (!title) {
358367
if (args.bang)
@@ -370,7 +379,7 @@ var TabGroup = Module("tabGroup", {
370379
literal: 0,
371380
completer: function (context) {
372381
context.title = ["Rename current group"];
373-
let activeGroup = tabGroup.tabView.GroupItems.getActiveGroupItem();
382+
let activeGroup = tabGroup.TV && tabGroup.tabView.GroupItems.getActiveGroupItem();
374383
let title = activeGroup ? activeGroup.getTitle() : "";
375384
context.completions = title ? [[title, ""]] : [];
376385
}
@@ -382,6 +391,9 @@ var TabGroup = Module("tabGroup", {
382391
*/
383392
new Command(["switch"], "Switch to another group",
384393
function (args) {
394+
if (!tabGroup.TV)
395+
return;
396+
385397
if (args.count > 0)
386398
tabGroup.switchTo("+" + args.count, true);
387399
else
@@ -404,15 +416,20 @@ var TabGroup = Module("tabGroup", {
404416

405417
completion: function () {
406418
completion.tabgroup = function TabGroupCompleter (context, excludeActiveGroup) {
419+
context.title = ["Tab Group"];
420+
context.anchored = false;
421+
if (!tabGroup.TV) {
422+
context.completions = [];
423+
return;
424+
}
425+
407426
const GI = tabGroup.tabView.GroupItems;
408427
let groupItems = GI.groupItems;
409428
if (excludeActiveGroup) {
410429
let activeGroup = GI.getActiveGroupItem();
411430
if (activeGroup)
412431
groupItems = groupItems.filter(function(group) group.id != activeGroup.id);
413432
}
414-
context.title = ["Tab Group"];
415-
context.anchored = false;
416433
context.completions = groupItems.map(function(group) {
417434
let title = group.id + ": " + (group.getTitle() || "(Untitled)");
418435
let desc = "Tabs: " + group.getChildren().length;

0 commit comments

Comments
 (0)