mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-04 10:12:47 +00:00
tab: Fix copy wrong relative path for tab (#19206)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Linux) Build Remote Server (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Linux) Build Remote Server (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
Closes #19204 Release Notes: - Fixed relative paths copied incorrectly from tabs ([#19204](https://github.com/zed-industries/zed/issues/19204))
This commit is contained in:
parent
41ba4178fc
commit
62de03f286
1 changed files with 16 additions and 18 deletions
|
@ -1747,17 +1747,6 @@ impl Pane {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn copy_relative_path(&mut self, _: &CopyRelativePath, cx: &mut ViewContext<Self>) {
|
|
||||||
if let Some(clipboard_text) = self
|
|
||||||
.active_item()
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|entry| entry.project_path(cx))
|
|
||||||
.map(|p| p.path.to_string_lossy().to_string())
|
|
||||||
{
|
|
||||||
cx.write_to_clipboard(ClipboardItem::new_string(clipboard_text));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn icon_color(selected: bool) -> Color {
|
pub fn icon_color(selected: bool) -> Color {
|
||||||
if selected {
|
if selected {
|
||||||
Color::Default
|
Color::Default
|
||||||
|
@ -2102,6 +2091,11 @@ impl Pane {
|
||||||
let parent_abs_path = entry_abs_path
|
let parent_abs_path = entry_abs_path
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.and_then(|abs_path| Some(abs_path.parent()?.to_path_buf()));
|
.and_then(|abs_path| Some(abs_path.parent()?.to_path_buf()));
|
||||||
|
let relative_path = pane
|
||||||
|
.read(cx)
|
||||||
|
.item_for_entry(entry, cx)
|
||||||
|
.and_then(|item| item.project_path(cx))
|
||||||
|
.map(|project_path| project_path.path);
|
||||||
|
|
||||||
let entry_id = entry.to_proto();
|
let entry_id = entry.to_proto();
|
||||||
menu = menu
|
menu = menu
|
||||||
|
@ -2117,13 +2111,17 @@ impl Pane {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.entry(
|
.when_some(relative_path, |menu, relative_path| {
|
||||||
"Copy Relative Path",
|
menu.entry(
|
||||||
Some(Box::new(CopyRelativePath)),
|
"Copy Relative Path",
|
||||||
cx.handler_for(&pane, move |pane, cx| {
|
Some(Box::new(CopyRelativePath)),
|
||||||
pane.copy_relative_path(&CopyRelativePath, cx);
|
cx.handler_for(&pane, move |_, cx| {
|
||||||
}),
|
cx.write_to_clipboard(ClipboardItem::new_string(
|
||||||
)
|
relative_path.to_string_lossy().to_string(),
|
||||||
|
));
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
.map(pin_tab_entries)
|
.map(pin_tab_entries)
|
||||||
.separator()
|
.separator()
|
||||||
.entry(
|
.entry(
|
||||||
|
|
Loading…
Reference in a new issue