Creating a new file with clipboard contents
Description
This WIP PR does the following:
- A new file can be created with the contents on the clipboard using menu action.
- PTAL and LMK if I can proceed to implement this with shortcut key.
Related Issue
- Addresses #1970
Screenshot
https://github.com/user-attachments/assets/79d42cdf-d88d-46ff-b8bd-11c4ae640333
Potential Bugs to fix
- New file not being opened in new tab.
@Syrux64 looks great so far. Yeah go ahead and implement the keyboard shortcut for this. When the navigator is in focus and cmd V is pressed, it should create the file inside the selected folder. If a file is selected, the newly created file should be a sibling to the selected file both having the same parent folder.
@austincondiff Sure! Thanks for the heads up.
This looks good so far! If you want to merge this before finishing the key command that would be fine.
My one suggestion is you can remove your new file method and just add a new contents parameter to the addFile method, with a default value of nil. That should make it so we don't have multiple addFile-type methods which could get messy.
func addFile(
fileName: String,
toFile file: CEWorkspaceFile,
useExtension: String? = nil,
contents: Data? = nil // Shouldn't break any existing calls, reduces duplicate code.
) throws -> CEWorkspaceFile {
@thecoolwinter thanks for pointing that out 👍, I'll get that fixed and raise a PR once I've implemented the shortcut.
Where are we on this? I'd love to get this merged soon. Really great work here!
Sorry for the long delay. So far the menu action works fine. I tried adding shortcut key via NSItem's 'Key' attribute. But all I hear is a tick sound. Can you guys suggest any other way to accomplish this? Or we could merge this PR without a shortcut key feature.
No worries, I had lost track of this PR. I've got a commit that fixes the issue you found with the key-commands. I'm going to try and globally fix the race error you found with renaming files, as it's an issue elsewhere. I also went ahead and changed the key command to ⌘V to match Xcode. Thank you for getting this done and sorry for the wait!!
@allcontributors please add @Syrux64 for code
Thanks y'all for letting me contribute to this project. I learnt a lot <33