extension Command { public var supportsWorkspaceTarget: Bool { affectsWorkspace || self == .toggleFocus || self == .toggleNoPeek || self == .toggleCleanSpace } } extension State { mutating func apply(_ command: Command, in key: WorkspaceKey, effects: inout [Effect]) -> Report? { guard displays[key.display] != nil else { return .unavailableDisplay(key.display) } guard isActive(key), workspaces[key] != nil else { return .noActiveWorkspace } guard command.supportsWorkspaceTarget else { return .unsupported } if command.endsFocus { endFocus(in: key, effects: &effects) } switch command { case .toggleFocus: toggle(.focus, in: key, effects: &effects) case .toggleNoPeek: toggle(.noPeek, in: key, effects: &effects) case .toggleCleanSpace: toggle(.cleanSpace, in: key, effects: &effects) default: applyWorkspace(command, key: key, effects: &effects) } return nil } }