summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/src/core/completion.lua9
-rw-r--r--server/test/completion/init.lua4
2 files changed, 10 insertions, 3 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua
index 3d8a47e0..f3e811a1 100644
--- a/server/src/core/completion.lua
+++ b/server/src/core/completion.lua
@@ -399,11 +399,18 @@ local function searchEmmyKeyword(vm, source, word, callback)
end
local function searchEmmyClass(vm, source, word, callback)
+ local classes = {}
vm.emmyMgr:eachClass(function (class)
if matchKey(word, class:getName()) then
- callback(class:getName(), class:getSource(), CompletionItemKind.Class)
+ classes[#classes+1] = class
end
end)
+ table.sort(classes, function (a, b)
+ return a:getName() < b:getName()
+ end)
+ for _, class in ipairs(classes) do
+ callback(class:getName(), class:getSource(), CompletionItemKind.Class)
+ end
end
local function searchSource(vm, source, word, callback)
diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua
index 2b79aa4d..0857e8cb 100644
--- a/server/test/completion/init.lua
+++ b/server/test/completion/init.lua
@@ -831,11 +831,11 @@ TEST [[
]]
{
{
- label = 'abc',
+ label = 'abb',
kind = CompletionItemKind.Class,
},
{
- label = 'abb',
+ label = 'abc',
kind = CompletionItemKind.Class,
},
}