diff options
author | Anmol Sethi <hi@nhooyr.io> | 2020-08-31 01:29:47 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-30 22:29:47 -0700 |
commit | 3229ba0cdef530fe7ab18326537118f88355e111 (patch) | |
tree | bdf13217cd9302ac59ac5c739fec9b394c7f0928 /runtime/lua/vim/lsp/util.lua | |
parent | b3f5083b8dc6469e3becd37eb9deb01eb1c33f5d (diff) | |
download | rneovim-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.lua | 7 |
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 |