From 966e763dc051f779d1e1240ead4d869083035571 Mon Sep 17 00:00:00 2001 From: Xuyuan Pang Date: Tue, 8 Aug 2023 23:25:10 +0800 Subject: [PATCH] fix: ssr request --- lua/rust-tools/ssr.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lua/rust-tools/ssr.lua b/lua/rust-tools/ssr.lua index 07f710f..ae44a94 100644 --- a/lua/rust-tools/ssr.lua +++ b/lua/rust-tools/ssr.lua @@ -10,19 +10,27 @@ local function get_opts(query) return opts end -local function handler(err, result) +local function handler(err, result, ctx) if err then error("Could not execute request to server: " .. err.message) return end - vim.lsp.util.apply_workspace_edit(result) + local client = vim.lsp.get_client_by_id(ctx.client_id) + if not client then + return + end + + vim.lsp.util.apply_workspace_edit(result, client.offset_encoding) end function M.ssr(query) if not query then vim.ui.input({ prompt = "Enter query: " }, function(input) query = input + if query then + M.ssr(query) + end end) end