1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 07:48:00 +01:00

Better array option completion handling. Closes issue #159.

--HG--
extra : rebase_source : d5673d1bd406ab7096e2e7f73e8412972585a069
This commit is contained in:
Kris Maglione
2010-12-01 14:18:03 -05:00
parent 4de32441d7
commit cb0478ddd6
4 changed files with 14 additions and 10 deletions

View File

@@ -389,16 +389,8 @@ const Bookmarks = Module("bookmarks", {
names: ["-tags", "-T"],
description: "A comma-separated list of tags",
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.keys = { text: function (tag) prefix + tag, description: util.identity };
context.filters.push(function (tag) have.indexOf(tag) < 0);
context.keys = { text: util.identity, description: util.identity };
},
type: CommandOption.LIST
};

View File

@@ -446,7 +446,7 @@ const Buffer = Module("buffer", {
*/
get 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) {
(dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame = Cu.getWeakReference(frame);

View File

@@ -849,6 +849,12 @@ const Commands = Module("commands", {
if (opt.type) {
let orig = 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 (!complete || orig != "" || args.completeStart != str.length)
fail("Invalid argument for " + opt.type.description + " option: " + optname);
@@ -937,7 +943,10 @@ const Commands = Module("commands", {
if (args.completeOpt) {
let opt = args.completeOpt;
let context = complete.fork(opt.names[0], args.completeStart);
let arg = args[opt.names[0]];
context.filter = args.completeFilter;
if (isArray(arg))
context.filters.push(function (item) arg.indexOf(item.text) === -1);
if (typeof opt.completer == "function")
var compl = opt.completer(context, args);
else

View File

@@ -271,6 +271,9 @@ const Events = Module("events", {
break;
}
}
catch (e) {
util.reportError(e);
}
finally {
this.feedingEvent = null;
this.feedingKeys = wasFeeding;