From e40ad73be127b3353ec5fe14e05a8097c6fc734e Mon Sep 17 00:00:00 2001 From: k-86 Date: Sun, 2 Jun 2024 20:45:05 +0900 Subject: [PATCH] Fix inconsistent return value of request function --- denops/@ddc-sources/lsp.ts | 4 ++-- lua/ddc_source_lsp/internal.lua | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/denops/@ddc-sources/lsp.ts b/denops/@ddc-sources/lsp.ts index 3e0cda7..460b910 100644 --- a/denops/@ddc-sources/lsp.ts +++ b/denops/@ddc-sources/lsp.ts @@ -260,9 +260,9 @@ export class Source extends BaseSource { lspItem, { client, timeout: 1000, sync: true, bufnr: bufnr }, ); - const { result } = u.ensure( + const result = u.ensure( response, - is.ObjectOf({ result: is.ObjectOf({ label: is.String }) }), + is.ObjectOf({ label: is.String }), ); return result as LSP.CompletionItem; } catch { diff --git a/lua/ddc_source_lsp/internal.lua b/lua/ddc_source_lsp/internal.lua index e52ad03..5f5bbe8 100644 --- a/lua/ddc_source_lsp/internal.lua +++ b/lua/ddc_source_lsp/internal.lua @@ -68,7 +68,10 @@ end function M.request_sync(clientId, method, params, opts) local client = vim.lsp.get_client_by_id(clientId) if client then - return client.request_sync(method, normalize(params), opts.timeout, opts.bufnr or 0) + local resp = client.request_sync(method, normalize(params), opts.timeout, opts.bufnr or 0) + if resp and resp.err == nil and resp.result then + return resp.result + end end end