Skip to content

fix: reuse of LSP client if the root dir and config name has not changed#378

Closed
AntoineGS wants to merge 9 commits intozbirenbaum:masterfrom
AntoineGS:fix_duplicated_clients
Closed

fix: reuse of LSP client if the root dir and config name has not changed#378
AntoineGS wants to merge 9 commits intozbirenbaum:masterfrom
AntoineGS:fix_duplicated_clients

Conversation

@AntoineGS
Copy link
Copy Markdown
Collaborator

Prevents scenarios where a second client could be created and cause and caught in store_client_id. May fix #359

@AntoineGS AntoineGS force-pushed the fix_duplicated_clients branch from bdda0ea to 522b62a Compare March 15, 2025 23:16
Prevents scenarios where a second client could be created and cause and caught in store_client_id.
May fix zbirenbaum#359
@AntoineGS AntoineGS force-pushed the fix_duplicated_clients branch from 522b62a to 948d589 Compare March 15, 2025 23:18
@AntoineGS AntoineGS marked this pull request as draft March 15, 2025 23:25
@AntoineGS
Copy link
Copy Markdown
Collaborator Author

Turns out lsp.lua wants one of the workspace_folders to match the root_dir or it assumes a new workspace.

--- @param client vim.lsp.Client
--- @param config vim.lsp.ClientConfig
--- @return boolean
local function reuse_client_default(client, config)
  if client.name ~= config.name then
    return false
  end

  if config.root_dir then
    for _, dir in ipairs(client.workspace_folders or {}) do
      -- note: do not need to check client.root_dir since that should be client.workspace_folders[1]
      if config.root_dir == dir.name then
        return true
      end
    end
  end

  -- TODO(lewis6991): also check config.workspace_folders

  return false
end

I am closing this as this is fixed in the workspace implementation.

@AntoineGS AntoineGS closed this Mar 16, 2025
@AntoineGS AntoineGS deleted the fix_duplicated_clients branch March 16, 2025 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copilot stops attaching to buffers at some point

1 participant