Skip to content

fix: allow copy-paste in same folder with auto-rename - #5139

Merged
Jocs merged 3 commits into
marktext:developfrom
rkristelijn:fix/paste-same-folder
Sep 2, 2026
Merged

Jocs merged 3 commits into
marktext:developfrom
rkristelijn:fix/paste-same-folder

Conversation

@rkristelijn

Copy link
Copy Markdown
Contributor

Closes #5138

Problem

Copy-paste in the sidebar's same folder shows 'Source and destination must not be the same' — blocking a valid operation.

Fix

When pasting a copied file into the same directory, generate a unique name:

  • file.md → file (copy).md
  • If exists: file (copy 2).md, etc.

Cut-paste in the same folder remains blocked (it's a no-op).

Changes

  • packages/desktop/src/renderer/src/store/project.ts: Make paste handler async, check cb.type === 'cut' before blocking, generate unique dest path using pathExists() loop.

Testing

  • Tested on Linux Mint 22.3 with MarkText develop branch

When pasting a copied file into the same directory, generate a unique
name (e.g. 'file (copy).md', 'file (copy 2).md') instead of blocking
with 'Source and destination must not be the same.'

Cut-paste in the same folder is still blocked (no-op).

Closes marktext#5138
@rkristelijn
rkristelijn force-pushed the fix/paste-same-folder branch from 38d1728 to 07b4205 Compare August 16, 2026 12:58
@Jocs
Jocs merged commit 9b43560 into marktext:develop Sep 2, 2026
14 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: copy-paste in same folder fails with 'Source and destination must not be the same'

2 participants