diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-08-11 10:42:30 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-08-11 10:42:30 +0800 |
commit | e2cdda52b7239c180f9f3a8f5090aa3f2dd7e9aa (patch) | |
tree | 0e138569faba10abcb5058e6db5ab1822449f805 | |
parent | 52c24177d3df9520a244e22b8dbf3c1b5bb323dc (diff) | |
download | lua-language-server-e2cdda52b7239c180f9f3a8f5090aa3f2dd7e9aa.zip |
sort pairs
-rw-r--r-- | script/core/completion.lua | 6 | ||||
-rw-r--r-- | test/completion/init.lua | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua index 63492689..f6556233 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -287,7 +287,7 @@ end local function checkLocal(ast, word, offset, results) local locals = guide.getVisibleLocals(ast.ast, offset) - for name, source in pairs(locals) do + for name, source in util.sortPairs(locals) do if isSameSource(ast, source, offset) then goto CONTINUE end @@ -1673,7 +1673,7 @@ local function tryLuaDocBySource(ast, offset, source, results) end return true elseif source.type == 'doc.diagnostic.name' then - for name in pairs(define.DiagnosticDefaultSeverity) do + for name in util.sortPairs(define.DiagnosticDefaultSeverity) do if matchKey(source[1], name) then results[#results+1] = { label = name, @@ -1758,7 +1758,7 @@ local function tryLuaDocByErr(ast, offset, err, docState, results) } end elseif err.type == 'LUADOC_MISS_DIAG_NAME' then - for name in pairs(define.DiagnosticDefaultSeverity) do + for name in util.sortPairs(define.DiagnosticDefaultSeverity) do results[#results+1] = { label = name, kind = define.CompletionItemKind.Value, diff --git a/test/completion/init.lua b/test/completion/init.lua index d975fa7e..419bde82 100644 --- a/test/completion/init.lua +++ b/test/completion/init.lua @@ -131,11 +131,11 @@ zabcde$ ]] { { - label = 'zabcdefg', + label = 'zabcde', kind = define.CompletionItemKind.Variable, }, { - label = 'zabcde', + label = 'zabcdefg', kind = define.CompletionItemKind.Variable, }, } @@ -829,11 +829,11 @@ xxxx$ ]] { { - label = 'xxxx', + label = 'XXXX', kind = define.CompletionItemKind.Variable, }, { - label = 'XXXX', + label = 'xxxx', kind = define.CompletionItemKind.Variable, }, } |