Skip to content

Commit 68b5d67

Browse files
committed
Fix app launch option.
1 parent a893249 commit 68b5d67

File tree

3 files changed

+4
-24
lines changed

3 files changed

+4
-24
lines changed

Launcher Helper/AppDelegate.swift

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
1717
let mainAppIdentifier = CLConfiguration.bundlePrefix + ".CodeLauncher"
1818
let runningApps = NSWorkspace.shared.runningApplications
1919
let isRunning = !runningApps.filter { $0.bundleIdentifier == mainAppIdentifier }.isEmpty
20-
2120
if !isRunning {
2221
DistributedNotificationCenter.default().addObserver(self, selector: #selector(terminate), name: .killHelper, object: mainAppIdentifier)
23-
24-
let path = Bundle.main.bundlePath as NSString
25-
var components = path.pathComponents
26-
components.removeLast()
27-
components.removeLast()
28-
components.removeLast()
29-
components.append("MacOS")
30-
components.append("CodeLauncher")
31-
32-
let aPath = NSString.path(withComponents: components)
33-
if let url = URL(string: aPath) {
34-
NSWorkspace.shared.openApplication(at: url, configuration: NSWorkspace.OpenConfiguration(), completionHandler: nil)
35-
}
22+
let path = Bundle.main.bundleURL
23+
let targetPath = path.deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent().deletingLastPathComponent()
24+
NSWorkspace.shared.openApplication(at: targetPath, configuration: NSWorkspace.OpenConfiguration(), completionHandler: nil)
3625
} else {
3726
terminate()
3827
}

Launcher/Helper/CLTaskManager.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -417,17 +417,10 @@ class CLTaskManager: NSObject {
417417
let launcherAppID = CLConfiguration.bundlePrefix + ".CodeLauncher.helper"
418418
let runningApps = NSWorkspace.shared.runningApplications
419419
let isRunning = !runningApps.filter { $0.bundleIdentifier == launcherAppID }.isEmpty
420-
let currentLaunchOption = CLDefaults.default.settingsLaunchOption
421-
let succeed = SMLoginItemSetEnabled(launcherAppID as CFString, currentLaunchOption)
422420
if isRunning {
423421
DistributedNotificationCenter.default().post(name: .killHelper, object: Bundle.main.bundleIdentifier!)
424422
}
425-
426-
if !succeed {
427-
CLDefaults.default.settingsLaunchOption = false
428-
} else {
429-
CLDefaults.default.settingsLaunchOption = !currentLaunchOption
430-
}
423+
SMLoginItemSetEnabled(launcherAppID as CFString, CLDefaults.default.settingsLaunchOption)
431424
}
432425

433426
func avatarPath(forProjectID id: UUID, isEditing: Bool = false) -> URL {

Launcher/Model/CLStore.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ class CLStore: ObservableObject {
9898
@Published var activeProjects: [String] = []
9999
@Published var projectOutputs: [CLTaskOutput] = [] {
100100
didSet {
101-
102-
103101
guard let last = self.projectOutputs.last, last.projectID == self.currentProjectID else { return }
104102
DispatchQueue.main.async {
105103
NotificationCenter.default.post(name: .scrollDownToLatestConsoleOutput, object: last)

0 commit comments

Comments
 (0)