From f3f08ec186e544e727622580ef6f3257e6740572 Mon Sep 17 00:00:00 2001 From: Khan Winter <35942988+thecoolwinter@users.noreply.github.com> Date: Tue, 6 Feb 2024 00:16:51 -0600 Subject: [PATCH] Add Commands to All Windows --- CodeEdit.xcodeproj/project.pbxproj | 49 ++++++++++--------- .../xcshareddata/swiftpm/Package.resolved | 14 +++--- CodeEdit/CodeEditApp.swift | 2 - .../Documents/WorkspaceDocument.swift | 2 + .../WindowCommands/CodeEditCommands.swift | 1 - .../WindowCommands/FileCommands.swift | 21 ++++++-- .../WindowCommands/WindowCommands.swift | 17 +++++++ 7 files changed, 69 insertions(+), 37 deletions(-) diff --git a/CodeEdit.xcodeproj/project.pbxproj b/CodeEdit.xcodeproj/project.pbxproj index 9a1315605..a80efc97c 100644 --- a/CodeEdit.xcodeproj/project.pbxproj +++ b/CodeEdit.xcodeproj/project.pbxproj @@ -121,7 +121,6 @@ 587B60F82934124200D5CD8F /* CEWorkspaceFileManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B60F72934124100D5CD8F /* CEWorkspaceFileManagerTests.swift */; }; 587B61012934170A00D5CD8F /* UnitTests_Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B61002934170A00D5CD8F /* UnitTests_Extensions.swift */; }; 587B612E293419B700D5CD8F /* CodeFileTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B612D293419B700D5CD8F /* CodeFileTests.swift */; }; - 587B9D57292FC27A00AC7927 /* FolderMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B9D54292FC27A00AC7927 /* FolderMonitor.swift */; }; 587B9D9F29300ABD00AC7927 /* SegmentedControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B9D8829300ABD00AC7927 /* SegmentedControl.swift */; }; 587B9DA029300ABD00AC7927 /* PanelDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B9D8929300ABD00AC7927 /* PanelDivider.swift */; }; 587B9DA229300ABD00AC7927 /* EffectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B9D8B29300ABD00AC7927 /* EffectView.swift */; }; @@ -232,7 +231,6 @@ 58D01C9D293167DC00C5B6B4 /* KeychainSwiftAccessOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58D01C93293167DC00C5B6B4 /* KeychainSwiftAccessOptions.swift */; }; 58F2EAEC292FB2B0004A9BDE /* IgnoredFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58F2EAAA292FB2B0004A9BDE /* IgnoredFiles.swift */; }; 58F2EAEF292FB2B0004A9BDE /* ThemeSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58F2EAAF292FB2B0004A9BDE /* ThemeSettingsView.swift */; }; - 58F2EB02292FB2B0004A9BDE /* Loopable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58F2EACD292FB2B0004A9BDE /* Loopable.swift */; }; 58F2EB03292FB2B0004A9BDE /* Documentation.docc in Sources */ = {isa = PBXBuildFile; fileRef = 58F2EACE292FB2B0004A9BDE /* Documentation.docc */; }; 58F2EB04292FB2B0004A9BDE /* SourceControlSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58F2EAD1292FB2B0004A9BDE /* SourceControlSettings.swift */; }; 58F2EB05292FB2B0004A9BDE /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58F2EAD2292FB2B0004A9BDE /* Settings.swift */; }; @@ -354,10 +352,13 @@ 6CAAF69429BCD78600A1F48A /* (null) in Sources */ = {isa = PBXBuildFile; }; 6CABB19E29C5591D00340467 /* NSTableViewWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CABB19C29C5591D00340467 /* NSTableViewWrapper.swift */; }; 6CABB1A129C5593800340467 /* OverlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CABB1A029C5593800340467 /* OverlayView.swift */; }; + 6CB446402B6DFF3A00539ED0 /* CodeEditSourceEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 6CB4463F2B6DFF3A00539ED0 /* CodeEditSourceEditor */; }; 6CB52DC92AC8DC3E002E75B3 /* CEWorkspaceFileManager+FileManagement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB52DC82AC8DC3E002E75B3 /* CEWorkspaceFileManager+FileManagement.swift */; }; 6CB9144B29BEC7F100BC47F2 /* (null) in Sources */ = {isa = PBXBuildFile; }; 6CBA0D512A1BF524002C6FAA /* SegmentedControlImproved.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CBA0D502A1BF524002C6FAA /* SegmentedControlImproved.swift */; }; 6CBD1BC62978DE53006639D5 /* Font+Caption3.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CBD1BC52978DE53006639D5 /* Font+Caption3.swift */; }; + 6CBE1CFB2B71DAA6003AC32E /* Loopable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CBE1CFA2B71DAA6003AC32E /* Loopable.swift */; }; + 6CBE1D002B720565003AC32E /* CodeEditSourceEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 6CBE1CFF2B720565003AC32E /* CodeEditSourceEditor */; }; 6CC9E4B229B5669900C97388 /* Environment+ActiveEditor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CC9E4B129B5669900C97388 /* Environment+ActiveEditor.swift */; }; 6CD03B6A29FC773F001BD1D0 /* SettingsInjector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CD03B6929FC773F001BD1D0 /* SettingsInjector.swift */; }; 6CDA84AD284C1BA000C1CC3A /* EditorTabBarContextMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CDA84AC284C1BA000C1CC3A /* EditorTabBarContextMenu.swift */; }; @@ -365,7 +366,6 @@ 6CE622692A2A174A0013085C /* InspectorTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CE622682A2A174A0013085C /* InspectorTab.swift */; }; 6CE6226B2A2A1C730013085C /* UtilityAreaTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CE6226A2A2A1C730013085C /* UtilityAreaTab.swift */; }; 6CE6226E2A2A1CDE0013085C /* NavigatorTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CE6226D2A2A1CDE0013085C /* NavigatorTab.swift */; }; - 6CE952E32B29433500C29C31 /* CodeEditSourceEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 6CE952E22B29433500C29C31 /* CodeEditSourceEditor */; }; 6CED16E42A3E660D000EC962 /* String+Lines.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CED16E32A3E660D000EC962 /* String+Lines.swift */; }; 6CFF967429BEBCC300182D6F /* FindCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CFF967329BEBCC300182D6F /* FindCommands.swift */; }; 6CFF967629BEBCD900182D6F /* FileCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CFF967529BEBCD900182D6F /* FileCommands.swift */; }; @@ -681,7 +681,6 @@ 587B60F72934124100D5CD8F /* CEWorkspaceFileManagerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CEWorkspaceFileManagerTests.swift; sourceTree = ""; }; 587B61002934170A00D5CD8F /* UnitTests_Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnitTests_Extensions.swift; sourceTree = ""; }; 587B612D293419B700D5CD8F /* CodeFileTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CodeFileTests.swift; sourceTree = ""; }; - 587B9D54292FC27A00AC7927 /* FolderMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FolderMonitor.swift; sourceTree = ""; }; 587B9D8829300ABD00AC7927 /* SegmentedControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SegmentedControl.swift; sourceTree = ""; }; 587B9D8929300ABD00AC7927 /* PanelDivider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PanelDivider.swift; sourceTree = ""; }; 587B9D8B29300ABD00AC7927 /* EffectView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EffectView.swift; sourceTree = ""; }; @@ -794,7 +793,6 @@ 58D01C93293167DC00C5B6B4 /* KeychainSwiftAccessOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeychainSwiftAccessOptions.swift; sourceTree = ""; }; 58F2EAAA292FB2B0004A9BDE /* IgnoredFiles.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IgnoredFiles.swift; sourceTree = ""; }; 58F2EAAF292FB2B0004A9BDE /* ThemeSettingsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThemeSettingsView.swift; sourceTree = ""; }; - 58F2EACD292FB2B0004A9BDE /* Loopable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Loopable.swift; sourceTree = ""; }; 58F2EACE292FB2B0004A9BDE /* Documentation.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = Documentation.docc; sourceTree = ""; }; 58F2EAD1292FB2B0004A9BDE /* SourceControlSettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SourceControlSettings.swift; sourceTree = ""; }; 58F2EAD2292FB2B0004A9BDE /* Settings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = ""; }; @@ -904,6 +902,7 @@ 6CB52DC82AC8DC3E002E75B3 /* CEWorkspaceFileManager+FileManagement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CEWorkspaceFileManager+FileManagement.swift"; sourceTree = ""; }; 6CBA0D502A1BF524002C6FAA /* SegmentedControlImproved.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SegmentedControlImproved.swift; sourceTree = ""; }; 6CBD1BC52978DE53006639D5 /* Font+Caption3.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Font+Caption3.swift"; sourceTree = ""; }; + 6CBE1CFA2B71DAA6003AC32E /* Loopable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Loopable.swift; sourceTree = ""; }; 6CC9E4B129B5669900C97388 /* Environment+ActiveEditor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Environment+ActiveEditor.swift"; sourceTree = ""; }; 6CD03B6929FC773F001BD1D0 /* SettingsInjector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsInjector.swift; sourceTree = ""; }; 6CDA84AC284C1BA000C1CC3A /* EditorTabBarContextMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorTabBarContextMenu.swift; sourceTree = ""; }; @@ -1070,9 +1069,10 @@ 6C66C31329D05CDC00DE9ED2 /* GRDB in Frameworks */, 58F2EB1E292FB954004A9BDE /* Sparkle in Frameworks */, 6C2149412A1BB9AB00748382 /* LogStream in Frameworks */, + 6CBE1D002B720565003AC32E /* CodeEditSourceEditor in Frameworks */, 6C147C4529A329350089B630 /* OrderedCollections in Frameworks */, 6C6BD6F429CD142C00235D17 /* CollectionConcurrencyKit in Frameworks */, - 6CE952E32B29433500C29C31 /* CodeEditSourceEditor in Frameworks */, + 6CB446402B6DFF3A00539ED0 /* CodeEditSourceEditor in Frameworks */, 5879828A292ED15F0085B254 /* SwiftTerm in Frameworks */, 6CDEFC9629E22C2700B7C684 /* Introspect in Frameworks */, 2816F594280CF50500DD548B /* CodeEditSymbols in Frameworks */, @@ -1463,7 +1463,7 @@ 5831E3C92933E83400D5A6D2 /* Protocols */ = { isa = PBXGroup; children = ( - 58F2EACD292FB2B0004A9BDE /* Loopable.swift */, + 6CBE1CFA2B71DAA6003AC32E /* Loopable.swift */, 852C7E322A587279006BA599 /* SearchableSettingsPage.swift */, ); path = Protocols; @@ -2188,7 +2188,6 @@ 5831E3C92933E83400D5A6D2 /* Protocols */, 5875680E29316BDC00C965A3 /* ShellClient */, 6C5C891A2A3F736500A94FE1 /* FocusedValues.swift */, - 587B9D54292FC27A00AC7927 /* FolderMonitor.swift */, ); path = Utils; sourceTree = ""; @@ -3032,7 +3031,8 @@ 6CDEFC9529E22C2700B7C684 /* Introspect */, 6C0F3A3B2A1D0D5000223D19 /* CodeEditKit */, 6C5BE5212A3D5666002DA0FC /* WindowManagement */, - 6CE952E22B29433500C29C31 /* CodeEditSourceEditor */, + 6CB4463F2B6DFF3A00539ED0 /* CodeEditSourceEditor */, + 6CBE1CFF2B720565003AC32E /* CodeEditSourceEditor */, ); productName = CodeEdit; productReference = B658FB2C27DA9E0F00EA4DBD /* CodeEdit.app */; @@ -3128,7 +3128,7 @@ 6CDEFC9429E22C2700B7C684 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */, 6C0F3A3A2A1D0D5000223D19 /* XCRemoteSwiftPackageReference "CodeEditKit" */, 6C5BE5202A3D5666002DA0FC /* XCRemoteSwiftPackageReference "SwiftUI-WindowManagement" */, - 6CE952E12B29433500C29C31 /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */, + 6CBE1CFE2B720565003AC32E /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */, ); productRefGroup = B658FB2D27DA9E0F00EA4DBD /* Products */; projectDirPath = ""; @@ -3386,6 +3386,7 @@ 58822528292C280D00E83CDE /* StatusBarEncodingSelector.swift in Sources */, 6C7F37FE2A3EA6FA00217B83 /* View+focusedValue.swift in Sources */, B6C4F2A12B3CA37500B2B140 /* SourceControlNavigatorHistoryView.swift in Sources */, + 6CBE1CFB2B71DAA6003AC32E /* Loopable.swift in Sources */, B6C6A43029771F7100A3D28F /* EditorTabBackground.swift in Sources */, B60718372B170638009CDAB4 /* SourceControlNavigatorRenameBranchView.swift in Sources */, 6C578D8129CD294800DC73B2 /* ExtensionActivatorView.swift in Sources */, @@ -3395,7 +3396,6 @@ 9D36E1BF2B5E7D7500443C41 /* GitBranchesGroup.swift in Sources */, 587B9E8229301D8F00AC7927 /* GitHubPreviewHeader.swift in Sources */, 611191FC2B08CCB800D4459B /* SearchIndexer+AsyncController.swift in Sources */, - 58F2EB02292FB2B0004A9BDE /* Loopable.swift in Sources */, 6C578D8929CD36E400DC73B2 /* Commands+ForEach.swift in Sources */, 611192082B08CCFD00D4459B /* SearchIndexer+Terms.swift in Sources */, 28B8F884280FFE4600596236 /* NSTableView+Background.swift in Sources */, @@ -3429,7 +3429,6 @@ 6C2C155A29B4F4CC00EA60A5 /* Variadic.swift in Sources */, B6E41C8F29DE9CD80088F9F4 /* AccountsSettingsDetailsView.swift in Sources */, 5882252B292C280D00E83CDE /* StatusBarCursorLocationLabel.swift in Sources */, - 587B9D57292FC27A00AC7927 /* FolderMonitor.swift in Sources */, 58798252292E78D80085B254 /* ImageFileView.swift in Sources */, 5882252D292C280D00E83CDE /* StatusBarSplitTerminalButton.swift in Sources */, 58798238292E30B90085B254 /* FeedbackWindowController.swift in Sources */, @@ -4665,20 +4664,20 @@ minimumVersion = 0.2.0; }; }; - 6CDEFC9429E22C2700B7C684 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = { + 6CBE1CFE2B720565003AC32E /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */ = { isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/siteline/SwiftUI-Introspect"; + repositoryURL = "https://github.com/CodeEditApp/CodeEditSourceEditor"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 0.2.3; + minimumVersion = 0.7.0; }; }; - 6CE952E12B29433500C29C31 /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */ = { + 6CDEFC9429E22C2700B7C684 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = { isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/CodeEditApp/CodeEditSourceEditor.git"; + repositoryURL = "https://github.com/siteline/SwiftUI-Introspect"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 0.7.0; + minimumVersion = 0.2.3; }; }; /* End XCRemoteSwiftPackageReference section */ @@ -4748,16 +4747,20 @@ package = 6C147C4329A329350089B630 /* XCRemoteSwiftPackageReference "swift-collections" */; productName = DequeModule; }; - 6CDEFC9529E22C2700B7C684 /* Introspect */ = { + 6CB4463F2B6DFF3A00539ED0 /* CodeEditSourceEditor */ = { isa = XCSwiftPackageProductDependency; - package = 6CDEFC9429E22C2700B7C684 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */; - productName = Introspect; + productName = CodeEditSourceEditor; }; - 6CE952E22B29433500C29C31 /* CodeEditSourceEditor */ = { + 6CBE1CFF2B720565003AC32E /* CodeEditSourceEditor */ = { isa = XCSwiftPackageProductDependency; - package = 6CE952E12B29433500C29C31 /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */; + package = 6CBE1CFE2B720565003AC32E /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */; productName = CodeEditSourceEditor; }; + 6CDEFC9529E22C2700B7C684 /* Introspect */ = { + isa = XCSwiftPackageProductDependency; + package = 6CDEFC9429E22C2700B7C684 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */; + productName = Introspect; + }; /* End XCSwiftPackageProductDependency section */ }; rootObject = B658FB2427DA9E0F00EA4DBD /* Project object */; diff --git a/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 4966272a3..8214fa17c 100644 --- a/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -30,7 +30,7 @@ { "identity" : "codeeditsourceeditor", "kind" : "remoteSourceControl", - "location" : "https://github.com/CodeEditApp/CodeEditSourceEditor.git", + "location" : "https://github.com/CodeEditApp/CodeEditSourceEditor", "state" : { "revision" : "e08a43ea07861e42d42f317899df69bf8f0a0a54", "version" : "0.7.0" @@ -140,8 +140,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/mattmassicotte/MainOffender", "state" : { - "revision" : "343cc3797618c29b48b037b4e2beea0664e75315", - "version" : "0.1.0" + "revision" : "8de872d9256ff7f9913cbc5dd560568ab164be45", + "version" : "0.2.1" } }, { @@ -167,8 +167,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/ChimeHQ/Rearrange", "state" : { - "revision" : "0fb658e721c68495f6340c211cc6d4719e6b52d8", - "version" : "1.6.0" + "revision" : "5ff7f3363f7a08f77e0d761e38e6add31c2136e1", + "version" : "1.8.1" } }, { @@ -203,8 +203,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-syntax.git", "state" : { - "revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036", - "version" : "509.0.2" + "revision" : "43c802fb7f96e090dde015344a94b5e85779eff1", + "version" : "509.1.0" } }, { diff --git a/CodeEdit/CodeEditApp.swift b/CodeEdit/CodeEditApp.swift index 8dad81eaa..d1fb39053 100644 --- a/CodeEdit/CodeEditApp.swift +++ b/CodeEdit/CodeEditApp.swift @@ -27,10 +27,8 @@ struct CodeEditApp: App { var body: some Scene { Group { WelcomeWindow() - .keyboardShortcut("1", modifiers: [.command, .shift]) ExtensionManagerWindow() - .keyboardShortcut("2", modifiers: [.command, .shift]) AboutWindow() diff --git a/CodeEdit/Features/Documents/WorkspaceDocument.swift b/CodeEdit/Features/Documents/WorkspaceDocument.swift index ab419b93e..5baa3397d 100644 --- a/CodeEdit/Features/Documents/WorkspaceDocument.swift +++ b/CodeEdit/Features/Documents/WorkspaceDocument.swift @@ -111,6 +111,8 @@ final class WorkspaceDocument: NSDocument, ObservableObject, NSToolbarDelegate { private func initWorkspaceState(_ url: URL) throws { self.fileURL = url + self.displayName = url.lastPathComponent + let sourceControlManager = SourceControlManager( workspaceURL: url, editorManager: editorManager diff --git a/CodeEdit/Features/WindowCommands/CodeEditCommands.swift b/CodeEdit/Features/WindowCommands/CodeEditCommands.swift index bc435d4f3..d035499a0 100644 --- a/CodeEdit/Features/WindowCommands/CodeEditCommands.swift +++ b/CodeEdit/Features/WindowCommands/CodeEditCommands.swift @@ -8,7 +8,6 @@ import SwiftUI struct CodeEditCommands: Commands { - var body: some Commands { MainCommands() FileCommands() diff --git a/CodeEdit/Features/WindowCommands/FileCommands.swift b/CodeEdit/Features/WindowCommands/FileCommands.swift index 6cb452aec..117fe2048 100644 --- a/CodeEdit/Features/WindowCommands/FileCommands.swift +++ b/CodeEdit/Features/WindowCommands/FileCommands.swift @@ -37,12 +37,24 @@ struct FileCommands: Commands { CommandGroup(replacing: .saveItem) { Button("Close Tab") { - NSApp.sendAction(#selector(CodeEditWindowController.closeCurrentTab(_:)), to: nil, from: nil) + if NSApp.target(forAction: #selector(CodeEditWindowController.closeCurrentTab(_:))) != nil { + NSApp.sendAction(#selector(CodeEditWindowController.closeCurrentTab(_:)), to: nil, from: nil) + } else { + NSApp.sendAction(#selector(NSWindow.close), to: nil, from: nil) + } } .keyboardShortcut("w") Button("Close Editor") { - NSApp.sendAction(#selector(CodeEditWindowController.closeActiveEditor(_:)), to: nil, from: nil) + if NSApp.target(forAction: #selector(CodeEditWindowController.closeActiveEditor(_:))) != nil { + NSApp.sendAction( + #selector(CodeEditWindowController.closeActiveEditor(_:)), + to: nil, + from: nil + ) + } else { + NSApp.sendAction(#selector(NSWindow.close), to: nil, from: nil) + } } .keyboardShortcut("w", modifiers: [.control, .shift, .command]) @@ -52,10 +64,11 @@ struct FileCommands: Commands { .keyboardShortcut("w", modifiers: [.shift, .command]) Button("Close Workspace") { - // TODO: Determine how this is different than the "Close Window" command and adjust accordingly - NSApp.sendAction(#selector(NSWindow.close), to: nil, from: nil) + guard let keyWindow = NSApplication.shared.keyWindow else { return } + NSApp.sendAction(#selector(NSWindow.close), to: keyWindow, from: nil) } .keyboardShortcut("w", modifiers: [.control, .option, .command]) + .disabled(!(NSApplication.shared.keyWindow?.windowController is CodeEditWindowController)) if let utilityAreaViewModel { Button("Close Terminal") { diff --git a/CodeEdit/Features/WindowCommands/WindowCommands.swift b/CodeEdit/Features/WindowCommands/WindowCommands.swift index 436f92a67..fb76ade3d 100644 --- a/CodeEdit/Features/WindowCommands/WindowCommands.swift +++ b/CodeEdit/Features/WindowCommands/WindowCommands.swift @@ -13,6 +13,23 @@ struct WindowCommands: Commands { var openWindow var body: some Commands { + CommandGroup(replacing: .singleWindowList) { + Button("Welcome to CodeEdit") { + NSApp.openWindow(.welcome) + } + .keyboardShortcut("1", modifiers: [.shift, .command]) + + Button("About CodeEdit") { + NSApp.openWindow(.about) + } + .keyboardShortcut("2", modifiers: [.shift, .command]) + + Button("Manage Extensions") { + NSApp.openWindow(.extensions) + } + .keyboardShortcut("3", modifiers: [.shift, .command]) + } + CommandGroup(after: .windowArrangement) { // This command is used to open SwiftUI windows from AppKit. // It should not be used by the user.