Skip to content

Commit

Permalink
Fix duplicate LSP features appearing in multiroot workspaces (#2101)
Browse files Browse the repository at this point in the history
Fix duplicate LSP features
  • Loading branch information
andyw8 authored May 30, 2024
1 parent b8f17bf commit 5e29a6d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion vscode/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function collectClientOptions(
configuration: vscode.WorkspaceConfiguration,
workspaceFolder: vscode.WorkspaceFolder,
outputChannel: WorkspaceChannel,
ruby: Ruby,
): LanguageClientOptions {
const pullOn: "change" | "save" | "both" =
configuration.get("pullDiagnosticsOn")!;
Expand All @@ -103,8 +104,27 @@ function collectClientOptions(
const features: EnabledFeatures = configuration.get("enabledFeatures")!;
const enabledFeatures = Object.keys(features).filter((key) => features[key]);

const fsPath = workspaceFolder.uri.fsPath.replace(/\/$/, "");
const documentSelector = [
{
language: "ruby",
pattern: `${fsPath}/**/*`,
},
];

if (ruby.env.GEM_PATH) {
const parts = ruby.env.GEM_PATH.split(path.delimiter);

parts.forEach((gemPath) => {
documentSelector.push({
language: "ruby",
pattern: `${gemPath}/**/*`,
});
});
}

return {
documentSelector: [{ language: "ruby" }],
documentSelector,
workspaceFolder,
diagnosticCollectionName: LSP_NAME,
outputChannel,
Expand Down Expand Up @@ -149,6 +169,7 @@ export default class Client extends LanguageClient implements ClientInterface {
vscode.workspace.getConfiguration("rubyLsp"),
workspaceFolder,
outputChannel,
ruby,
),
);

Expand Down

0 comments on commit 5e29a6d

Please sign in to comment.