mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 09:48:00 +01:00
Better completion with quoting, but not perfect.
This commit is contained in:
@@ -434,7 +434,7 @@ function Commands() //{{{
|
|||||||
{
|
{
|
||||||
// Push possible option matches into completions
|
// Push possible option matches into completions
|
||||||
if (complete && !onlyArgumentsRemaining)
|
if (complete && !onlyArgumentsRemaining)
|
||||||
completeOpts = [[opt[0], opt[0][0]] for ([i, opt] in Iterator(options))];
|
completeOpts = [[opt[0], opt[0][0]] for ([i, opt] in Iterator(options)) if (!(opt[0][0] in args))];
|
||||||
}
|
}
|
||||||
function resetCompletions()
|
function resetCompletions()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,20 +43,24 @@ function CompletionContext(editor, name, offset)
|
|||||||
self = this.contexts[name];
|
self = this.contexts[name];
|
||||||
else
|
else
|
||||||
self.contexts[name] = this;
|
self.contexts[name] = this;
|
||||||
|
|
||||||
|
self.parent = parent;
|
||||||
|
["filters", "keys", "title", "quote"].forEach(function (key)
|
||||||
|
self[key] = parent[key] && util.cloneObject(parent[key]));
|
||||||
|
["anchored", "compare", "editor", "_filter", "filterFunc", "keys", "_process", "top"].forEach(function (key)
|
||||||
|
self[key] = parent[key]);
|
||||||
|
|
||||||
|
self.__defineGetter__("value", function () this.top.value);
|
||||||
|
|
||||||
|
self.offset = parent.offset;
|
||||||
|
self.advance(offset);
|
||||||
|
|
||||||
self.incomplete = false;
|
self.incomplete = false;
|
||||||
self.message = null;
|
self.message = null;
|
||||||
self.offset = parent.offset + (offset || 0);
|
|
||||||
self.parent = parent;
|
|
||||||
self.waitingForTab = false;
|
self.waitingForTab = false;
|
||||||
delete self._filter; // FIXME?
|
//delete self._filter; // FIXME?
|
||||||
delete self._generate;
|
delete self._generate;
|
||||||
delete self._ignoreCase;
|
delete self._ignoreCase;
|
||||||
["filters", "keys", "title", "quote"].forEach(function (key) {
|
|
||||||
if (parent[key])
|
|
||||||
self[key] = util.cloneObject(parent[key]);
|
|
||||||
});
|
|
||||||
["anchored", "compare", "editor", "filterFunc", "keys", "_process", "top"].forEach(function (key)
|
|
||||||
self[key] = parent[key]);
|
|
||||||
if (self != this)
|
if (self != this)
|
||||||
return self;
|
return self;
|
||||||
["_caret", "contextList", "maxItems", "onUpdate", "selectionTypes", "tabPressed", "updateAsync", "value"].forEach(function (key) {
|
["_caret", "contextList", "maxItems", "onUpdate", "selectionTypes", "tabPressed", "updateAsync", "value"].forEach(function (key) {
|
||||||
@@ -345,14 +349,14 @@ CompletionContext.prototype = {
|
|||||||
advance: function advance(count)
|
advance: function advance(count)
|
||||||
{
|
{
|
||||||
delete this._ignoreCase;
|
delete this._ignoreCase;
|
||||||
this.offset += count;
|
liberator.dump(count);
|
||||||
if (this.quote)
|
if (this.quote)
|
||||||
{
|
{
|
||||||
this.offset += this.quote[0].length;
|
count = this.quote[0].length + this.quote[1](this.filter.substr(0, count)).length;
|
||||||
this.quote[0] = "";
|
this.quote[0] = "";
|
||||||
this.quote[2] = "";
|
this.quote[2] = "";
|
||||||
}
|
}
|
||||||
// XXX
|
this.offset += count;
|
||||||
if (this._filter)
|
if (this._filter)
|
||||||
this._filter = this._filter.substr(count);
|
this._filter = this._filter.substr(count);
|
||||||
},
|
},
|
||||||
@@ -1254,7 +1258,7 @@ function Completion() //{{{
|
|||||||
|
|
||||||
[prefix] = context.filter.match(/^(?:\w*[\s!]|!)\s*/);
|
[prefix] = context.filter.match(/^(?:\w*[\s!]|!)\s*/);
|
||||||
let cmdContext = context.fork(cmd, prefix.length);
|
let cmdContext = context.fork(cmd, prefix.length);
|
||||||
let argContext = cmdContext.fork("args", args.completeStart);
|
let argContext = context.fork("args", prefix.length);
|
||||||
args = command.parseArgs(cmdContext.filter, argContext);
|
args = command.parseArgs(cmdContext.filter, argContext);
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user