mirror of
https://github.com/h3pdesign/Neon-Vision-Editor
synced 2026-04-21 13:27:16 +00:00
Fix Cmd+W close flow to confirm unsaved editor tabs
This commit is contained in:
parent
36a453c232
commit
62b0d70189
5 changed files with 12 additions and 7 deletions
|
|
@ -361,7 +361,7 @@
|
|||
CODE_SIGNING_ALLOWED = YES;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 429;
|
||||
CURRENT_PROJECT_VERSION = 430;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEVELOPMENT_TEAM = CS727NF72U;
|
||||
ENABLE_APP_SANDBOX = YES;
|
||||
|
|
@ -444,7 +444,7 @@
|
|||
CODE_SIGNING_ALLOWED = YES;
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 429;
|
||||
CURRENT_PROJECT_VERSION = 430;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEVELOPMENT_TEAM = CS727NF72U;
|
||||
ENABLE_APP_SANDBOX = YES;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import FoundationModels
|
|||
|
||||
struct NeonVisionMacAppCommands: Commands {
|
||||
let activeEditorViewModel: () -> EditorViewModel
|
||||
let hasActiveEditorWindow: () -> Bool
|
||||
let openNewWindow: () -> Void
|
||||
let openAIDiagnosticsWindow: () -> Void
|
||||
let postWindowCommand: (_ name: Notification.Name, _ object: Any?) -> Void
|
||||
|
|
@ -121,13 +122,10 @@ struct NeonVisionMacAppCommands: Commands {
|
|||
Divider()
|
||||
|
||||
Button("Close Tab") {
|
||||
let current = activeEditorViewModel()
|
||||
if let tab = current.selectedTab {
|
||||
current.closeTab(tabID: tab.id)
|
||||
}
|
||||
post(.closeSelectedTabRequested)
|
||||
}
|
||||
.keyboardShortcut("w", modifiers: .command)
|
||||
.disabled(!hasSelectedTab)
|
||||
.disabled(!hasActiveEditorWindow() || !hasSelectedTab)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -368,6 +368,7 @@ struct NeonVisionEditorApp: App {
|
|||
.commands {
|
||||
NeonVisionMacAppCommands(
|
||||
activeEditorViewModel: { activeEditorViewModel },
|
||||
hasActiveEditorWindow: { WindowViewModelRegistry.shared.activeViewModel() != nil },
|
||||
openNewWindow: { openWindow(id: "blank-window") },
|
||||
openAIDiagnosticsWindow: { openWindow(id: "ai-logs") },
|
||||
postWindowCommand: { name, object in
|
||||
|
|
|
|||
|
|
@ -1612,6 +1612,11 @@ struct ContentView: View {
|
|||
openSettings()
|
||||
}
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: .closeSelectedTabRequested)) { notif in
|
||||
guard matchesCurrentWindow(notif) else { return }
|
||||
guard let tab = viewModel.selectedTab else { return }
|
||||
requestCloseTab(tab)
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: .showUpdaterRequested)) { notif in
|
||||
guard matchesCurrentWindow(notif) else { return }
|
||||
let shouldCheckNow = (notif.object as? Bool) ?? true
|
||||
|
|
|
|||
|
|
@ -777,6 +777,7 @@ extension Notification.Name {
|
|||
static let keyboardAccessoryBarVisibilityChanged = Notification.Name("keyboardAccessoryBarVisibilityChanged")
|
||||
static let showUpdaterRequested = Notification.Name("showUpdaterRequested")
|
||||
static let showSettingsRequested = Notification.Name("showSettingsRequested")
|
||||
static let closeSelectedTabRequested = Notification.Name("closeSelectedTabRequested")
|
||||
}
|
||||
|
||||
extension NSRange {
|
||||
|
|
|
|||
Loading…
Reference in a new issue