Skip to content

Clipboard clears after paste even when the action was "copy" (should only clear on "move"/cut) #12

Description

@elspear

When using file manager's copy and paste (via context menu and or keyboard shortcuts), the internal clipboard is set to null immediately after pasting, regardless of whether the clipboard action was "copy" or "move"

So you can't copy a file and paste it into multiple folders without re-copying each time.

Where it happens:

case "paste":
  if (copyRef.current) {
    api.exec(
      copyRef.current.action === "copy" ? "copy-files" : "move-files",
      {
        ids: copyRef.current.ids,
        target: contextArg?.type === "folder" ? contextArg.id : path,
      }
    );
    copyRef.current = null;  // <-- clears clipboard unconditionally
  }
  break;

Suggested fix: only clear clipboard when action was cut/move

case "paste":
  if (copyRef.current) {
    api.exec(
      copyRef.current.action === "copy" ? "copy-files" : "move-files",
      {
        ids: copyRef.current.ids,
        target: contextArg?.type === "folder" ? contextArg.id : path,
      }
    );
    if (copyRef.current.action !== "copy") {
      copyRef.current = null;
    }
  }
  break;

version: 2.4.4

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions