mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 23:17:59 +01:00
Better array option completion handling. Closes issue #159.
--HG-- extra : rebase_source : d5673d1bd406ab7096e2e7f73e8412972585a069
This commit is contained in:
@@ -389,16 +389,8 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
names: ["-tags", "-T"],
|
names: ["-tags", "-T"],
|
||||||
description: "A comma-separated list of tags",
|
description: "A comma-separated list of tags",
|
||||||
completer: function tags(context, args) {
|
completer: function tags(context, args) {
|
||||||
// TODO: Move the bulk of this to parseArgs.
|
|
||||||
let filter = context.filter;
|
|
||||||
let have = filter.split(",");
|
|
||||||
|
|
||||||
args.completeFilter = have.pop();
|
|
||||||
|
|
||||||
let prefix = filter.substr(0, filter.length - args.completeFilter.length);
|
|
||||||
context.generate = function () array(b.tags for (b in bookmarkcache) if (b.tags)).flatten().uniq().array;
|
context.generate = function () array(b.tags for (b in bookmarkcache) if (b.tags)).flatten().uniq().array;
|
||||||
context.keys = { text: function (tag) prefix + tag, description: util.identity };
|
context.keys = { text: util.identity, description: util.identity };
|
||||||
context.filters.push(function (tag) have.indexOf(tag) < 0);
|
|
||||||
},
|
},
|
||||||
type: CommandOption.LIST
|
type: CommandOption.LIST
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -446,7 +446,7 @@ const Buffer = Module("buffer", {
|
|||||||
*/
|
*/
|
||||||
get focusedFrame() {
|
get focusedFrame() {
|
||||||
let frame = (dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame;
|
let frame = (dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame;
|
||||||
return frame && frame.get() || content;
|
return frame && frame.get() || window.content;
|
||||||
},
|
},
|
||||||
set focusedFrame(frame) {
|
set focusedFrame(frame) {
|
||||||
(dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame = Cu.getWeakReference(frame);
|
(dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame = Cu.getWeakReference(frame);
|
||||||
|
|||||||
@@ -849,6 +849,12 @@ const Commands = Module("commands", {
|
|||||||
if (opt.type) {
|
if (opt.type) {
|
||||||
let orig = arg;
|
let orig = arg;
|
||||||
arg = opt.type.parse(arg);
|
arg = opt.type.parse(arg);
|
||||||
|
|
||||||
|
if (complete && isArray(arg)) {
|
||||||
|
args.completeFilter = arg[arg.length - 1];
|
||||||
|
args.completeStart += orig.length - args.completeFilter.length;
|
||||||
|
}
|
||||||
|
|
||||||
if (arg == null || (typeof arg == "number" && isNaN(arg))) {
|
if (arg == null || (typeof arg == "number" && isNaN(arg))) {
|
||||||
if (!complete || orig != "" || args.completeStart != str.length)
|
if (!complete || orig != "" || args.completeStart != str.length)
|
||||||
fail("Invalid argument for " + opt.type.description + " option: " + optname);
|
fail("Invalid argument for " + opt.type.description + " option: " + optname);
|
||||||
@@ -937,7 +943,10 @@ const Commands = Module("commands", {
|
|||||||
if (args.completeOpt) {
|
if (args.completeOpt) {
|
||||||
let opt = args.completeOpt;
|
let opt = args.completeOpt;
|
||||||
let context = complete.fork(opt.names[0], args.completeStart);
|
let context = complete.fork(opt.names[0], args.completeStart);
|
||||||
|
let arg = args[opt.names[0]];
|
||||||
context.filter = args.completeFilter;
|
context.filter = args.completeFilter;
|
||||||
|
if (isArray(arg))
|
||||||
|
context.filters.push(function (item) arg.indexOf(item.text) === -1);
|
||||||
if (typeof opt.completer == "function")
|
if (typeof opt.completer == "function")
|
||||||
var compl = opt.completer(context, args);
|
var compl = opt.completer(context, args);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -271,6 +271,9 @@ const Events = Module("events", {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (e) {
|
||||||
|
util.reportError(e);
|
||||||
|
}
|
||||||
finally {
|
finally {
|
||||||
this.feedingEvent = null;
|
this.feedingEvent = null;
|
||||||
this.feedingKeys = wasFeeding;
|
this.feedingKeys = wasFeeding;
|
||||||
|
|||||||
Reference in New Issue
Block a user