mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 12:42:26 +01:00
Fix completion bug. Speed completion scrolling by another 20ui.js.
This commit is contained in:
@@ -320,7 +320,11 @@ function Bookmarks() //{{{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
bang: true,
|
bang: true,
|
||||||
completer: function completer(context, args) completion.bookmark(context, args["-tags"]),
|
completer: function completer(context, args)
|
||||||
|
{
|
||||||
|
context.quote = null;
|
||||||
|
completion.bookmark(context, args["-tags"]);
|
||||||
|
},
|
||||||
options: [[["-tags", "-T"], commands.OPTION_LIST, null, tags]]
|
options: [[["-tags", "-T"], commands.OPTION_LIST, null, tags]]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ function CompletionContext(editor, name, offset)
|
|||||||
self[key] = parent[key]);
|
self[key] = parent[key]);
|
||||||
if (self != this)
|
if (self != this)
|
||||||
return self;
|
return self;
|
||||||
["contextList", "onUpdate", "selectionTypes", "tabPressed", "updateAsync", "value"].forEach(function (key) {
|
["_caret", "contextList", "onUpdate", "selectionTypes", "tabPressed", "updateAsync", "value"].forEach(function (key) {
|
||||||
self.__defineGetter__(key, function () this.top[key]);
|
self.__defineGetter__(key, function () this.top[key]);
|
||||||
self.__defineSetter__(key, function (val) this.top[key] = val);
|
self.__defineSetter__(key, function (val) this.top[key] = val);
|
||||||
});
|
});
|
||||||
@@ -149,7 +149,7 @@ CompletionContext.prototype = {
|
|||||||
return substrings.reduce(function (a, b) a.length > b.length ? a : b, "");
|
return substrings.reduce(function (a, b) a.length > b.length ? a : b, "");
|
||||||
},
|
},
|
||||||
|
|
||||||
get caret() (this.editor ? this.editor.selection.getRangeAt(0).startOffset : this.value.length) - this.offset,
|
get caret() this._caret - this.offset,
|
||||||
|
|
||||||
get compare() this._compare || function () 0,
|
get compare() this._compare || function () 0,
|
||||||
set compare(val) this._compare = val,
|
set compare(val) this._compare = val,
|
||||||
@@ -176,6 +176,25 @@ CompletionContext.prototype = {
|
|||||||
get filterFunc() this._filterFunc || util.identity,
|
get filterFunc() this._filterFunc || util.identity,
|
||||||
set filterFunc(val) this._filterFunc = val,
|
set filterFunc(val) this._filterFunc = val,
|
||||||
|
|
||||||
|
get filter() this._filter != null ? this._filter : this.value.substr(this.offset, this.caret),
|
||||||
|
set filter(val)
|
||||||
|
{
|
||||||
|
delete this._ignoreCase;
|
||||||
|
return this._filter = val
|
||||||
|
},
|
||||||
|
|
||||||
|
get format() ({
|
||||||
|
title: this.title,
|
||||||
|
keys: this.keys,
|
||||||
|
process: this.process
|
||||||
|
}),
|
||||||
|
set format(format)
|
||||||
|
{
|
||||||
|
this.title = format.title || this.title;
|
||||||
|
this.keys = format.keys || this.keys;
|
||||||
|
this.process = format.process || this.process;
|
||||||
|
},
|
||||||
|
|
||||||
get regenerate() this._generate && (!this.completions || !this.itemCache[this.key] || this.cache.offset != this.offset),
|
get regenerate() this._generate && (!this.completions || !this.itemCache[this.key] || this.cache.offset != this.offset),
|
||||||
set regenerate(val) { if (val) delete this.itemCache[this.key] },
|
set regenerate(val) { if (val) delete this.itemCache[this.key] },
|
||||||
|
|
||||||
@@ -197,7 +216,6 @@ CompletionContext.prototype = {
|
|||||||
let lock = {};
|
let lock = {};
|
||||||
this.cache.backgroundLock = lock;
|
this.cache.backgroundLock = lock;
|
||||||
this.incomplete = true;
|
this.incomplete = true;
|
||||||
let now = Date.now();
|
|
||||||
liberator.callAsync(this, function () {
|
liberator.callAsync(this, function () {
|
||||||
let items = this.generate();
|
let items = this.generate();
|
||||||
if (this.cache.backgroundLock != lock)
|
if (this.cache.backgroundLock != lock)
|
||||||
@@ -208,25 +226,6 @@ CompletionContext.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
get filter() this._filter != null ? this._filter : this.value.substr(this.offset, this.caret),
|
|
||||||
set filter(val)
|
|
||||||
{
|
|
||||||
delete this._ignoreCase;
|
|
||||||
return this._filter = val
|
|
||||||
},
|
|
||||||
|
|
||||||
get format() ({
|
|
||||||
title: this.title,
|
|
||||||
keys: this.keys,
|
|
||||||
process: this.process
|
|
||||||
}),
|
|
||||||
set format(format)
|
|
||||||
{
|
|
||||||
this.title = format.title || this.title;
|
|
||||||
this.keys = format.keys || this.keys;
|
|
||||||
this.process = format.process || this.process;
|
|
||||||
},
|
|
||||||
|
|
||||||
get ignoreCase()
|
get ignoreCase()
|
||||||
{
|
{
|
||||||
if ("_ignoreCase" in this)
|
if ("_ignoreCase" in this)
|
||||||
@@ -242,7 +241,7 @@ CompletionContext.prototype = {
|
|||||||
|
|
||||||
get items()
|
get items()
|
||||||
{
|
{
|
||||||
if (!this.hasItems)
|
if (!this.hasItems || this.backgroundLock)
|
||||||
return [];
|
return [];
|
||||||
if (this.cache.filtered && this.cache.filter == this.filter)
|
if (this.cache.filtered && this.cache.filter == this.filter)
|
||||||
return this.cache.filtered;
|
return this.cache.filtered;
|
||||||
@@ -437,7 +436,16 @@ CompletionContext.prototype = {
|
|||||||
this.tabPressed = false;
|
this.tabPressed = false;
|
||||||
this.title = ["Completions"];
|
this.title = ["Completions"];
|
||||||
this.updateAsync = false;
|
this.updateAsync = false;
|
||||||
this.value = this.editor ? this.editor.rootElement.textContent : this._value;
|
if (this.editor)
|
||||||
|
{
|
||||||
|
this.value = this.editor.rootElement.textContent;
|
||||||
|
this._caret = this.editor.selection.getRangeAt(0).startOffset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.value = this._value;
|
||||||
|
this._caret = this.value.length;
|
||||||
|
}
|
||||||
//for (let key in (k for ([k, v] in Iterator(self.contexts)) if (v.offset > this.caret)))
|
//for (let key in (k for ([k, v] in Iterator(self.contexts)) if (v.offset > this.caret)))
|
||||||
// delete this.contexts[key];
|
// delete this.contexts[key];
|
||||||
for each (let context in this.contexts)
|
for each (let context in this.contexts)
|
||||||
@@ -1001,9 +1009,6 @@ function Completion() //{{{
|
|||||||
return [];
|
return [];
|
||||||
|
|
||||||
var hasTags = urls[0].tags !== undefined;
|
var hasTags = urls[0].tags !== undefined;
|
||||||
// TODO: create a copy of urls?
|
|
||||||
if (!filter && (!hasTags || !filterTags))
|
|
||||||
return urls;
|
|
||||||
|
|
||||||
filterTags = filterTags || [];
|
filterTags = filterTags || [];
|
||||||
|
|
||||||
|
|||||||
@@ -1231,6 +1231,7 @@ function CommandLine() //{{{
|
|||||||
catch (e) {}
|
catch (e) {}
|
||||||
doc.body.style.minWidth = commandlineWidget.scrollWidth + "px";
|
doc.body.style.minWidth = commandlineWidget.scrollWidth + "px";
|
||||||
outputContainer.height = Math.min(doc.height, availableHeight) + "px";
|
outputContainer.height = Math.min(doc.height, availableHeight) + "px";
|
||||||
|
doc.body.style.minWidth = undefined;
|
||||||
outputContainer.collapsed = false;
|
outputContainer.collapsed = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -1321,7 +1322,7 @@ function ItemList(id) //{{{
|
|||||||
|
|
||||||
doc.body.id = id + "-content";
|
doc.body.id = id + "-content";
|
||||||
doc.body.appendChild(doc.createTextNode(""));
|
doc.body.appendChild(doc.createTextNode(""));
|
||||||
doc.body.style.borderTop = "1px solid black"; // FIXME: For cases where completions/MOW are shown at once. Should use :highlight.
|
doc.body.style.borderTop = "1px solid black"; // FIXME: For cases where completions/MOW are shown at once, or ls=0. Should use :highlight.
|
||||||
|
|
||||||
var items = null;
|
var items = null;
|
||||||
var startIndex = -1; // The index of the first displayed item
|
var startIndex = -1; // The index of the first displayed item
|
||||||
@@ -1337,7 +1338,8 @@ function ItemList(id) //{{{
|
|||||||
div.style.minWidth = document.getElementById("liberator-commandline").scrollWidth + "px";
|
div.style.minWidth = document.getElementById("liberator-commandline").scrollWidth + "px";
|
||||||
minHeight = Math.max(minHeight, divNodes.completions.getBoundingClientRect().bottom);
|
minHeight = Math.max(minHeight, divNodes.completions.getBoundingClientRect().bottom);
|
||||||
container.height = minHeight;
|
container.height = minHeight;
|
||||||
div.style.minWidth = undefined;
|
if (container.collapsed)
|
||||||
|
div.style.minWidth = undefined;
|
||||||
// FIXME: Belongs elsewhere.
|
// FIXME: Belongs elsewhere.
|
||||||
commandline.updateOutputHeight(false);
|
commandline.updateOutputHeight(false);
|
||||||
}
|
}
|
||||||
@@ -1415,18 +1417,16 @@ function ItemList(id) //{{{
|
|||||||
nodes[i] = row;
|
nodes[i] = row;
|
||||||
for (let [i, row] in util.Array.iterator2(nodes))
|
for (let [i, row] in util.Array.iterator2(nodes))
|
||||||
{
|
{
|
||||||
let display = i >= start && i < end;
|
let display = (i >= start && i < end);
|
||||||
if (row.parentNode != items)
|
if (display && row.parentNode != items)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
var next = nodes[++i];
|
var next = nodes[++i];
|
||||||
while ((!next || next.parentNode != root) && i < nodes.length);
|
while ((!next || next.parentNode != root) && i < nodes.length);
|
||||||
items.insertBefore(row, next);
|
items.insertBefore(row, next);
|
||||||
}
|
}
|
||||||
if (display)
|
else if (!display && row.parentNode == items)
|
||||||
row.style.display = "table-row";
|
items.removeChild(row);
|
||||||
else
|
|
||||||
row.style.display = "none";
|
|
||||||
}
|
}
|
||||||
nodes.up.style.display = (start == 0) ? "none" : "block";
|
nodes.up.style.display = (start == 0) ? "none" : "block";
|
||||||
nodes.down.style.display = (end == context.items.length) ? "none" : "block";
|
nodes.down.style.display = (end == context.items.length) ? "none" : "block";
|
||||||
@@ -1434,7 +1434,7 @@ function ItemList(id) //{{{
|
|||||||
|
|
||||||
divNodes.noCompletions.style.display = (off > 0) ? "none" : "block";
|
divNodes.noCompletions.style.display = (off > 0) ? "none" : "block";
|
||||||
|
|
||||||
completionElements = buffer.evaluateXPath("//xhtml:div[@liberator:highlight='CompItem' and not(contains(@style, 'none'))]", doc);
|
completionElements = buffer.evaluateXPath("//xhtml:div[@liberator:highlight='CompItem']", doc);
|
||||||
|
|
||||||
autoSize();
|
autoSize();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user