project_panel: Add support for copy/paste between different worktree
close #5362
replace #14940 , because my mistake operator on branch.
Release Notes:
- N/A
I would expect an extra function/method to calculate a relative path of a ClipboardItem in a specific worktree that gets the operation (action invocation via cmd-v or other jkeys, right click, etc.)
@SomeoneToIgnore current, worktree only have one copy_external_entries api support copy different worktree, which is using in project_panel::drop_external_files. Writing an similar function for support copy relatvie path, is it your expecting?
Yes, or if you insist it's almost the same, I'd extract the common part and/or rename it into the "copy_external_files" or something.
@SomeoneToIgnore Want to known, if current modify is acceptable? Adding remote support copy_relative_entry will expect?
Any suggestion?
@SomeoneToIgnore I do some clarify, why you confused, I add more code here and another parameter in worktree::copy_entry.
- origin api semantic is copy old entry(
entry_id) to new entry which usingnew_pathto represent it in current worktree,
fn copy_entry(
&self,
entry_id: ProjectEntryId,
new_path: impl Into<Arc<Path>>,
cx: &mut ModelContext<Worktree>,
) -> Task<Result<Option<Entry>>>
- worktree don't known anythings which relative worktree, that is why don't support copy/paste between different worktree.
- if we want support it, i need known the entry path from different worktree, which using
relative_pathto get, so I modify the api to
fn copy_entry(
&self,
entry_id: ProjectEntryId,
relative_path: Option<impl Into<Arc<Path>>>,
new_path: impl Into<Arc<Path>>,
cx: &mut ModelContext<Worktree>,
) -> Task<Result<Option<Entry>>>
-
the
copy_entrysemantic has been modify,- in same worktree, keep origin semantic.
- in different worktree, the
entry_idis not represent old entry, which represent the entry in target worktree, andrelative_pathis calculate relativeentry_id, thenew_pathsemantic is not modify.
-
currently, the whole function has work as expect, but the code become unread, I need spend more time to simple the code.
-
support cut/copy paste the worktree root will not do it current pr, and I also check the behaviour in VSCode, which also not support.
@SomeoneToIgnore do you have times to review?
If I'm not reviewing yet, can you guess if I have time or not?
If I'm not reviewing yet, can you guess if I have time or not?
Sorry for my mistake.
Sorry, I am away for this week also, and expect to look at the PR early next week. Please ping anybody else if you want the review faster.
I have done, ready for review agian.
Thank you, I learn a lot from this PR, explaining what i do using words is important for review.