From 3229ba0cdef530fe7ab18326537118f88355e111 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 31 Aug 2020 01:29:47 -0400 Subject: lsp: Fix bad sortText comparison (#12485) The spec indicates we have to fallback to comparing by label if sortText is falsy. Closes #12431 --- runtime/lua/vim/lsp/util.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'runtime/lua/vim') 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 -- cgit