Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CodeEdit/Features/CEWorkspace/Models/CEWorkspaceFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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.
Expand Down