Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Source Control File Names With Spaces #1858

Merged
34 changes: 21 additions & 13 deletions CodeEdit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
04C3255C2801F86900C8DA2D /* ProjectNavigatorMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285FEC7127FE4EEF00E57D53 /* ProjectNavigatorMenu.swift */; };
0FD96BCE2BEF42530025A697 /* CodeEditWindowController+Toolbar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0FD96BCD2BEF42530025A697 /* CodeEditWindowController+Toolbar.swift */; };
201169D72837B2E300F92B46 /* SourceControlNavigatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 201169D62837B2E300F92B46 /* SourceControlNavigatorView.swift */; };
201169DB2837B34000F92B46 /* SourceControlNavigatorChangedFileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 201169DA2837B34000F92B46 /* SourceControlNavigatorChangedFileView.swift */; };
201169DB2837B34000F92B46 /* GitChangedFileListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 201169DA2837B34000F92B46 /* GitChangedFileListView.swift */; };
201169DD2837B3AC00F92B46 /* SourceControlNavigatorToolbarBottom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 201169DC2837B3AC00F92B46 /* SourceControlNavigatorToolbarBottom.swift */; };
201169E22837B3D800F92B46 /* SourceControlNavigatorChangesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 201169E12837B3D800F92B46 /* SourceControlNavigatorChangesView.swift */; };
201169E52837B40300F92B46 /* SourceControlNavigatorRepositoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 201169E42837B40300F92B46 /* SourceControlNavigatorRepositoryView.swift */; };
Expand Down Expand Up @@ -225,7 +225,7 @@
587B9E9729301D8F00AC7927 /* BitBucketAccount+Token.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B9E5029301D8F00AC7927 /* BitBucketAccount+Token.swift */; };
587B9E9829301D8F00AC7927 /* GitCommit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B9E5329301D8F00AC7927 /* GitCommit.swift */; };
587B9E9929301D8F00AC7927 /* GitChangedFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B9E5429301D8F00AC7927 /* GitChangedFile.swift */; };
587B9E9A29301D8F00AC7927 /* GitType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B9E5529301D8F00AC7927 /* GitType.swift */; };
587B9E9A29301D8F00AC7927 /* GitStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B9E5529301D8F00AC7927 /* GitStatus.swift */; };
587FB99029C1246400B519DD /* EditorTabView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587FB98F29C1246400B519DD /* EditorTabView.swift */; };
58822524292C280D00E83CDE /* StatusBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58822509292C280D00E83CDE /* StatusBarView.swift */; };
58822525292C280D00E83CDE /* StatusBarMenuStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5882250B292C280D00E83CDE /* StatusBarMenuStyle.swift */; };
Expand Down Expand Up @@ -376,6 +376,7 @@
6C1CC9982B1E770B0002349B /* AsyncFileIterator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C1CC9972B1E770B0002349B /* AsyncFileIterator.swift */; };
6C1CC99B2B1E7CBC0002349B /* FindNavigatorIndexBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C1CC99A2B1E7CBC0002349B /* FindNavigatorIndexBar.swift */; };
6C1F3DA22C18C55800F6DEF6 /* ShellIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C1F3DA12C18C55800F6DEF6 /* ShellIntegrationTests.swift */; };
6C23842F2C796B4C003FBDD4 /* GitChangedFileLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C23842E2C796B4C003FBDD4 /* GitChangedFileLabel.swift */; };
6C2C155829B4F49100EA60A5 /* SplitViewItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C2C155729B4F49100EA60A5 /* SplitViewItem.swift */; };
6C2C155A29B4F4CC00EA60A5 /* Variadic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C2C155929B4F4CC00EA60A5 /* Variadic.swift */; };
6C2C155D29B4F4E500EA60A5 /* SplitViewReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C2C155C29B4F4E500EA60A5 /* SplitViewReader.swift */; };
Expand Down Expand Up @@ -561,7 +562,6 @@
B6C4F2A32B3CA74800B2B140 /* CommitDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C4F2A22B3CA74800B2B140 /* CommitDetailsView.swift */; };
B6C4F2A62B3CABD200B2B140 /* HistoryInspectorItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C4F2A52B3CABD200B2B140 /* HistoryInspectorItemView.swift */; };
B6C4F2A92B3CB00100B2B140 /* CommitDetailsHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C4F2A82B3CB00100B2B140 /* CommitDetailsHeaderView.swift */; };
B6C4F2AC2B3CC4D000B2B140 /* CommitChangedFileListItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C4F2AB2B3CC4D000B2B140 /* CommitChangedFileListItemView.swift */; };
B6C6A42A297716A500A3D28F /* EditorTabCloseButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C6A429297716A500A3D28F /* EditorTabCloseButton.swift */; };
B6C6A42E29771A8D00A3D28F /* EditorTabButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C6A42D29771A8D00A3D28F /* EditorTabButtonStyle.swift */; };
B6C6A43029771F7100A3D28F /* EditorTabBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C6A42F29771F7100A3D28F /* EditorTabBackground.swift */; };
Expand Down Expand Up @@ -687,7 +687,7 @@
04BC1CDD2AD9B4B000A83EA5 /* EditorFileTabCloseButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorFileTabCloseButton.swift; sourceTree = "<group>"; };
0FD96BCD2BEF42530025A697 /* CodeEditWindowController+Toolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CodeEditWindowController+Toolbar.swift"; sourceTree = "<group>"; };
201169D62837B2E300F92B46 /* SourceControlNavigatorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceControlNavigatorView.swift; sourceTree = "<group>"; };
201169DA2837B34000F92B46 /* SourceControlNavigatorChangedFileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceControlNavigatorChangedFileView.swift; sourceTree = "<group>"; };
201169DA2837B34000F92B46 /* GitChangedFileListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GitChangedFileListView.swift; sourceTree = "<group>"; };
201169DC2837B3AC00F92B46 /* SourceControlNavigatorToolbarBottom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceControlNavigatorToolbarBottom.swift; sourceTree = "<group>"; };
201169E12837B3D800F92B46 /* SourceControlNavigatorChangesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceControlNavigatorChangesView.swift; sourceTree = "<group>"; };
201169E42837B40300F92B46 /* SourceControlNavigatorRepositoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceControlNavigatorRepositoryView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -886,7 +886,7 @@
587B9E5029301D8F00AC7927 /* BitBucketAccount+Token.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "BitBucketAccount+Token.swift"; sourceTree = "<group>"; };
587B9E5329301D8F00AC7927 /* GitCommit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GitCommit.swift; sourceTree = "<group>"; };
587B9E5429301D8F00AC7927 /* GitChangedFile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GitChangedFile.swift; sourceTree = "<group>"; };
587B9E5529301D8F00AC7927 /* GitType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GitType.swift; sourceTree = "<group>"; };
587B9E5529301D8F00AC7927 /* GitStatus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GitStatus.swift; sourceTree = "<group>"; };
587FB98F29C1246400B519DD /* EditorTabView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditorTabView.swift; sourceTree = "<group>"; };
58822509292C280D00E83CDE /* StatusBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarView.swift; sourceTree = "<group>"; };
5882250B292C280D00E83CDE /* StatusBarMenuStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarMenuStyle.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1034,6 +1034,7 @@
6C1CC9972B1E770B0002349B /* AsyncFileIterator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsyncFileIterator.swift; sourceTree = "<group>"; };
6C1CC99A2B1E7CBC0002349B /* FindNavigatorIndexBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FindNavigatorIndexBar.swift; sourceTree = "<group>"; };
6C1F3DA12C18C55800F6DEF6 /* ShellIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShellIntegrationTests.swift; sourceTree = "<group>"; };
6C23842E2C796B4C003FBDD4 /* GitChangedFileLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GitChangedFileLabel.swift; sourceTree = "<group>"; };
6C2C155729B4F49100EA60A5 /* SplitViewItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplitViewItem.swift; sourceTree = "<group>"; };
6C2C155929B4F4CC00EA60A5 /* Variadic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Variadic.swift; sourceTree = "<group>"; };
6C2C155C29B4F4E500EA60A5 /* SplitViewReader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplitViewReader.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1210,7 +1211,6 @@
B6C4F2A22B3CA74800B2B140 /* CommitDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommitDetailsView.swift; sourceTree = "<group>"; };
B6C4F2A52B3CABD200B2B140 /* HistoryInspectorItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryInspectorItemView.swift; sourceTree = "<group>"; };
B6C4F2A82B3CB00100B2B140 /* CommitDetailsHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommitDetailsHeaderView.swift; sourceTree = "<group>"; };
B6C4F2AB2B3CC4D000B2B140 /* CommitChangedFileListItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommitChangedFileListItemView.swift; sourceTree = "<group>"; };
B6C6A429297716A500A3D28F /* EditorTabCloseButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorTabCloseButton.swift; sourceTree = "<group>"; };
B6C6A42D29771A8D00A3D28F /* EditorTabButtonStyle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EditorTabButtonStyle.swift; sourceTree = "<group>"; };
B6C6A42F29771F7100A3D28F /* EditorTabBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorTabBackground.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1339,6 +1339,7 @@
201169DE2837B3C700F92B46 /* Views */ = {
isa = PBXGroup;
children = (
6C2384302C796EBD003FBDD4 /* ChangedFile */,
201169D62837B2E300F92B46 /* SourceControlNavigatorView.swift */,
201169DC2837B3AC00F92B46 /* SourceControlNavigatorToolbarBottom.swift */,
);
Expand Down Expand Up @@ -2247,7 +2248,7 @@
587B9E5329301D8F00AC7927 /* GitCommit.swift */,
B65B10F12B07D34F002852CF /* GitRemote.swift */,
B607181F2B0C6CE7009CDAB4 /* GitStashEntry.swift */,
587B9E5529301D8F00AC7927 /* GitType.swift */,
587B9E5529301D8F00AC7927 /* GitStatus.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -2818,6 +2819,15 @@
path = TerminalEmulator;
sourceTree = "<group>";
};
6C2384302C796EBD003FBDD4 /* ChangedFile */ = {
isa = PBXGroup;
children = (
201169DA2837B34000F92B46 /* GitChangedFileListView.swift */,
6C23842E2C796B4C003FBDD4 /* GitChangedFileLabel.swift */,
);
path = ChangedFile;
sourceTree = "<group>";
};
6C48B5DB2C0D664A001E9955 /* Model */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3016,11 +3026,10 @@
isa = PBXGroup;
children = (
201169E12837B3D800F92B46 /* SourceControlNavigatorChangesView.swift */,
201169DA2837B34000F92B46 /* SourceControlNavigatorChangedFileView.swift */,
04BA7C0D2AE2A76E00584E1C /* SourceControlNavigatorChangesCommitView.swift */,
B65B10FD2B08B07D002852CF /* SourceControlNavigatorChangesList.swift */,
04BA7C232AE2E7CD00584E1C /* SourceControlNavigatorSyncView.swift */,
B65B10F72B081A34002852CF /* SourceControlNavigatorNoRemotesView.swift */,
B65B10FD2B08B07D002852CF /* SourceControlNavigatorChangesList.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -3183,7 +3192,6 @@
20EBB504280C329800F3A5DA /* CommitListItemView.swift */,
B6C4F2A22B3CA74800B2B140 /* CommitDetailsView.swift */,
B6C4F2A82B3CB00100B2B140 /* CommitDetailsHeaderView.swift */,
B6C4F2AB2B3CC4D000B2B140 /* CommitChangedFileListItemView.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -3871,7 +3879,7 @@
30B088172C0D53080063A882 /* LSPUtil.swift in Sources */,
6C5B63DE29C76213005454BA /* WindowCodeFileView.swift in Sources */,
58F2EB08292FB2B0004A9BDE /* TextEditingSettings.swift in Sources */,
201169DB2837B34000F92B46 /* SourceControlNavigatorChangedFileView.swift in Sources */,
201169DB2837B34000F92B46 /* GitChangedFileListView.swift in Sources */,
61A3E3DD2C33132F00076BD3 /* CEWorkspaceSettingsView.swift in Sources */,
5882252E292C280D00E83CDE /* UtilityAreaMaximizeButton.swift in Sources */,
30B0880D2C0D53080063A882 /* LanguageServer+References.swift in Sources */,
Expand Down Expand Up @@ -3949,7 +3957,6 @@
581BFB672926431000D251EC /* WelcomeWindowView.swift in Sources */,
58A5DFA329339F6400D1BD5D /* CommandManager.swift in Sources */,
58798284292ED0FB0085B254 /* TerminalEmulatorView.swift in Sources */,
B6C4F2AC2B3CC4D000B2B140 /* CommitChangedFileListItemView.swift in Sources */,
61A3E3E12C331B4A00076BD3 /* AddCETaskView.swift in Sources */,
6C82D6B329BFD88700495C54 /* NavigateCommands.swift in Sources */,
617DB3D82C25B04D00B58BFE /* CECircularProgressView.swift in Sources */,
Expand All @@ -3970,6 +3977,7 @@
30B088092C0D53080063A882 /* LanguageServer+Formatting.swift in Sources */,
30B088102C0D53080063A882 /* LanguageServer+SemanticTokens.swift in Sources */,
B6C6A43029771F7100A3D28F /* EditorTabBackground.swift in Sources */,
6C23842F2C796B4C003FBDD4 /* GitChangedFileLabel.swift in Sources */,
B60718372B170638009CDAB4 /* SourceControlRenameBranchView.swift in Sources */,
6C578D8129CD294800DC73B2 /* ExtensionActivatorView.swift in Sources */,
B6F0517D29D9E4B100D72287 /* TerminalSettingsView.swift in Sources */,
Expand Down Expand Up @@ -4218,7 +4226,7 @@
61A3E3DF2C3318C900076BD3 /* CEWorkspaceSettingsTaskListView.swift in Sources */,
58F2EB07292FB2B0004A9BDE /* GeneralSettings.swift in Sources */,
B6041F4D29D7A4E9000F3454 /* SettingsPageView.swift in Sources */,
587B9E9A29301D8F00AC7927 /* GitType.swift in Sources */,
587B9E9A29301D8F00AC7927 /* GitStatus.swift in Sources */,
B65B10F82B081A34002852CF /* SourceControlNavigatorNoRemotesView.swift in Sources */,
58D01C97293167DC00C5B6B4 /* String+SHA256.swift in Sources */,
61A3E3D92C33126F00076BD3 /* CEWorkspaceSettingsData.swift in Sources */,
Expand Down
8 changes: 4 additions & 4 deletions CodeEdit/Features/CEWorkspace/Models/CEWorkspaceFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ final class CEWorkspaceFile: Codable, Comparable, Hashable, Identifiable, Editor

var fileIdentifier = UUID().uuidString

/// Returns the Git status of a file as ``GitType``
var gitStatus: GitType?
/// Returns the Git status of a file as ``GitStatus``
var gitStatus: GitStatus?

/// Returns a boolean that is true if the file is staged for commit
var staged: Bool?
Expand Down Expand Up @@ -163,7 +163,7 @@ final class CEWorkspaceFile: Codable, Comparable, Hashable, Identifiable, Editor

init(
url: URL,
changeType: GitType? = nil,
changeType: GitStatus? = nil,
staged: Bool? = false
) {
self.url = url
Expand All @@ -180,7 +180,7 @@ final class CEWorkspaceFile: Codable, Comparable, Hashable, Identifiable, Editor
required init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
url = try values.decode(URL.self, forKey: .url)
gitStatus = try values.decode(GitType.self, forKey: .changeType)
gitStatus = try values.decode(GitStatus.self, forKey: .changeType)
staged = try values.decode(Bool.self, forKey: .staged)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ enum FileIcon {

/// Returns a string describing a SFSymbol for files
/// If not specified otherwise this will return `"doc"`
static func fileIcon(fileType: FileType) -> String { // swiftlint:disable:this cyclomatic_complexity function_body_length line_length
static func fileIcon(fileType: FileType?) -> String { // swiftlint:disable:this cyclomatic_complexity function_body_length line_length
switch fileType {
case .json, .yml, .resolved:
return "doc.json"
Expand Down Expand Up @@ -171,7 +171,7 @@ enum FileIcon {

/// Returns a `Color` for a specific `fileType`
/// If not specified otherwise this will return `Color.accentColor`
static func iconColor(fileType: FileType) -> Color { // swiftlint:disable:this cyclomatic_complexity
static func iconColor(fileType: FileType?) -> Color { // swiftlint:disable:this cyclomatic_complexity
switch fileType {
case .swift, .html:
return .orange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ final class WorkspaceDocument: NSDocument, ObservableObject, NSToolbarDelegate {
// MARK: Set Up Workspace

private func initWorkspaceState(_ url: URL) throws {
// Ensure the URL ends with a "/" to prevent certain URL(filePath:relativeTo) initializers from
// placing the file one directory above our workspace. This quick fix appends a "/" if needed.
var url = url
if !url.absoluteString.hasSuffix("/") {
url = URL(filePath: url.absoluteURL.path(percentEncoded: false) + "/")
}

self.fileURL = url
self.displayName = url.lastPathComponent

Expand Down
5 changes: 3 additions & 2 deletions CodeEdit/Features/Editor/Models/EditorManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ class EditorManager: ObservableObject {
/// - Parameters:
/// - item: The tab to open.
/// - editor: The editor to add the tab to. If nil, it is added to the active tab group.
func openTab(item: CEWorkspaceFile, in editor: Editor? = nil) {
/// - asTemporary: Indicates whether the tab should be opened as a temporary tab or a permanent tab.
func openTab(item: CEWorkspaceFile, in editor: Editor? = nil, asTemporary: Bool = false) {
let editor = editor ?? activeEditor
editor.openTab(file: item, asTemporary: false)
editor.openTab(file: item, asTemporary: asTemporary)
}

/// bind active tap group to listen to file selection changes.
Expand Down
Loading
Loading