1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-08 04:14:11 +01:00

Cherry pick some completion changes from an ancient patch.

This commit is contained in:
Kris Maglione
2011-10-01 23:30:39 -04:00
parent 84a68bff9a
commit 11af53d1ae

View File

@@ -221,6 +221,8 @@ var CompletionContext = Class("CompletionContext", {
}, },
get title() this.__title, get title() this.__title,
get activeContexts() this.contextList.filter(function (c) c.hasItems && c.items.length),
// Temporary // Temporary
/** /**
* @property {Object} * @property {Object}
@@ -241,9 +243,7 @@ var CompletionContext = Class("CompletionContext", {
let minStart = Math.min.apply(Math, [context.offset for ([k, context] in Iterator(this.contexts)) if (context.hasItems && context.items.length)]); let minStart = Math.min.apply(Math, [context.offset for ([k, context] in Iterator(this.contexts)) if (context.hasItems && context.items.length)]);
if (minStart == Infinity) if (minStart == Infinity)
minStart = 0; minStart = 0;
let items = this.contextList.map(function (context) { let items = this.activeContexts.map(function (context) {
if (!context.hasItems)
return [];
let prefix = self.value.substring(minStart, context.offset); let prefix = self.value.substring(minStart, context.offset);
return context.items.map(function (item) ({ return context.items.map(function (item) ({
text: prefix + item.text, text: prefix + item.text,
@@ -262,7 +262,7 @@ var CompletionContext = Class("CompletionContext", {
}, },
// Temporary // Temporary
get allSubstrings() { get allSubstrings() {
let contexts = this.contextList.filter(function (c) c.hasItems && c.items.length); let contexts = this.activeContexts;
let minStart = Math.min.apply(Math, contexts.map(function (c) c.offset)); let minStart = Math.min.apply(Math, contexts.map(function (c) c.offset));
let lists = contexts.map(function (context) { let lists = contexts.map(function (context) {
let prefix = context.value.substring(minStart, context.offset); let prefix = context.value.substring(minStart, context.offset);
@@ -899,7 +899,7 @@ var Completion = Module("completion", {
context = context.contexts["/list"]; context = context.contexts["/list"];
context.wait(null, true); context.wait(null, true);
let contexts = context.contextList.filter(function (c) c.hasItems && c.items.length); let contexts = context.activeContexts;
if (!contexts.length) if (!contexts.length)
contexts = context.contextList.filter(function (c) c.hasItems).slice(0, 1); contexts = context.contextList.filter(function (c) c.hasItems).slice(0, 1);
if (!contexts.length) if (!contexts.length)