mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 04:47:59 +01:00
generate errors for Ex tab commands in the command rather than in v.tabs
This commit is contained in:
@@ -2050,7 +2050,20 @@ vimperator.Commands = function () //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
commandManager.add(new vimperator.Command(["tabm[ove]"],
|
commandManager.add(new vimperator.Command(["tabm[ove]"],
|
||||||
function (args, special) { vimperator.tabs.move(getBrowser().mCurrentTab, args, special); },
|
function (args, special)
|
||||||
|
{
|
||||||
|
// FIXME: tabmove! N should probably produce an error
|
||||||
|
if (!/^([+-]?\d+|)$/.test(args))
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E488: Trailing characters");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!args)
|
||||||
|
args = "$"; // if not specified, move to the last tab
|
||||||
|
|
||||||
|
vimperator.tabs.move(getBrowser().mCurrentTab, args, special);
|
||||||
|
},
|
||||||
{
|
{
|
||||||
usage: ["tabm[ove] [N]", "tabm[ove][!] +N | -N"],
|
usage: ["tabm[ove] [N]", "tabm[ove][!] +N | -N"],
|
||||||
shortHelp: "Move the current tab after tab N",
|
shortHelp: "Move the current tab after tab N",
|
||||||
|
|||||||
@@ -56,20 +56,13 @@ vimperator.Tabs = function () //{{{
|
|||||||
if (typeof spec === "number")
|
if (typeof spec === "number")
|
||||||
position = spec;
|
position = spec;
|
||||||
else if (spec === "$")
|
else if (spec === "$")
|
||||||
return last;
|
position = last;
|
||||||
else if (!/^([+-]?\d+|)$/.test(spec))
|
else if (/^[+-]\d+$/.test(spec))
|
||||||
{
|
|
||||||
// TODO: move error reporting to ex-command?
|
|
||||||
vimperator.echoerr("E488: Trailing characters");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (/^([+-]\d+)$/.test(spec)) // relative position +/-N
|
|
||||||
position += parseInt(spec, 10);
|
position += parseInt(spec, 10);
|
||||||
else // absolute position
|
else if (/^\d+$/.test(spec))
|
||||||
position = parseInt(spec, 10);
|
position = parseInt(spec, 10);
|
||||||
}
|
else
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (position > last)
|
if (position > last)
|
||||||
position = wrap ? position % length : last;
|
position = wrap ? position % length : last;
|
||||||
@@ -132,15 +125,10 @@ vimperator.Tabs = function () //{{{
|
|||||||
return getBrowser().mTabContainer.selectedItem;
|
return getBrowser().mTabContainer.selectedItem;
|
||||||
},
|
},
|
||||||
|
|
||||||
// spec == "" moves the tab to the last position as per Vim
|
|
||||||
// wrap causes the movement to wrap around the start and end of the tab list
|
// wrap causes the movement to wrap around the start and end of the tab list
|
||||||
// NOTE: position is a 0 based index
|
// NOTE: position is a 0 based index
|
||||||
// FIXME: tabmove! N should probably produce an error
|
|
||||||
move: function (tab, spec, wrap)
|
move: function (tab, spec, wrap)
|
||||||
{
|
{
|
||||||
if (spec === "")
|
|
||||||
spec = "$"; // if not specified, move to the last tab -> XXX: move to ex handling?
|
|
||||||
|
|
||||||
var index = indexFromSpec(spec, wrap);
|
var index = indexFromSpec(spec, wrap);
|
||||||
getBrowser().moveTabTo(tab, index);
|
getBrowser().moveTabTo(tab, index);
|
||||||
},
|
},
|
||||||
@@ -209,10 +197,11 @@ vimperator.Tabs = function () //{{{
|
|||||||
select: function (spec, wrap)
|
select: function (spec, wrap)
|
||||||
{
|
{
|
||||||
var index = indexFromSpec(spec, wrap);
|
var index = indexFromSpec(spec, wrap);
|
||||||
if (index === false)
|
// FIXME:
|
||||||
|
if (index === -1)
|
||||||
{
|
{
|
||||||
vimperator.beep(); // XXX: move to ex-handling?
|
vimperator.beep(); // XXX: move to ex-handling?
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
getBrowser().mTabContainer.selectedIndex = index;
|
getBrowser().mTabContainer.selectedIndex = index;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user