-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 copy_path_with_file_number shortcut #25029
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Where is the |
@notpeter suggestion |
@pawurb : Since Example, I don't know if it works: pub enum PathType {
Absolute,
Relative,
}
pub fn copy_path_with_line_number(
&mut self,
path_type: PathType,
_: &zed_actions::workspace::CopyPathWithLineNumber,
_window: &mut Window,
cx: &mut Context<Self>,
) {
let path_target = match path_type {
PathType::Absolute => self.target_file_abs_path(cx),
PathType::Relative => self.target_file_path(cx),
};
if let Some(path) = path_target {
if let Some(path) = path.to_str() {
let selection = self.selections.newest::<Point>(cx).start.row + 1;
let path_with_line_number = format!("{}:{}", path, selection);
cx.write_to_clipboard(ClipboardItem::new_string(path_with_line_number));
}
}
}
self.copy_path_with_line_number(PathType::Absolute, action, window, cx); //Absolute
self.copy_path_with_line_number(PathType::Relative, action, window, cx); //Relative |
@Angelk90 I don't think we can change the method params. I've followed the convention from |
@pawurb : |
I've refactored calls to remove repetition. |
Thank you for the PR! There is already an action that does this, It produces output like what you are expecting:
|
Hi. It's my first time contributing so sorry in advance if I'm mixing something up.
This PR adds shortcuts enabling copying file path (absolute and relative) with line number appended, in the following format:
I use this feature constantly when working in VS code to run only a specific test case with Rspec (other testing frameworks also support this behaviour).
I've also noticed that there is
editor::CopyPermalinkToLine
shortcut, so a local path with line number should probably also be supported.Release Notes:
CopyPathWithLineNumber
andCopyRelativePathWithLineNumber
shortcuts