diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-24 19:59:37 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-24 19:59:37 +0800 |
commit | 6daad9f42b8c3003a538a0667e5242536aa95eac (patch) | |
tree | dedacbeffcd592fdaf565b82643dd86208463fed /server | |
parent | db2de7238fb92269b7ad6aca8a35f82e01eaa126 (diff) | |
download | lua-language-server-6daad9f42b8c3003a538a0667e5242536aa95eac.zip |
保证顺序
Diffstat (limited to 'server')
-rw-r--r-- | server/src/core/completion.lua | 9 | ||||
-rw-r--r-- | server/test/completion/init.lua | 4 |
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, }, } |