zed icon indicating copy to clipboard operation
zed copied to clipboard

Create a new directory when a new file ends with `/`

Open 80avin opened this issue 1 year ago • 4 comments

This feature is present in almost all editors but in zed, doing so crashes the editor.

Release Notes:

  • When creating new file via project panel, a filename ending with / creates a directory.

80avin avatar May 18 '24 15:05 80avin

We require contributors to sign our Contributor License Agreement, and we don't have @80avin on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

cla-bot[bot] avatar May 18 '24 15:05 cla-bot[bot]

@cla-bot check

80avin avatar May 18 '24 15:05 80avin

The cla-bot has been summoned, and re-checked this pull request!

cla-bot[bot] avatar May 18 '24 15:05 cla-bot[bot]

Worth noting vscode let's you create nested folders and optionally a file at the end, things like:

  • foo/bar
  • foo/bar/
  • foo/bar/baz and so on, which is a lot more complicated because it's ok for some prefix of the path to already exist. I think I actually found a vscode bug around this behavior, with in the folder foo, it won't let you create the file foo: image But with the folder foo and the file bar inside it, it won't show anything wrong creating foo/bar, but will fail to do so: image Could always be added in future prs of course.

bbb651 avatar May 19 '24 20:05 bbb651

I think I actually found a vscode bug around this behavior, with in the folder foo, it won't let you create the file foo: image

I think you are creating the file at same level as foo directory that's why this issue is coming. To create a file inside a directory, you have to select the directory first. It'll look like this image

But with the folder foo and the file bar inside it, it won't show anything wrong creating foo/bar, but will fail to do so:

Noticed that in zed, even without this PR, it fails silently. We may need error for that but that can be separate PR.

80avin avatar May 23 '24 19:05 80avin

I think you are creating the file at same level as foo directory that's why this issue is coming. To create a file inside a directory, you have to select the directory first.

It was intentional, I gave it as an example of what trying to create a duplicate file should do, rather than letting you create the file and get the filesystem error

bbb651 avatar May 26 '24 01:05 bbb651