lsp: Fix bad sortText comparison (#12485)

The spec indicates we have to fallback to comparing by label
if sortText is falsy.

Closes #12431
This commit is contained in:
Anmol Sethi
2020-08-31 01:29:47 -04:00
committed by GitHub
parent b3f5083b8d
commit 3229ba0cde
2 changed files with 23 additions and 24 deletions

View File

@@ -299,10 +299,9 @@ end
---
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion
local function sort_completion_items(items)
if items[1] and items[1].sortText then
table.sort(items, function(a, b) return a.sortText < b.sortText
end)
end
table.sort(items, function(a, b)
return (a.sortText or a.label) < (b.sortText or b.label)
end)
end
--@private