1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 18:42:27 +01:00

Partially fix completions with mismatched start offsets

This commit is contained in:
Kris Maglione
2008-11-24 11:12:06 +00:00
parent 862a6cae7c
commit ced94146f8
3 changed files with 12 additions and 9 deletions

View File

@@ -618,17 +618,20 @@ function Commands() //{{{
{ {
let opt = args.completeOpt; let opt = args.completeOpt;
let context = complete.fork(opt[0][0], args.completeStart); let context = complete.fork(opt[0][0], args.completeStart);
context.filter = args.completeFilter;
if (typeof opt[3] == "function") if (typeof opt[3] == "function")
var compl = opt[3](context, args); var compl = opt[3](context, args);
else else
compl = opt[3] || []; compl = opt[3] || [];
context.title = [opt[0][0]]; context.title = [opt[0][0]];
context.completions = completion.filter(compl.map(function ([k, v]) [args.quote(k), v]), args.completeFilter);; context.quote = args.quote;
context.completions = compl;
} }
complete.advance(args.completeStart); complete.advance(args.completeStart);
complete.title = ["Options"]; complete.title = ["Options"];
if (completeOpts) if (completeOpts)
complete.completions = completeOpts; complete.completions = completeOpts;
} }
// check for correct number of arguments // check for correct number of arguments

View File

@@ -91,10 +91,10 @@ CompletionContext.prototype = {
let self = this; let self = this;
let minStart = Math.min.apply(Math, [context.offset for ([k, context] in Iterator(this.contexts)) if (context.items.length && context.hasItems)]); let minStart = Math.min.apply(Math, [context.offset for ([k, context] in Iterator(this.contexts)) if (context.items.length && context.hasItems)]);
let items = this.contextList.map(function (context) { let items = this.contextList.map(function (context) {
let prefix = self.value.substring(minStart, context.offset);
if (!context.hasItems) if (!context.hasItems)
return []; return [];
return context.items; let prefix = self.value.substring(minStart, context.offset);
return [{ text: prefix + item.text, item: item.item } for ([i, item] in Iterator(context.items))];
}); });
return { start: minStart, items: util.Array.flatten(items) } return { start: minStart, items: util.Array.flatten(items) }
}, },
@@ -1167,7 +1167,6 @@ function Completion() //{{{
if (compObject != null) if (compObject != null)
{ {
cmdContext.advance(compObject.start); cmdContext.advance(compObject.start);
cmdContext.title = ["Completions"];
cmdContext.filterFunc = function (k) k; cmdContext.filterFunc = function (k) k;
cmdContext.completions = compObject.items; cmdContext.completions = compObject.items;
} }
@@ -1333,7 +1332,6 @@ function Completion() //{{{
context.title = ["Shell Command", "Path"]; context.title = ["Shell Command", "Path"];
context.generate = function () context.generate = function ()
{ {
liberator.dump("generate");
const environmentService = Components.classes["@mozilla.org/process/environment;1"] const environmentService = Components.classes["@mozilla.org/process/environment;1"]
.getService(Components.interfaces.nsIEnvironment); .getService(Components.interfaces.nsIEnvironment);

View File

@@ -488,7 +488,7 @@ liberator.registerObserver("load_commands", function ()
height: 1em !important; min-height: 1em !important; max-height: 1em !important; height: 1em !important; min-height: 1em !important; max-height: 1em !important;
overflow: hidden !important; overflow: hidden !important;
]]>; ]]>;
let [key, css] = args.arguments[0]; let [key, css] = args.arguments;
if (!css && !(key && special)) if (!css && !(key && special))
{ {
let str = template.tabular(["Key", "Sample", "CSS"], let str = template.tabular(["Key", "Sample", "CSS"],
@@ -509,9 +509,11 @@ liberator.registerObserver("load_commands", function ()
argCount: 2, argCount: 2,
bang: true, bang: true,
// TODO: add this as a standard highlight completion function? // TODO: add this as a standard highlight completion function?
completer: function (context) [0, completer: function (context, args)
completion.filter([[v.class, ""] for (v in highlight)], context.filter) {
], if (args.completeArg == 0)
context.completions = [[v.class, ""] for (v in highlight)];
},
hereDoc: true, hereDoc: true,
literal: true, literal: true,
options: [[["-append", "-a"], commands.OPTION_NOARG]], options: [[["-append", "-a"], commands.OPTION_NOARG]],