zed icon indicating copy to clipboard operation
zed copied to clipboard

project_panel: Add support for copy/paste between different worktree

Open CharlesChen0823 opened this issue 1 year ago • 8 comments

close #5362

replace #14940 , because my mistake operator on branch.

Release Notes:

  • N/A

CharlesChen0823 avatar Jul 29 '24 02:07 CharlesChen0823

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?

CharlesChen0823 avatar Jul 29 '24 06:07 CharlesChen0823

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 avatar Jul 29 '24 06:07 SomeoneToIgnore

@SomeoneToIgnore Want to known, if current modify is acceptable? Adding remote support copy_relative_entry will expect?

Any suggestion?

CharlesChen0823 avatar Jul 30 '24 08:07 CharlesChen0823

@SomeoneToIgnore I do some clarify, why you confused, I add more code here and another parameter in worktree::copy_entry.

  1. origin api semantic is copy old entry(entry_id) to new entry which using new_path to 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>>>
  1. worktree don't known anythings which relative worktree, that is why don't support copy/paste between different worktree.
  2. if we want support it, i need known the entry path from different worktree, which using relative_path to 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>>> 
  1. the copy_entry semantic has been modify,

    • in same worktree, keep origin semantic.
    • in different worktree, the entry_id is not represent old entry, which represent the entry in target worktree, and relative_path is calculate relative entry_id, the new_path semantic is not modify.
  2. currently, the whole function has work as expect, but the code become unread, I need spend more time to simple the code.

  3. 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.

CharlesChen0823 avatar Aug 01 '24 07:08 CharlesChen0823

@SomeoneToIgnore do you have times to review?

CharlesChen0823 avatar Aug 02 '24 06:08 CharlesChen0823

If I'm not reviewing yet, can you guess if I have time or not?

SomeoneToIgnore avatar Aug 02 '24 07:08 SomeoneToIgnore

If I'm not reviewing yet, can you guess if I have time or not?

Sorry for my mistake.

CharlesChen0823 avatar Aug 02 '24 08:08 CharlesChen0823

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.

SomeoneToIgnore avatar Aug 06 '24 18:08 SomeoneToIgnore

I have done, ready for review agian.

CharlesChen0823 avatar Aug 28 '24 06:08 CharlesChen0823

Thank you, I learn a lot from this PR, explaining what i do using words is important for review.

CharlesChen0823 avatar Aug 28 '24 08:08 CharlesChen0823