ionide-vscode-fsharp icon indicating copy to clipboard operation
ionide-vscode-fsharp copied to clipboard

Improve UX regarding adding files in new (nonexistent) folders

Open baronfel opened this issue 2 years ago • 2 comments

Discussed in https://github.com/ionide/ionide-vscode-fsharp/discussions/1639

Originally posted by inputusernamehere November 20, 2021 Thank you for your work on Ionide! I have a minor improvement suggestion:

So right now it's possible to create a new folder in the regular file explorer, then switch to the F#/Ionide view, and create a new file in that folder. Let's say I call the folder new_folder, and input new_folder/new_file.fs when I create a new file. It will work as expected.

However if I do not create the folder my self first, I get hit with this error:

Error running command fsharp.explorer.addFile: Could not find a part of the path 'd:\code\ionide-folder-test\new_folder\new_file.fs'.. This is likely caused by the extension that contributes fsharp.explorer.addFile.

I think it would be smoother if Ionide just created the new folder for me.

This is a good first issue. The code implementing this is over in fsautocomplete, specifically the three File.Open calls on the three highlighted methods. I think there should be a helper that parses the passed in file name and creates any necessary directories that are included in the file name.

@inputusernamehere - would you be interested in submitting a PR to fix these? I'd be happy to walk you through the process.

baronfel avatar Nov 21 '21 04:11 baronfel

I appreciate you investigating this issue and outlining what needs to be done. I'll be pretty busy for the forseeable future so if someone else wants to give it a go you don't have to wait for me!

inputusernamehere avatar Nov 29 '21 17:11 inputusernamehere

I've made a little progress on this.

jcmrva avatar Dec 17 '21 16:12 jcmrva

This seems to be work for me. I added a new file from the solution explore named foo/bar/baz.fs and it recursively created the directories that were needed as well as the file.

kevinbarabash avatar Oct 18 '23 01:10 kevinbarabash

Oh great! I'll close this one, then.

baronfel avatar Oct 18 '23 01:10 baronfel