Skip to content

Commit

Permalink
Bazel: Fix relative go to definition in external repositories (#103)
Browse files Browse the repository at this point in the history
Summary:
The resolve root was calculated incorrectly for relative load statements in external repositories. Instead of removing the file's path relative to the external repository, it only kept this part. For example if the current file is `$(bazel info output_base)/external/foo/bar/BUILD`, it would compute the resolve root as `bar/BUILD`, whereas it needs to be `$(bazel info output_base)/external/foo`.

Pull Request resolved: #103

Reviewed By: stepancheg

Differential Revision: D52887182

Pulled By: ndmitchell

fbshipit-source-id: 3025ae7be81a85976f2e250c104de7163db6a6a5
  • Loading branch information
cameron-martin authored and facebook-github-bot committed Jan 19, 2024
1 parent 30f6eea commit c696737
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions starlark_bin/bin/bazel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,8 @@ impl BazelContext {
// system information to check if we're in a known remote repository, and what the
// root is. Fall back to the `workspace_root` otherwise.
("", LspUrl::File(current_file)) => {
if let Some((_, remote_repository_root)) =
self.get_repository_for_path(current_file)
{
Some(Cow::Borrowed(remote_repository_root))
if let Some((repository_name, _)) = self.get_repository_for_path(current_file) {
self.get_repository_path(&repository_name).map(Cow::Owned)
} else {
workspace_root.map(Cow::Borrowed)
}
Expand Down

0 comments on commit c696737

Please sign in to comment.