diff --git a/CodeEdit/Features/CEWorkspace/Models/CEWorkspaceFile.swift b/CodeEdit/Features/CEWorkspace/Models/CEWorkspaceFile.swift index 10e821e94..c9800a157 100644 --- a/CodeEdit/Features/CEWorkspace/Models/CEWorkspaceFile.swift +++ b/CodeEdit/Features/CEWorkspace/Models/CEWorkspaceFile.swift @@ -39,7 +39,7 @@ final class CEWorkspaceFile: Codable, Comparable, Hashable, Identifiable, Editor var id: String { url.relativePath } /// Returns the file name (e.g.: `Package.swift`) - var name: String { url.lastPathComponent } + var name: String { url.lastPathComponent.trimmingCharacters(in: .whitespacesAndNewlines) } /// Returns the extension of the file or an empty string if no extension is present. var type: FileIcon.FileType { .init(rawValue: url.pathExtension) ?? .txt } @@ -176,7 +176,9 @@ final class CEWorkspaceFile: Codable, Comparable, Hashable, Identifiable, Editor /// Returns the file name with optional extension (e.g.: `Package.swift`) func fileName(typeHidden: Bool = false) -> String { - typeHidden ? url.deletingPathExtension().lastPathComponent : name + typeHidden ? url.deletingPathExtension() + .lastPathComponent + .trimmingCharacters(in: .whitespacesAndNewlines) : name } /// Generates a string based on user's file name preferences.