From 055555d81a6b4e8075c11c53c2a769fdfdbe52d2 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Tue, 12 Aug 2008 17:47:59 +0000 Subject: [PATCH] sort filename completions --- content/completion.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/content/completion.js b/content/completion.js index e55a1696..03c7ca1c 100644 --- a/content/completion.js +++ b/content/completion.js @@ -297,7 +297,6 @@ liberator.Completion = function () //{{{ }, // TODO: support file:// and \ or / path separators on both platforms - // TODO: sort directories first // if "tail" is true, only return names without any directory components file: function (filter, tail) { @@ -314,7 +313,11 @@ liberator.Completion = function () //{{{ { files = liberator.io.readDirectory(dir); mapped = files.map(function (file) { - return [[tail ? file.leafName : (dir + file.leafName)], file.isDirectory() ? "Directory" : "File"]; + return [tail ? file.leafName : (dir + file.leafName), file.isDirectory() ? "Directory" : "File"]; + }).sort(function (a, b) { + return a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0 + }).sort(function (a, b) { + return a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0 }); } catch (e)