aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
authorAnmol Sethi <hi@nhooyr.io>2020-08-31 01:29:47 -0400
committerGitHub <noreply@github.com>2020-08-30 22:29:47 -0700
commit3229ba0cdef530fe7ab18326537118f88355e111 (patch)
treebdf13217cd9302ac59ac5c739fec9b394c7f0928 /runtime/lua/vim/lsp/util.lua
parentb3f5083b8dc6469e3becd37eb9deb01eb1c33f5d (diff)
downloadrneovim-3229ba0cdef530fe7ab18326537118f88355e111.tar.gz
rneovim-3229ba0cdef530fe7ab18326537118f88355e111.tar.bz2
rneovim-3229ba0cdef530fe7ab18326537118f88355e111.zip
lsp: Fix bad sortText comparison (#12485)
The spec indicates we have to fallback to comparing by label if sortText is falsy. Closes #12431
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r--runtime/lua/vim/lsp/util.lua7
1 files changed, 3 insertions, 4 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 3ec7311d65..cedb0b2824 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -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