mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 23:58:00 +01:00
use -1 as the default value for the ex command count
This commit is contained in:
@@ -128,6 +128,7 @@ vimperator.Commands = function() //{{{
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
const OPTION_ANY = 0; // can be given no argument or an argument of any type, user is responsible
|
const OPTION_ANY = 0; // can be given no argument or an argument of any type, user is responsible
|
||||||
// for parsing the return value
|
// for parsing the return value
|
||||||
const OPTION_NOARG = 1;
|
const OPTION_NOARG = 1;
|
||||||
@@ -476,33 +477,30 @@ vimperator.Commands = function() //{{{
|
|||||||
// FIXME: doesn't really belong here...
|
// FIXME: doesn't really belong here...
|
||||||
// return [null, null, null, null, heredoc_tag || false];
|
// return [null, null, null, null, heredoc_tag || false];
|
||||||
// [count, cmd, special, args] = match;
|
// [count, cmd, special, args] = match;
|
||||||
this.parseCommand = function(string, tag)
|
this.parseCommand = function(str, tag)
|
||||||
{
|
{
|
||||||
// removing comments
|
// remove comments
|
||||||
string.replace(/\s*".*$/, '');
|
str.replace(/\s*".*$/, '');
|
||||||
|
|
||||||
if (tag) // we already have a multiline heredoc construct
|
if (tag) // we already have a multiline heredoc construct
|
||||||
{
|
{
|
||||||
if (string == tag)
|
if (str == tag)
|
||||||
return [null, null, null, null, false];
|
return [null, null, null, null, false];
|
||||||
else
|
else
|
||||||
return [null, null, null, string, tag];
|
return [null, null, null, str, tag];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0 - count, 1 - cmd, 2 - special, 3 - args, 4 - heredoc tag
|
// 0 - count, 1 - cmd, 2 - special, 3 - args, 4 - heredoc tag
|
||||||
var matches = string.match(/^:*(\d+)?([a-zA-Z]+|!)(!)?(?:\s*(.*?)\s*)?$/);
|
var matches = str.match(/^:*(\d+)?([a-zA-Z]+|!)(!)?(?:\s*(.*?)\s*)?$/);
|
||||||
if (!matches)
|
if (!matches)
|
||||||
return [null, null, null, null, null];
|
return [null, null, null, null, null];
|
||||||
matches.shift();
|
matches.shift();
|
||||||
|
|
||||||
// parse count
|
// parse count
|
||||||
if (matches[0])
|
if (matches[0])
|
||||||
{
|
|
||||||
matches[0] = parseInt(matches[0]);
|
matches[0] = parseInt(matches[0]);
|
||||||
if (isNaN(matches[0]))
|
|
||||||
matches[0] = 0; // 0 is the default if no count given
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
matches[0] = 0;
|
matches[0] = -1;
|
||||||
|
|
||||||
matches[2] = !!matches[2];
|
matches[2] = !!matches[2];
|
||||||
matches.push(null);
|
matches.push(null);
|
||||||
@@ -581,7 +579,7 @@ vimperator.Commands = function() //{{{
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
addDefaultCommand(new vimperator.Command(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"],
|
addDefaultCommand(new vimperator.Command(["bd[elete]", "bw[ipeout]", "bun[load]", "tabc[lose]"],
|
||||||
function(args, special, count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count, special, 0); },
|
function(args, special, count) { vimperator.tabs.remove(getBrowser().mCurrentTab, count > 0 ? count : 1, special, 0); },
|
||||||
{
|
{
|
||||||
usage: ["[count]bd[elete][!]"],
|
usage: ["[count]bd[elete][!]"],
|
||||||
short_help: "Delete current buffer (=tab)",
|
short_help: "Delete current buffer (=tab)",
|
||||||
@@ -1855,9 +1853,6 @@ vimperator.Commands = function() //{{{
|
|||||||
addDefaultCommand(new vimperator.Command(["time"],
|
addDefaultCommand(new vimperator.Command(["time"],
|
||||||
function(args, special, count)
|
function(args, special, count)
|
||||||
{
|
{
|
||||||
if (!count || count < 1)
|
|
||||||
count = 1;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (count > 1)
|
if (count > 1)
|
||||||
@@ -1951,12 +1946,12 @@ vimperator.Commands = function() //{{{
|
|||||||
{
|
{
|
||||||
if (undoItems[i].state.entries[0].url == args)
|
if (undoItems[i].state.entries[0].url == args)
|
||||||
{
|
{
|
||||||
count = i+1;
|
count = i + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
undoCloseTab(count-1);
|
undoCloseTab(count - 1);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
usage: ["[count]u[ndo][!] [url]"],
|
usage: ["[count]u[ndo][!] [url]"],
|
||||||
@@ -1984,8 +1979,16 @@ vimperator.Commands = function() //{{{
|
|||||||
addDefaultCommand(new vimperator.Command(["undoa[ll]"],
|
addDefaultCommand(new vimperator.Command(["undoa[ll]"],
|
||||||
function(args, special, count)
|
function(args, special, count)
|
||||||
{
|
{
|
||||||
if (count || special)
|
if (count > -1)
|
||||||
return vimperator.echoerr("E488: Trailing characters");
|
{
|
||||||
|
vimperator.echoerr("E481: No range allowed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (special)
|
||||||
|
{
|
||||||
|
vimperator.echoerr("E477: No ! allowed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
||||||
var undoItems = eval("(" + ss.getClosedTabData(window) + ")");
|
var undoItems = eval("(" + ss.getClosedTabData(window) + ")");
|
||||||
|
|||||||
Reference in New Issue
Block a user