Repository: CodeEditApp/CodeEdit
File: CodeEdit/Documents/WorkspaceDocument.swift (Swift)

Code before:
        )
        self.addWindowController(windowController)
    }

    // MARK: Set Up Workspace

    private func initWorkspaceState(_ url: URL) throws {
        self.workspaceClient = try .default(
            fileManager: .default,
            folderURL: url,
            ignoredFilesAndFolders: ignoredFilesAndDirectory
        )
        self.searchState = .init(self)
        self.quickOpenState = .init(fileURL: url)
        self.statusBarModel = .init(workspaceURL: url)

        NotificationCenter.default.addObserver(self,
                                               selector: #selector(convertTemporaryTab),
                                               name: NSNotification.Name("CodeEditor.didBeginEditing"),
                                               object: nil)
    }

    private func readSelectionState() throws -> WorkspaceSelectionState {
        guard fileURL != nil else { return selectionState }
        guard fileURL!.path != "" else { return selectionState }
        let path = fileURL!.path.data(using: .utf8)
        let hash = String(CryptoKit.SHA256.hash(data: path!).hashValue)
        if let data = UserDefaults.standard.value(forKey: hash) as? Data {
            let state = try? PropertyListDecoder().decode(WorkspaceSelectionState.self, from: data)
            if state != nil { return state! }
        }
        return selectionState
    }

    override func read(from url: URL, ofType typeName: String) throws {
        try initWorkspaceState(url)

        // Initialize Workspace
        do {
            selectionState = try readSelectionState()
        } catch {
            Swift.print("couldn't retrieve selection state from user defaults")
        }

        workspaceClient?
            .getFiles
            .sink { [weak self] files in
                guard let self = self else { return }

                guard !self.fileItems.isEmpty else {
                    self.fileItems = files

Review comment (suggestion):
Perhaps something like this is better to use?
```swift
guard let fileData = fileURL?.path?.data(using: .utf8) else {
    return selectionState
}
```

Code after:
    }

    // MARK: Set Up Workspace

    private func initWorkspaceState(_ url: URL) throws {
        self.workspaceClient = try .default(
            fileManager: .default,
            folderURL: url,
            ignoredFilesAndFolders: ignoredFilesAndDirectory
        )
        self.searchState = .init(self)
        self.quickOpenState = .init(fileURL: url)
        self.statusBarModel = .init(workspaceURL: url)

        NotificationCenter.default.addObserver(self,
                                               selector: #selector(convertTemporaryTab),
                                               name: NSNotification.Name("CodeEditor.didBeginEditing"),
                                               object: nil)
    }

    /// Retrieves selection state from UserDefaults using SHA256 hash of project  path as key
    /// - Throws: `DecodingError.dataCorrupted` error if retrived data from UserDefaults is not decodable
    /// - Returns: retrived state from UserDefaults or default state if not found
    private func readSelectionState() throws -> WorkspaceSelectionState {
        guard let path = fileURL?.path,
              let hash = path.sha256Hash,
              let data = UserDefaults.standard.value(forKey: hash) as? Data  else { return selectionState }
        let state = try PropertyListDecoder().decode(WorkspaceSelectionState.self, from: data)
        return state
    }

    override func read(from url: URL, ofType typeName: String) throws {
        try initWorkspaceState(url)

        // Initialize Workspace
        do {
            selectionState = try readSelectionState()
        } catch {
            Swift.print("couldn't retrieve selection state from user defaults")
        }

        workspaceClient?
            .getFiles
            .sink { [weak self] files in
                guard let self = self else { return }

                guard !self.fileItems.isEmpty else {
                    self.fileItems = files
                    return
                }