Repository: CodeEditApp/CodeEdit
File: CodeEditModules/Modules/WorkspaceClient/src/Model/FileItem.swift (Swift)

Code before:
            deleteConfirmation.buttons.last?.hasDestructiveAction = true
            deleteConfirmation.addButton(withTitle: "Cancel")
            if deleteConfirmation.runModal() == .alertFirstButtonReturn { // "Delete" button
                if FileItem.fileManger.fileExists(atPath: self.url.path) {
                    do {
                        try FileItem.fileManger.removeItem(at: self.url)
                    } catch {
                        fatalError(error.localizedDescription)
                    }
                }
            }
        }

        /// This function duplicates the item or folder
        public func duplicate() {
            // if a file/folder with the same name exists, add "copy" to the end
            var fileUrl = self.url
            while FileItem.fileManger.fileExists(atPath: fileUrl.path) {
                let previousName = fileUrl.lastPathComponent
                let previousNameWithoutExtension = (previousName as NSString).deletingPathExtension
                let filextension = fileUrl.pathExtension
                let fileName = filextension.isEmpty ?
                previousName : previousNameWithoutExtension
                fileUrl = fileUrl.deletingLastPathComponent()
                fileUrl.appendPathComponent("\(fileName)-copy")
                fileUrl.appendPathExtension("\(filextension)")
            }

            if FileItem.fileManger.fileExists(atPath: self.url.path) {
                do {
                    try FileItem.fileManger.copyItem(at: self.url, to: fileUrl)
                } catch {
                    print("Error at \(self.url.path) to \(fileUrl.path)")
                    fatalError(error.localizedDescription)
                }
            }
        }

        /// This function moves the item or folder if possible
        public func move(to newLocation: URL) {
            guard !FileItem.fileManger.fileExists(atPath: newLocation.path) else { return }
            do {
                try FileItem.fileManger.moveItem(at: self.url, to: newLocation)
            } catch { fatalError(error.localizedDescription) }
        }
    }
}

// MARK: Hashable

extension WorkspaceClient.FileItem: Hashable {

Review comment (suggestion):
```suggestion
                fileUrl.appendPathExtension(filextension)
```

Code after:
            deleteConfirmation.buttons.last?.hasDestructiveAction = true
            deleteConfirmation.addButton(withTitle: "Cancel")
            if deleteConfirmation.runModal() == .alertFirstButtonReturn { // "Delete" button
                if FileItem.fileManger.fileExists(atPath: self.url.path) {
                    do {
                        try FileItem.fileManger.removeItem(at: self.url)
                    } catch {
                        fatalError(error.localizedDescription)
                    }
                }
            }
        }

        /// This function duplicates the item or folder
        public func duplicate() {
            // if a file/folder with the same name exists, add "copy" to the end
            var fileUrl = self.url
            while FileItem.fileManger.fileExists(atPath: fileUrl.path) {
                let previousName = fileUrl.deletingPathExtension().lastPathComponent
                let filextension = fileUrl.pathExtension
                let duplicateName = "\(previousName)-copy"

                fileUrl = fileUrl.deletingLastPathComponent()
                fileUrl.appendPathComponent(duplicateName)
                fileUrl.appendPathExtension(filextension)
            }

            if FileItem.fileManger.fileExists(atPath: self.url.path) {
                do {
                    try FileItem.fileManger.copyItem(at: self.url, to: fileUrl)
                } catch {
                    print("Error at \(self.url.path) to \(fileUrl.path)")
                    fatalError(error.localizedDescription)
                }
            }
        }

        /// This function moves the item or folder if possible
        public func move(to newLocation: URL) {
            guard !FileItem.fileManger.fileExists(atPath: newLocation.path) else { return }
            do {
                try FileItem.fileManger.moveItem(at: self.url, to: newLocation)
            } catch { fatalError(error.localizedDescription) }
        }
    }
}

// MARK: Hashable

extension WorkspaceClient.FileItem: Hashable {
    public func hash(into hasher: inout Hasher) {