mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 14:47:59 +01:00
Sort buffer completions numerically.
This commit is contained in:
@@ -220,6 +220,12 @@ function CompletionContext(editor, name, offset) //{{{
|
|||||||
: item.item[key];
|
: item.item[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompletionContext.Sort = {
|
||||||
|
number: function (a, b) parseInt(b) - parseInt(a) || String.localeCompare(a, b),
|
||||||
|
|
||||||
|
unsorted: null
|
||||||
|
};
|
||||||
|
|
||||||
CompletionContext.prototype = {
|
CompletionContext.prototype = {
|
||||||
// Temporary
|
// Temporary
|
||||||
/**
|
/**
|
||||||
@@ -1381,6 +1387,7 @@ function Completion() //{{{
|
|||||||
context.anchored = false;
|
context.anchored = false;
|
||||||
context.title = ["Buffer", "URL"];
|
context.title = ["Buffer", "URL"];
|
||||||
context.keys = { text: "text", description: "url", icon: "icon" };
|
context.keys = { text: "text", description: "url", icon: "icon" };
|
||||||
|
context.compare = CompletionContext.Sort.number;
|
||||||
let process = context.process[0];
|
let process = context.process[0];
|
||||||
context.process = [function (item, text)
|
context.process = [function (item, text)
|
||||||
<>
|
<>
|
||||||
@@ -1560,7 +1567,7 @@ function Completion() //{{{
|
|||||||
{
|
{
|
||||||
context.format = history.format;
|
context.format = history.format;
|
||||||
context.title = ["History"]
|
context.title = ["History"]
|
||||||
context.compare = null;
|
context.compare = CompletionContext.Sort.unsorted;
|
||||||
//context.background = true;
|
//context.background = true;
|
||||||
if (context.maxItems == null)
|
if (context.maxItems == null)
|
||||||
context.maxItems = 100;
|
context.maxItems = 100;
|
||||||
@@ -1584,7 +1591,7 @@ function Completion() //{{{
|
|||||||
context.hasItems = context.completions.length > 0; // XXX
|
context.hasItems = context.completions.length > 0; // XXX
|
||||||
context.filterFunc = null;
|
context.filterFunc = null;
|
||||||
context.cancel = function () services.get("autoCompleteSearch").stopSearch();
|
context.cancel = function () services.get("autoCompleteSearch").stopSearch();
|
||||||
context.compare = null;
|
context.compare = CompletionContext.Sort.unsorted;
|
||||||
let timer = new Timer(50, 100, function (result) {
|
let timer = new Timer(50, 100, function (result) {
|
||||||
context.incomplete = result.searchResult >= result.RESULT_NOMATCH_ONGOING;
|
context.incomplete = result.searchResult >= result.RESULT_NOMATCH_ONGOING;
|
||||||
context.completions = [
|
context.completions = [
|
||||||
@@ -1716,7 +1723,7 @@ function Completion() //{{{
|
|||||||
context.format = history.format;
|
context.format = history.format;
|
||||||
context.title = [keyword + " Quick Search"];
|
context.title = [keyword + " Quick Search"];
|
||||||
// context.background = true;
|
// context.background = true;
|
||||||
context.compare = null;
|
context.compare = CompletionContext.Sort.unsorted;
|
||||||
context.generate = function () {
|
context.generate = function () {
|
||||||
let [begin, end] = item.url.split("%s");
|
let [begin, end] = item.url.split("%s");
|
||||||
|
|
||||||
@@ -1751,7 +1758,7 @@ function Completion() //{{{
|
|||||||
let ctxt = context.fork(name, 0);
|
let ctxt = context.fork(name, 0);
|
||||||
|
|
||||||
ctxt.title = [engine.description + " Suggestions"];
|
ctxt.title = [engine.description + " Suggestions"];
|
||||||
ctxt.compare = null;
|
ctxt.compare = CompletionContext.Sort.unsorted;
|
||||||
ctxt.incomplete = true;
|
ctxt.incomplete = true;
|
||||||
bookmarks.getSuggestions(name, ctxt.filter, function (compl) {
|
bookmarks.getSuggestions(name, ctxt.filter, function (compl) {
|
||||||
ctxt.incomplete = false;
|
ctxt.incomplete = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user