Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Open Cargo.toml" action #6519

Merged
merged 1 commit into from
Nov 13, 2020

Conversation

p3achyjr
Copy link

What is it?

This adds an "open cargo.toml" action from the vscode shell, resolves #6462

Test

Ran cargo xtask install --server and cargo xtask install --client, then Developer: Reload Window.

image

When clicked:

image

.gitignore Outdated Show resolved Hide resolved
if !cargo_toml_path.exists() {
return Ok(None);
}
let cargo_toml_url = to_proto::url_from_abs_path(&cargo_toml_path.clone());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let cargo_toml_url = to_proto::url_from_abs_path(&cargo_toml_path.clone());
let cargo_toml_url = to_proto::url_from_abs_path(&cargo_toml_path);

}
let cargo_toml_url = to_proto::url_from_abs_path(&cargo_toml_path.clone());
let cargo_toml_location =
Location::new(cargo_toml_url.clone(), Range::new(Position::new(0, 0), Position::new(0, 0)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Location::new(cargo_toml_url.clone(), Range::new(Position::new(0, 0), Position::new(0, 0)));
Location::new(cargo_toml_url, Range::default();

(not sure about the Default impl)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is the lsp_types::GotoDefinitionResponse the right type to return?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lnicola what else should I return? GotoDefinitionResponse seems to be used to jump to a specific part of a file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my second time contributing to Rust-Analyzer so it might take me a bit to learn the wheels :|

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries. I was thinking that a custom type or an URL would be better, since we're navigating to a file, not a location.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could maybe use TextDocumentIdentifier and hardcode the location on the client? But maybe in the future we want to open specific parts of the Cargo.toml, and we should keep the client logic as simple as possible, right?

@p3achyjr p3achyjr closed this Nov 10, 2020
@p3achyjr p3achyjr reopened this Nov 10, 2020
@matklad
Copy link
Member

matklad commented Nov 12, 2020

The changes look good to me, but there's still a bit of a mess in history. Lets try to clean up.

@p3achyjr I think the following steps should help:

  • run git status to make sure you don't have uncommited files
  • run git log to make sure that the latest commit has the e1c953c hash (to make sure state you have locally and state we see on github are the same)
  • run git reset --soft 111cc34c8f181315f4dcfa85c616d54d47eff0b9. This should reset the branch state to the commit on the base branch, from which you started your hacking. The --soft flag however preserves your changes (state of the files on the file system) intact. This would be a good place to run git status and git log again to get a sense of the state of the things.
  • run git add . && git commit -m 'add open Cargo.toml action' to commit all your changes as a single commit (but make sure there's no .DS_store file)
  • run git push --force-with-lease to push the changes to github.

@p3achyjr
Copy link
Author

Thanks @matklad. I was running into issues where whenever I ran git commit --amend, I could not push my changes because I would have to run git pull first. This was further complicated by how whenever I ran git pull, I would get merge conflicts.

The steps worked though! Will keep this in my back pocket :)

@matklad
Copy link
Member

matklad commented Nov 13, 2020

Hm, there's still something wrong with history (.DS_Store file is still there), but I'll fix that up locally!

bors r+

Thanks!

@bors
Copy link
Contributor

bors bot commented Nov 13, 2020

@bors bors bot merged commit b0ad492 into rust-lang:master Nov 13, 2020
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.

Add "Open Cargo.toml" action
3 participants