Skip to content

Commit

Permalink
Ensure default gem path is also in document selector
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Oct 18, 2024
1 parent ef1a27d commit 8eb9f41
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions vscode/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,27 @@ function collectClientOptions(
});
}

// Because of how default gems are installed, the entry in the `GEM_PATH` is actually not exactly where the files
// are located. With the regex, we are correcting the default gem path from this (where the files are not located)
// /opt/rubies/3.3.1/lib/ruby/gems/3.3.0
//
// to this (where the files are actually stored)
// /opt/rubies/3.3.1/lib/ruby/3.3.0
ruby.gemPath.forEach((gemPath) => {
documentSelector.push({
language: "ruby",
pattern: `${gemPath.replace(/lib\/ruby\/gems\/(?=\d)/, "lib/ruby/")}/**/*`,
pattern: `${gemPath}/**/*`,
});

// Because of how default gems are installed, the gemPath location is actually not exactly where the files are
// located. With the regex, we are correcting the default gem path from this (where the files are not located)
// /opt/rubies/3.3.1/lib/ruby/gems/3.3.0
//
// to this (where the files are actually stored)
// /opt/rubies/3.3.1/lib/ruby/3.3.0
//
// Notice that we still need to add the regular path to the selector because some version managers will install gems
// under the non-corrected path
if (/lib\/ruby\/gems\/(?=\d)/.test(gemPath)) {
documentSelector.push({
language: "ruby",
pattern: `${gemPath.replace(/lib\/ruby\/gems\/(?=\d)/, "lib/ruby/")}/**/*`,
});
}
});

// This is a temporary solution as an escape hatch for users who cannot upgrade the `ruby-lsp` gem to a version that
Expand Down

0 comments on commit 8eb9f41

Please sign in to comment.