Repository: CodeEditApp/CodeEdit
File: CodeEdit/Features/WindowCommands/FileCommands.swift (Swift)

Code before:
            .keyboardShortcut("w", modifiers: [.control, .option, .command])

            if let utilityAreaViewModel {
                Button("Close Terminal") {
                    utilityAreaViewModel.removeTerminals(utilityAreaViewModel.selectedTerminals)
                }
                .keyboardShortcut(.delete)
            }

            Divider()

            Button("Save") {
                NSApp.sendAction(#selector(CodeEditWindowController.saveDocument(_:)), to: nil, from: nil)
            }
            .keyboardShortcut("s")
        }
    }

    // TODO: This logic needs to become a command, not a function bound to the MenuBar
    private func createNewFile() {
        guard let windowController = getCurrentCEWindowController() else { return }

        let fileManager = FileManager.default
        let workspaceName = windowController.workspace?.workspaceFileManager?.folderUrl.lastPathComponent

        var hashedWorkspaceName = "no-workspace".md5()
        if let workspaceName {
            hashedWorkspaceName = workspaceName.md5()
        }

        let tempStorageDir = CodeEditApp.applicationSupportURL
            .appendingPathComponent("workspaces/\(hashedWorkspaceName)", isDirectory: true)

        do {
            try createDirectoryIfNotExists(atPath: tempStorageDir.path)

            let probableNumber = try predictNextTempFileNumber(in: tempStorageDir)

            let filename = "untitled-\(probableNumber)"
            let tempFileURL = tempStorageDir.appending(path: filename)
            fileManager.createFile(atPath: tempFileURL.path(percentEncoded: false), contents: nil)
            print("Saving new file at: \(tempFileURL.path)")

            let file = CEWorkspaceFile(url: tempFileURL)
            windowController.workspace?.editorManager.openTab(item: file)
        } catch {
            print(error)
            let alert = NSAlert()
            alert.messageText = "Error"
            alert.informativeText = "An error occurred. Please try again later."
            alert.alertStyle = .critical

Review comment (suggestion):
```suggestion
       let hashedWorkspaceName = (workspaceName ?? "no-workspace").md5()
```

Code after:
                Button("Close Terminal") {
                    utilityAreaViewModel.removeTerminals(utilityAreaViewModel.selectedTerminals)
                }
                .keyboardShortcut(.delete)
            }

            Divider()

            Button("Save") {
                NSApp.sendAction(#selector(CodeEditWindowController.saveDocument(_:)), to: nil, from: nil)
            }
            .keyboardShortcut("s")
        }
    }

    private func createNewFile() {
        guard let windowController = getCurrentCEWindowController() else { return }

        let fileManager = FileManager.default
        let workspaceName = windowController.workspace?.workspaceFileManager?.folderUrl.lastPathComponent

        var hashedWorkspaceName = (workspaceName ?? "no-workspace").md5()

        let tempStorageDir = CodeEditApp.applicationSupportURL
            .appendingPathComponent("workspaces/\(hashedWorkspaceName)", isDirectory: true)

        do {
            try createDirectoryIfNotExists(atPath: tempStorageDir.path)

            let probableNumber = try predictNextTempFileNumber(in: tempStorageDir)

            let filename = "untitled-\(probableNumber)"
            let tempFileURL = tempStorageDir.appending(path: filename)
            fileManager.createFile(atPath: tempFileURL.path(percentEncoded: false), contents: nil)
            print("Saving new file at: \(tempFileURL.path)")

            let file = CEWorkspaceFile(url: tempFileURL)
            windowController.workspace?.editorManager.openTab(item: file)
        } catch {
            print(error)
            let alert = NSAlert()
            alert.messageText = "Error"
            alert.informativeText = "An error occurred: \(error.localizedDescription)."
            alert.alertStyle = .critical
            alert.addButton(withTitle: "OK")
            alert.runModal()
        }
    }

    private func getCurrentCEWindowController() -> CodeEditWindowController? {
        return NSApp.keyWindow?.windowController as? CodeEditWindowController