mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 18:32:25 +01:00
Make completion display less jittery.
This commit is contained in:
@@ -832,15 +832,11 @@ liberator.Completion = function () //{{{
|
|||||||
// if "tail" is true, only return names without any directory components
|
// if "tail" is true, only return names without any directory components
|
||||||
file: function (filter, tail)
|
file: function (filter, tail)
|
||||||
{
|
{
|
||||||
var dir = "", compl = "";
|
let [matches, dir, compl] = filter.match(/^((?:.*[\/\\])?)(.*?)$/);
|
||||||
var matches = filter.match(/^(.*[\/\\])?(.*?)$/);
|
// dir == "" is expanded inside readDirectory to the current dir
|
||||||
|
|
||||||
if (matches)
|
let generate = function ()
|
||||||
{
|
{
|
||||||
dir = matches[1] || ""; // "" is expanded inside readDirectory to the current dir
|
|
||||||
compl = matches[2] || "";
|
|
||||||
}
|
|
||||||
|
|
||||||
var files = [], mapped = [];
|
var files = [], mapped = [];
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -857,15 +853,16 @@ liberator.Completion = function () //{{{
|
|||||||
mapped = files.map(function (file) [tail ? file.leafName : (dir + file.leafName),
|
mapped = files.map(function (file) [tail ? file.leafName : (dir + file.leafName),
|
||||||
file.isDirectory() ? "Directory" : "File"]);
|
file.isDirectory() ? "Directory" : "File"]);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e) {}
|
||||||
{
|
return mapped;
|
||||||
return [0, []];
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
try {
|
||||||
if (tail)
|
if (tail)
|
||||||
return [dir.length, buildLongestStartingSubstring(mapped, compl, true)];
|
return [dir.length, this.cached("file-" + dir, compl, generate, "filter", [true])];
|
||||||
else
|
else
|
||||||
return [0, buildLongestStartingSubstring(mapped, filter, true)];
|
return [0, this.cached("file", filter, generate, "filter", [true])];
|
||||||
|
}catch(e){liberator.dump(e)}
|
||||||
},
|
},
|
||||||
|
|
||||||
help: function (filter)
|
help: function (filter)
|
||||||
|
|||||||
@@ -1226,6 +1226,7 @@ liberator.ItemList = function (id) //{{{
|
|||||||
var container = iframe.parentNode;
|
var container = iframe.parentNode;
|
||||||
|
|
||||||
doc.body.id = id + "-content";
|
doc.body.id = id + "-content";
|
||||||
|
doc.body.appendChild(doc.createTextNode(""));
|
||||||
|
|
||||||
var completions = []; // a reference to the Array of completions
|
var completions = []; // a reference to the Array of completions
|
||||||
var startIndex = -1; // The index of the first displayed item
|
var startIndex = -1; // The index of the first displayed item
|
||||||
@@ -1316,7 +1317,6 @@ liberator.ItemList = function (id) //{{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// do a full refill of the list:
|
// do a full refill of the list:
|
||||||
doc.body.innerHTML = "";
|
|
||||||
|
|
||||||
XML.ignoreWhitespace = true;
|
XML.ignoreWhitespace = true;
|
||||||
let div = <div class="ex-command-output hl-Normal">
|
let div = <div class="ex-command-output hl-Normal">
|
||||||
@@ -1326,10 +1326,8 @@ liberator.ItemList = function (id) //{{{
|
|||||||
|
|
||||||
let tbody = div..tbody;
|
let tbody = div..tbody;
|
||||||
for (let i in liberator.util.range(offset, endIndex))
|
for (let i in liberator.util.range(offset, endIndex))
|
||||||
{
|
tbody.* += createRow.apply(null, completions[i]);
|
||||||
let elem = completions[i];
|
|
||||||
tbody.* += createRow(elem[0], elem[1], elem[2]);
|
|
||||||
}
|
|
||||||
div.* +=
|
div.* +=
|
||||||
<table>
|
<table>
|
||||||
{
|
{
|
||||||
@@ -1341,7 +1339,7 @@ liberator.ItemList = function (id) //{{{
|
|||||||
let dom = liberator.util.xmlToDom(div, doc);
|
let dom = liberator.util.xmlToDom(div, doc);
|
||||||
completionBody = dom.getElementsByTagName("tbody")[0];
|
completionBody = dom.getElementsByTagName("tbody")[0];
|
||||||
completionElements = completionBody.childNodes;
|
completionElements = completionBody.childNodes;
|
||||||
doc.body.appendChild(dom);
|
doc.body.replaceChild(dom, doc.body.firstChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
|
|||||||
Reference in New Issue
Block a user