mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 05:57:58 +01:00
sort :commands for tab-completion
This commit is contained in:
@@ -72,7 +72,7 @@ vimperator.Command = function (specs, description, action, extraInfo) //{{{
|
|||||||
// return the primary command name (the long name of the first spec listed)
|
// return the primary command name (the long name of the first spec listed)
|
||||||
this.name = this.longNames[0];
|
this.name = this.longNames[0];
|
||||||
this.names = expandedSpecs.names; // return all command name aliases
|
this.names = expandedSpecs.names; // return all command name aliases
|
||||||
this.description = extraInfo.description || "";
|
this.description = description || "";
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.completer = extraInfo.completer || null;
|
this.completer = extraInfo.completer || null;
|
||||||
this.args = extraInfo.args || [];
|
this.args = extraInfo.args || [];
|
||||||
@@ -414,14 +414,6 @@ vimperator.Commands = function () //{{{
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
function commandsIterator()
|
|
||||||
{
|
|
||||||
for (var i = 0; i < exCommands.length; i++)
|
|
||||||
yield exCommands[i];
|
|
||||||
|
|
||||||
throw StopIteration;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getUserCommands(name)
|
function getUserCommands(name)
|
||||||
{
|
{
|
||||||
var matches = [];
|
var matches = [];
|
||||||
@@ -467,7 +459,11 @@ vimperator.Commands = function () //{{{
|
|||||||
|
|
||||||
__iterator__: function ()
|
__iterator__: function ()
|
||||||
{
|
{
|
||||||
return commandsIterator();
|
var sorted = exCommands.sort(function (cmd1, cmd2) { return cmd1.name > cmd2.name; });
|
||||||
|
for (var i = 0; i < sorted.length; i++)
|
||||||
|
yield sorted[i];
|
||||||
|
|
||||||
|
throw StopIteration;
|
||||||
},
|
},
|
||||||
|
|
||||||
add: function (names, description, action, extra)
|
add: function (names, description, action, extra)
|
||||||
|
|||||||
@@ -302,6 +302,7 @@ vimperator.Completion = function () //{{{
|
|||||||
{
|
{
|
||||||
substrings = [];
|
substrings = [];
|
||||||
var completions = [];
|
var completions = [];
|
||||||
|
|
||||||
if (!filter)
|
if (!filter)
|
||||||
{
|
{
|
||||||
for (var command in vimperator.commands)
|
for (var command in vimperator.commands)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ vimperator.Map = function (modes, cmds, description, action, extraInfo) //{{{
|
|||||||
this.action = action;
|
this.action = action;
|
||||||
|
|
||||||
this.flags = extraInfo.flags || 0;
|
this.flags = extraInfo.flags || 0;
|
||||||
this.description = extraInfo.description || "";
|
this.description = description || "";
|
||||||
this.rhs = extraInfo.rhs || null;
|
this.rhs = extraInfo.rhs || null;
|
||||||
this.noremap = extraInfo.noremap || false;
|
this.noremap = extraInfo.noremap || false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -669,7 +669,6 @@ vimperator.CommandLine = function () //{{{
|
|||||||
completionlist.selectItem(completionIndex);
|
completionlist.selectItem(completionIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (completionIndex == -1 && !longest) // wrapped around matches, reset command line
|
if (completionIndex == -1 && !longest) // wrapped around matches, reset command line
|
||||||
{
|
{
|
||||||
if (full && completions.length > 1)
|
if (full && completions.length > 1)
|
||||||
@@ -679,12 +678,14 @@ vimperator.CommandLine = function () //{{{
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
var compl = null;
|
||||||
if (longest && completions.length > 1)
|
if (longest && completions.length > 1)
|
||||||
var compl = vimperator.completion.getLongestSubstring();
|
compl = vimperator.completion.getLongestSubstring();
|
||||||
else if (full)
|
else if (full)
|
||||||
var compl = completions[completionIndex][0];
|
compl = completions[completionIndex][0];
|
||||||
else if (completions.length == 1)
|
else if (completions.length == 1)
|
||||||
var compl = completions[0][0];
|
compl = completions[0][0];
|
||||||
|
|
||||||
if (compl)
|
if (compl)
|
||||||
{
|
{
|
||||||
setCommand(command.substring(0, completionStartIndex) + compl + completionPostfix);
|
setCommand(command.substring(0, completionStartIndex) + compl + completionPostfix);
|
||||||
|
|||||||
Reference in New Issue
Block a user