# Fix copying folders into themselves to create copies \(\#8484\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/7acd6879db8a9524ef938aeaaa683598bb1f47bc)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 7acd6879db8a9524ef938aeaaa683598bb1f47bc

Requested commit: 7acd6879db8a9524ef938aeaaa683598bb1f47bc

Commit: 7acd6879db8a9524ef938aeaaa683598bb1f47bc

Tree: 36dbad632a414265f30eaa53932be54f61e47153

Author: Thorsten Ball

Committer: GitHub

## Message

```
Fix copying folders into themselves to create copies (#8484)

This fixes #7314 and #7778.

The problem was copying a folder into itself, which is actually quite a
common operation in macOS's `Finder.app`: you select a folder, hit
`cmd-c` and `cmd-v` and have a copy. That's also how it works in VS
Code.

The fix here is to detect when we're copying a folder into itself and
treating it like we're copying a file into itself: we don't want to copy
into the target, we want to copy into the folder one level higher up,
which will then automatically add a ` copy` to the end of the name.

Release Notes:

- Fixed ability to copy folders into themselves by selecting them in
project panel and hitting `copy` and `paste`. Instead of endless
recursion, a copy of the folder is now created.
([#7314](https://github.com/zed-industries/zed/issues/7314)).

Demo:



https://github.com/zed-industries/zed/assets/1185253/2141310a-991d-491d-8498-eb766275a1f5
```

## Parents

- [7cbdea2ca04355b8cffbb76320934785c167df7e](https://git.cafe/gitcafe/zed/commit/7cbdea2ca04355b8cffbb76320934785c167df7e?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/7acd6879db8a9524ef938aeaaa683598bb1f47bc?format=markdown)
