Skip to content

Commit bc5aff9

Browse files
Correct Commands For All Windows, Fix ⌘W (#1587)
1 parent 80c5535 commit bc5aff9

File tree

7 files changed

+69
-37
lines changed

7 files changed

+69
-37
lines changed

CodeEdit.xcodeproj/project.pbxproj

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@
121121
587B60F82934124200D5CD8F /* CEWorkspaceFileManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B60F72934124100D5CD8F /* CEWorkspaceFileManagerTests.swift */; };
122122
587B61012934170A00D5CD8F /* UnitTests_Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B61002934170A00D5CD8F /* UnitTests_Extensions.swift */; };
123123
587B612E293419B700D5CD8F /* CodeFileTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B612D293419B700D5CD8F /* CodeFileTests.swift */; };
124-
587B9D57292FC27A00AC7927 /* FolderMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B9D54292FC27A00AC7927 /* FolderMonitor.swift */; };
125124
587B9D9F29300ABD00AC7927 /* SegmentedControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B9D8829300ABD00AC7927 /* SegmentedControl.swift */; };
126125
587B9DA029300ABD00AC7927 /* PanelDivider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B9D8929300ABD00AC7927 /* PanelDivider.swift */; };
127126
587B9DA229300ABD00AC7927 /* EffectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587B9D8B29300ABD00AC7927 /* EffectView.swift */; };
@@ -232,7 +231,6 @@
232231
58D01C9D293167DC00C5B6B4 /* KeychainSwiftAccessOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58D01C93293167DC00C5B6B4 /* KeychainSwiftAccessOptions.swift */; };
233232
58F2EAEC292FB2B0004A9BDE /* IgnoredFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58F2EAAA292FB2B0004A9BDE /* IgnoredFiles.swift */; };
234233
58F2EAEF292FB2B0004A9BDE /* ThemeSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58F2EAAF292FB2B0004A9BDE /* ThemeSettingsView.swift */; };
235-
58F2EB02292FB2B0004A9BDE /* Loopable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58F2EACD292FB2B0004A9BDE /* Loopable.swift */; };
236234
58F2EB03292FB2B0004A9BDE /* Documentation.docc in Sources */ = {isa = PBXBuildFile; fileRef = 58F2EACE292FB2B0004A9BDE /* Documentation.docc */; };
237235
58F2EB04292FB2B0004A9BDE /* SourceControlSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58F2EAD1292FB2B0004A9BDE /* SourceControlSettings.swift */; };
238236
58F2EB05292FB2B0004A9BDE /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58F2EAD2292FB2B0004A9BDE /* Settings.swift */; };
@@ -354,18 +352,20 @@
354352
6CAAF69429BCD78600A1F48A /* (null) in Sources */ = {isa = PBXBuildFile; };
355353
6CABB19E29C5591D00340467 /* NSTableViewWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CABB19C29C5591D00340467 /* NSTableViewWrapper.swift */; };
356354
6CABB1A129C5593800340467 /* OverlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CABB1A029C5593800340467 /* OverlayView.swift */; };
355+
6CB446402B6DFF3A00539ED0 /* CodeEditSourceEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 6CB4463F2B6DFF3A00539ED0 /* CodeEditSourceEditor */; };
357356
6CB52DC92AC8DC3E002E75B3 /* CEWorkspaceFileManager+FileManagement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CB52DC82AC8DC3E002E75B3 /* CEWorkspaceFileManager+FileManagement.swift */; };
358357
6CB9144B29BEC7F100BC47F2 /* (null) in Sources */ = {isa = PBXBuildFile; };
359358
6CBA0D512A1BF524002C6FAA /* SegmentedControlImproved.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CBA0D502A1BF524002C6FAA /* SegmentedControlImproved.swift */; };
360359
6CBD1BC62978DE53006639D5 /* Font+Caption3.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CBD1BC52978DE53006639D5 /* Font+Caption3.swift */; };
360+
6CBE1CFB2B71DAA6003AC32E /* Loopable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CBE1CFA2B71DAA6003AC32E /* Loopable.swift */; };
361+
6CBE1D002B720565003AC32E /* CodeEditSourceEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 6CBE1CFF2B720565003AC32E /* CodeEditSourceEditor */; };
361362
6CC9E4B229B5669900C97388 /* Environment+ActiveEditor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CC9E4B129B5669900C97388 /* Environment+ActiveEditor.swift */; };
362363
6CD03B6A29FC773F001BD1D0 /* SettingsInjector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CD03B6929FC773F001BD1D0 /* SettingsInjector.swift */; };
363364
6CDA84AD284C1BA000C1CC3A /* EditorTabBarContextMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CDA84AC284C1BA000C1CC3A /* EditorTabBarContextMenu.swift */; };
364365
6CDEFC9629E22C2700B7C684 /* Introspect in Frameworks */ = {isa = PBXBuildFile; productRef = 6CDEFC9529E22C2700B7C684 /* Introspect */; };
365366
6CE622692A2A174A0013085C /* InspectorTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CE622682A2A174A0013085C /* InspectorTab.swift */; };
366367
6CE6226B2A2A1C730013085C /* UtilityAreaTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CE6226A2A2A1C730013085C /* UtilityAreaTab.swift */; };
367368
6CE6226E2A2A1CDE0013085C /* NavigatorTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CE6226D2A2A1CDE0013085C /* NavigatorTab.swift */; };
368-
6CE952E32B29433500C29C31 /* CodeEditSourceEditor in Frameworks */ = {isa = PBXBuildFile; productRef = 6CE952E22B29433500C29C31 /* CodeEditSourceEditor */; };
369369
6CED16E42A3E660D000EC962 /* String+Lines.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CED16E32A3E660D000EC962 /* String+Lines.swift */; };
370370
6CFF967429BEBCC300182D6F /* FindCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CFF967329BEBCC300182D6F /* FindCommands.swift */; };
371371
6CFF967629BEBCD900182D6F /* FileCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CFF967529BEBCD900182D6F /* FileCommands.swift */; };
@@ -681,7 +681,6 @@
681681
587B60F72934124100D5CD8F /* CEWorkspaceFileManagerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CEWorkspaceFileManagerTests.swift; sourceTree = "<group>"; };
682682
587B61002934170A00D5CD8F /* UnitTests_Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnitTests_Extensions.swift; sourceTree = "<group>"; };
683683
587B612D293419B700D5CD8F /* CodeFileTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CodeFileTests.swift; sourceTree = "<group>"; };
684-
587B9D54292FC27A00AC7927 /* FolderMonitor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FolderMonitor.swift; sourceTree = "<group>"; };
685684
587B9D8829300ABD00AC7927 /* SegmentedControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SegmentedControl.swift; sourceTree = "<group>"; };
686685
587B9D8929300ABD00AC7927 /* PanelDivider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PanelDivider.swift; sourceTree = "<group>"; };
687686
587B9D8B29300ABD00AC7927 /* EffectView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EffectView.swift; sourceTree = "<group>"; };
@@ -794,7 +793,6 @@
794793
58D01C93293167DC00C5B6B4 /* KeychainSwiftAccessOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeychainSwiftAccessOptions.swift; sourceTree = "<group>"; };
795794
58F2EAAA292FB2B0004A9BDE /* IgnoredFiles.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IgnoredFiles.swift; sourceTree = "<group>"; };
796795
58F2EAAF292FB2B0004A9BDE /* ThemeSettingsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThemeSettingsView.swift; sourceTree = "<group>"; };
797-
58F2EACD292FB2B0004A9BDE /* Loopable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Loopable.swift; sourceTree = "<group>"; };
798796
58F2EACE292FB2B0004A9BDE /* Documentation.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = Documentation.docc; sourceTree = "<group>"; };
799797
58F2EAD1292FB2B0004A9BDE /* SourceControlSettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SourceControlSettings.swift; sourceTree = "<group>"; };
800798
58F2EAD2292FB2B0004A9BDE /* Settings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = "<group>"; };
@@ -904,6 +902,7 @@
904902
6CB52DC82AC8DC3E002E75B3 /* CEWorkspaceFileManager+FileManagement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CEWorkspaceFileManager+FileManagement.swift"; sourceTree = "<group>"; };
905903
6CBA0D502A1BF524002C6FAA /* SegmentedControlImproved.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SegmentedControlImproved.swift; sourceTree = "<group>"; };
906904
6CBD1BC52978DE53006639D5 /* Font+Caption3.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Font+Caption3.swift"; sourceTree = "<group>"; };
905+
6CBE1CFA2B71DAA6003AC32E /* Loopable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Loopable.swift; sourceTree = "<group>"; };
907906
6CC9E4B129B5669900C97388 /* Environment+ActiveEditor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Environment+ActiveEditor.swift"; sourceTree = "<group>"; };
908907
6CD03B6929FC773F001BD1D0 /* SettingsInjector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsInjector.swift; sourceTree = "<group>"; };
909908
6CDA84AC284C1BA000C1CC3A /* EditorTabBarContextMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditorTabBarContextMenu.swift; sourceTree = "<group>"; };
@@ -1070,9 +1069,10 @@
10701069
6C66C31329D05CDC00DE9ED2 /* GRDB in Frameworks */,
10711070
58F2EB1E292FB954004A9BDE /* Sparkle in Frameworks */,
10721071
6C2149412A1BB9AB00748382 /* LogStream in Frameworks */,
1072+
6CBE1D002B720565003AC32E /* CodeEditSourceEditor in Frameworks */,
10731073
6C147C4529A329350089B630 /* OrderedCollections in Frameworks */,
10741074
6C6BD6F429CD142C00235D17 /* CollectionConcurrencyKit in Frameworks */,
1075-
6CE952E32B29433500C29C31 /* CodeEditSourceEditor in Frameworks */,
1075+
6CB446402B6DFF3A00539ED0 /* CodeEditSourceEditor in Frameworks */,
10761076
5879828A292ED15F0085B254 /* SwiftTerm in Frameworks */,
10771077
6CDEFC9629E22C2700B7C684 /* Introspect in Frameworks */,
10781078
2816F594280CF50500DD548B /* CodeEditSymbols in Frameworks */,
@@ -1463,7 +1463,7 @@
14631463
5831E3C92933E83400D5A6D2 /* Protocols */ = {
14641464
isa = PBXGroup;
14651465
children = (
1466-
58F2EACD292FB2B0004A9BDE /* Loopable.swift */,
1466+
6CBE1CFA2B71DAA6003AC32E /* Loopable.swift */,
14671467
852C7E322A587279006BA599 /* SearchableSettingsPage.swift */,
14681468
);
14691469
path = Protocols;
@@ -2188,7 +2188,6 @@
21882188
5831E3C92933E83400D5A6D2 /* Protocols */,
21892189
5875680E29316BDC00C965A3 /* ShellClient */,
21902190
6C5C891A2A3F736500A94FE1 /* FocusedValues.swift */,
2191-
587B9D54292FC27A00AC7927 /* FolderMonitor.swift */,
21922191
);
21932192
path = Utils;
21942193
sourceTree = "<group>";
@@ -3032,7 +3031,8 @@
30323031
6CDEFC9529E22C2700B7C684 /* Introspect */,
30333032
6C0F3A3B2A1D0D5000223D19 /* CodeEditKit */,
30343033
6C5BE5212A3D5666002DA0FC /* WindowManagement */,
3035-
6CE952E22B29433500C29C31 /* CodeEditSourceEditor */,
3034+
6CB4463F2B6DFF3A00539ED0 /* CodeEditSourceEditor */,
3035+
6CBE1CFF2B720565003AC32E /* CodeEditSourceEditor */,
30363036
);
30373037
productName = CodeEdit;
30383038
productReference = B658FB2C27DA9E0F00EA4DBD /* CodeEdit.app */;
@@ -3128,7 +3128,7 @@
31283128
6CDEFC9429E22C2700B7C684 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */,
31293129
6C0F3A3A2A1D0D5000223D19 /* XCRemoteSwiftPackageReference "CodeEditKit" */,
31303130
6C5BE5202A3D5666002DA0FC /* XCRemoteSwiftPackageReference "SwiftUI-WindowManagement" */,
3131-
6CE952E12B29433500C29C31 /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */,
3131+
6CBE1CFE2B720565003AC32E /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */,
31323132
);
31333133
productRefGroup = B658FB2D27DA9E0F00EA4DBD /* Products */;
31343134
projectDirPath = "";
@@ -3386,6 +3386,7 @@
33863386
58822528292C280D00E83CDE /* StatusBarEncodingSelector.swift in Sources */,
33873387
6C7F37FE2A3EA6FA00217B83 /* View+focusedValue.swift in Sources */,
33883388
B6C4F2A12B3CA37500B2B140 /* SourceControlNavigatorHistoryView.swift in Sources */,
3389+
6CBE1CFB2B71DAA6003AC32E /* Loopable.swift in Sources */,
33893390
B6C6A43029771F7100A3D28F /* EditorTabBackground.swift in Sources */,
33903391
B60718372B170638009CDAB4 /* SourceControlNavigatorRenameBranchView.swift in Sources */,
33913392
6C578D8129CD294800DC73B2 /* ExtensionActivatorView.swift in Sources */,
@@ -3395,7 +3396,6 @@
33953396
9D36E1BF2B5E7D7500443C41 /* GitBranchesGroup.swift in Sources */,
33963397
587B9E8229301D8F00AC7927 /* GitHubPreviewHeader.swift in Sources */,
33973398
611191FC2B08CCB800D4459B /* SearchIndexer+AsyncController.swift in Sources */,
3398-
58F2EB02292FB2B0004A9BDE /* Loopable.swift in Sources */,
33993399
6C578D8929CD36E400DC73B2 /* Commands+ForEach.swift in Sources */,
34003400
611192082B08CCFD00D4459B /* SearchIndexer+Terms.swift in Sources */,
34013401
28B8F884280FFE4600596236 /* NSTableView+Background.swift in Sources */,
@@ -3429,7 +3429,6 @@
34293429
6C2C155A29B4F4CC00EA60A5 /* Variadic.swift in Sources */,
34303430
B6E41C8F29DE9CD80088F9F4 /* AccountsSettingsDetailsView.swift in Sources */,
34313431
5882252B292C280D00E83CDE /* StatusBarCursorLocationLabel.swift in Sources */,
3432-
587B9D57292FC27A00AC7927 /* FolderMonitor.swift in Sources */,
34333432
58798252292E78D80085B254 /* ImageFileView.swift in Sources */,
34343433
5882252D292C280D00E83CDE /* StatusBarSplitTerminalButton.swift in Sources */,
34353434
58798238292E30B90085B254 /* FeedbackWindowController.swift in Sources */,
@@ -4665,20 +4664,20 @@
46654664
minimumVersion = 0.2.0;
46664665
};
46674666
};
4668-
6CDEFC9429E22C2700B7C684 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = {
4667+
6CBE1CFE2B720565003AC32E /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */ = {
46694668
isa = XCRemoteSwiftPackageReference;
4670-
repositoryURL = "https://github.com/siteline/SwiftUI-Introspect";
4669+
repositoryURL = "https://github.com/CodeEditApp/CodeEditSourceEditor";
46714670
requirement = {
46724671
kind = upToNextMajorVersion;
4673-
minimumVersion = 0.2.3;
4672+
minimumVersion = 0.7.0;
46744673
};
46754674
};
4676-
6CE952E12B29433500C29C31 /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */ = {
4675+
6CDEFC9429E22C2700B7C684 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = {
46774676
isa = XCRemoteSwiftPackageReference;
4678-
repositoryURL = "https://github.com/CodeEditApp/CodeEditSourceEditor.git";
4677+
repositoryURL = "https://github.com/siteline/SwiftUI-Introspect";
46794678
requirement = {
46804679
kind = upToNextMajorVersion;
4681-
minimumVersion = 0.7.0;
4680+
minimumVersion = 0.2.3;
46824681
};
46834682
};
46844683
/* End XCRemoteSwiftPackageReference section */
@@ -4748,16 +4747,20 @@
47484747
package = 6C147C4329A329350089B630 /* XCRemoteSwiftPackageReference "swift-collections" */;
47494748
productName = DequeModule;
47504749
};
4751-
6CDEFC9529E22C2700B7C684 /* Introspect */ = {
4750+
6CB4463F2B6DFF3A00539ED0 /* CodeEditSourceEditor */ = {
47524751
isa = XCSwiftPackageProductDependency;
4753-
package = 6CDEFC9429E22C2700B7C684 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */;
4754-
productName = Introspect;
4752+
productName = CodeEditSourceEditor;
47554753
};
4756-
6CE952E22B29433500C29C31 /* CodeEditSourceEditor */ = {
4754+
6CBE1CFF2B720565003AC32E /* CodeEditSourceEditor */ = {
47574755
isa = XCSwiftPackageProductDependency;
4758-
package = 6CE952E12B29433500C29C31 /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */;
4756+
package = 6CBE1CFE2B720565003AC32E /* XCRemoteSwiftPackageReference "CodeEditSourceEditor" */;
47594757
productName = CodeEditSourceEditor;
47604758
};
4759+
6CDEFC9529E22C2700B7C684 /* Introspect */ = {
4760+
isa = XCSwiftPackageProductDependency;
4761+
package = 6CDEFC9429E22C2700B7C684 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */;
4762+
productName = Introspect;
4763+
};
47614764
/* End XCSwiftPackageProductDependency section */
47624765
};
47634766
rootObject = B658FB2427DA9E0F00EA4DBD /* Project object */;

CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CodeEdit/CodeEditApp.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ struct CodeEditApp: App {
2727
var body: some Scene {
2828
Group {
2929
WelcomeWindow()
30-
.keyboardShortcut("1", modifiers: [.command, .shift])
3130

3231
ExtensionManagerWindow()
33-
.keyboardShortcut("2", modifiers: [.command, .shift])
3432

3533
AboutWindow()
3634

CodeEdit/Features/Documents/WorkspaceDocument.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ final class WorkspaceDocument: NSDocument, ObservableObject, NSToolbarDelegate {
111111

112112
private func initWorkspaceState(_ url: URL) throws {
113113
self.fileURL = url
114+
self.displayName = url.lastPathComponent
115+
114116
let sourceControlManager = SourceControlManager(
115117
workspaceURL: url,
116118
editorManager: editorManager

CodeEdit/Features/WindowCommands/CodeEditCommands.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import SwiftUI
99

1010
struct CodeEditCommands: Commands {
11-
1211
var body: some Commands {
1312
MainCommands()
1413
FileCommands()

CodeEdit/Features/WindowCommands/FileCommands.swift

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,24 @@ struct FileCommands: Commands {
3737

3838
CommandGroup(replacing: .saveItem) {
3939
Button("Close Tab") {
40-
NSApp.sendAction(#selector(CodeEditWindowController.closeCurrentTab(_:)), to: nil, from: nil)
40+
if NSApp.target(forAction: #selector(CodeEditWindowController.closeCurrentTab(_:))) != nil {
41+
NSApp.sendAction(#selector(CodeEditWindowController.closeCurrentTab(_:)), to: nil, from: nil)
42+
} else {
43+
NSApp.sendAction(#selector(NSWindow.close), to: nil, from: nil)
44+
}
4145
}
4246
.keyboardShortcut("w")
4347

4448
Button("Close Editor") {
45-
NSApp.sendAction(#selector(CodeEditWindowController.closeActiveEditor(_:)), to: nil, from: nil)
49+
if NSApp.target(forAction: #selector(CodeEditWindowController.closeActiveEditor(_:))) != nil {
50+
NSApp.sendAction(
51+
#selector(CodeEditWindowController.closeActiveEditor(_:)),
52+
to: nil,
53+
from: nil
54+
)
55+
} else {
56+
NSApp.sendAction(#selector(NSWindow.close), to: nil, from: nil)
57+
}
4658
}
4759
.keyboardShortcut("w", modifiers: [.control, .shift, .command])
4860

@@ -52,10 +64,11 @@ struct FileCommands: Commands {
5264
.keyboardShortcut("w", modifiers: [.shift, .command])
5365

5466
Button("Close Workspace") {
55-
// TODO: Determine how this is different than the "Close Window" command and adjust accordingly
56-
NSApp.sendAction(#selector(NSWindow.close), to: nil, from: nil)
67+
guard let keyWindow = NSApplication.shared.keyWindow else { return }
68+
NSApp.sendAction(#selector(NSWindow.close), to: keyWindow, from: nil)
5769
}
5870
.keyboardShortcut("w", modifiers: [.control, .option, .command])
71+
.disabled(!(NSApplication.shared.keyWindow?.windowController is CodeEditWindowController))
5972

6073
if let utilityAreaViewModel {
6174
Button("Close Terminal") {

0 commit comments

Comments
 (0)