From 8973916a3d015d65a8c4614e141f4270a713cf33 Mon Sep 17 00:00:00 2001 From: Matthew Wilding Date: Wed, 24 Dec 2025 00:33:14 +0800 Subject: fix(roslyn_ls): guess root_dir for decompiled code #4257 Try to guess the root_dir by getting the lsp client from the previous buffer. --- lsp/roslyn_ls.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lsp/roslyn_ls.lua b/lsp/roslyn_ls.lua index 0cc7a7a2..6bc9cad1 100644 --- a/lsp/roslyn_ls.lua +++ b/lsp/roslyn_ls.lua @@ -160,9 +160,14 @@ return { cb(root_dir) end else - local existing_client = vim.lsp.get_clients({ name = 'roslyn_ls' })[1] - if existing_client and existing_client.config.root_dir then - cb(existing_client.config.root_dir) + -- Decompiled code (example: "/tmp/MetadataAsSource/f2bfba/DecompilationMetadataAsSourceFileProvider/d5782a/Console.cs") + local prev_buf = vim.fn.bufnr('#') + local client = vim.lsp.get_clients({ + name = 'roslyn_ls', + bufnr = prev_buf ~= 1 and prev_buf or nil, + })[1] + if client then + cb(client.config.root_dir) end end end, -- cgit v1.2.3-70-g09d2