Skip to content

Creating a new file with clipboard contents #1995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Syrux64
Copy link
Contributor

@Syrux64 Syrux64 commented Feb 23, 2025

Description

  • 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

Screenshot

REC-2025022334437.PM.mp4

Potential Bugs to fix

  • New file not being opened in new tab.

@Syrux64 Syrux64 changed the title WIP PR for Creating a file with copied contents Creating a new file with clipboard contents Feb 23, 2025
@austincondiff
Copy link
Collaborator

@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.

@Syrux64
Copy link
Contributor Author

Syrux64 commented Feb 24, 2025

@austincondiff Sure! Thanks for the heads up.

@thecoolwinter
Copy link
Collaborator

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 {

@Syrux64
Copy link
Contributor Author

Syrux64 commented Mar 6, 2025

@thecoolwinter thanks for pointing that out 👍, I'll get that fixed and raise a PR once I've implemented the shortcut.

@austincondiff
Copy link
Collaborator

Where are we on this? I'd love to get this merged soon. Really great work here!

@Syrux64
Copy link
Contributor Author

Syrux64 commented May 25, 2025

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.

@Syrux64 Syrux64 marked this pull request as ready for review May 31, 2025 13:02
@thecoolwinter
Copy link
Collaborator

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!!

tom-ludwig
tom-ludwig previously approved these changes Jun 11, 2025
0xWDG
0xWDG previously approved these changes Jun 11, 2025
@thecoolwinter thecoolwinter dismissed stale reviews from 0xWDG and tom-ludwig via c8f7fa1 June 11, 2025 15:07
@thecoolwinter thecoolwinter merged commit 277503e into CodeEditApp:main Jun 11, 2025
2 checks passed
@thecoolwinter
Copy link
Collaborator

@allcontributors please add @Syrux64 for code

Copy link
Contributor

@thecoolwinter

I've put up a pull request to add @Syrux64! 🎉

thecoolwinter pushed a commit that referenced this pull request Jun 11, 2025
Adds @Syrux64 as a contributor for code.

This was requested by thecoolwinter [in this comment](#1995 (comment))

[skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
@Syrux64
Copy link
Contributor Author

Syrux64 commented Jun 11, 2025

Thanks y'all for letting me contribute to this project. I learnt a lot <33

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.

6 participants