mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 16:52:25 +01:00
Partially fix completions with mismatched start offsets
This commit is contained in:
@@ -618,17 +618,20 @@ function Commands() //{{{
|
||||
{
|
||||
let opt = args.completeOpt;
|
||||
let context = complete.fork(opt[0][0], args.completeStart);
|
||||
context.filter = args.completeFilter;
|
||||
if (typeof opt[3] == "function")
|
||||
var compl = opt[3](context, args);
|
||||
else
|
||||
compl = opt[3] || [];
|
||||
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.title = ["Options"];
|
||||
if (completeOpts)
|
||||
complete.completions = completeOpts;
|
||||
|
||||
}
|
||||
|
||||
// check for correct number of arguments
|
||||
|
||||
@@ -91,10 +91,10 @@ CompletionContext.prototype = {
|
||||
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 items = this.contextList.map(function (context) {
|
||||
let prefix = self.value.substring(minStart, context.offset);
|
||||
if (!context.hasItems)
|
||||
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) }
|
||||
},
|
||||
@@ -1167,7 +1167,6 @@ function Completion() //{{{
|
||||
if (compObject != null)
|
||||
{
|
||||
cmdContext.advance(compObject.start);
|
||||
cmdContext.title = ["Completions"];
|
||||
cmdContext.filterFunc = function (k) k;
|
||||
cmdContext.completions = compObject.items;
|
||||
}
|
||||
@@ -1333,7 +1332,6 @@ function Completion() //{{{
|
||||
context.title = ["Shell Command", "Path"];
|
||||
context.generate = function ()
|
||||
{
|
||||
liberator.dump("generate");
|
||||
const environmentService = Components.classes["@mozilla.org/process/environment;1"]
|
||||
.getService(Components.interfaces.nsIEnvironment);
|
||||
|
||||
|
||||
@@ -488,7 +488,7 @@ liberator.registerObserver("load_commands", function ()
|
||||
height: 1em !important; min-height: 1em !important; max-height: 1em !important;
|
||||
overflow: hidden !important;
|
||||
]]>;
|
||||
let [key, css] = args.arguments[0];
|
||||
let [key, css] = args.arguments;
|
||||
if (!css && !(key && special))
|
||||
{
|
||||
let str = template.tabular(["Key", "Sample", "CSS"],
|
||||
@@ -509,9 +509,11 @@ liberator.registerObserver("load_commands", function ()
|
||||
argCount: 2,
|
||||
bang: true,
|
||||
// TODO: add this as a standard highlight completion function?
|
||||
completer: function (context) [0,
|
||||
completion.filter([[v.class, ""] for (v in highlight)], context.filter)
|
||||
],
|
||||
completer: function (context, args)
|
||||
{
|
||||
if (args.completeArg == 0)
|
||||
context.completions = [[v.class, ""] for (v in highlight)];
|
||||
},
|
||||
hereDoc: true,
|
||||
literal: true,
|
||||
options: [[["-append", "-a"], commands.OPTION_NOARG]],
|
||||
|
||||
Reference in New Issue
Block a user