@@ -74,15 +74,22 @@ extension Configuration {
7474 ///
7575 /// - Parameters:
7676 /// - configuration: The new value to set for ``Configuration/current``.
77+ /// - addingToAll: Whether to add this configuration to the set of implicitly-tracked ``Configuration``s that are told about detached Issues.
7778 /// - body: A function to call.
7879 ///
7980 /// - Returns: Whatever is returned by `body`.
8081 ///
8182 /// - Throws: Whatever is thrown by `body`.
82- static func withCurrent< R> ( _ configuration: Self , perform body: ( ) throws -> R ) rethrows -> R {
83- let id = configuration. _addToAll ( )
83+ static func withCurrent< R> (
84+ _ configuration: Self ,
85+ addingToAll: Bool = true ,
86+ perform body: ( ) throws -> R
87+ ) rethrows -> R {
88+ let id = addingToAll ? configuration. _addToAll ( ) : nil
8489 defer {
85- configuration. _removeFromAll ( identifiedBy: id)
90+ if let id {
91+ configuration. _removeFromAll ( identifiedBy: id)
92+ }
8693 }
8794
8895 var runtimeState = Runner . RuntimeState. current ?? . init( )
@@ -95,15 +102,22 @@ extension Configuration {
95102 ///
96103 /// - Parameters:
97104 /// - configuration: The new value to set for ``Configuration/current``.
105+ /// - addingToAll: Whether to add this configuration to the set of implicitly-tracked ``Configuration``s that are told about detached Issues.
98106 /// - body: A function to call.
99107 ///
100108 /// - Returns: Whatever is returned by `body`.
101109 ///
102110 /// - Throws: Whatever is thrown by `body`.
103- static func withCurrent< R> ( _ configuration: Self , perform body: ( ) async throws -> R ) async rethrows -> R {
104- let id = configuration. _addToAll ( )
111+ static func withCurrent< R> (
112+ _ configuration: Self ,
113+ addingToAll: Bool = true ,
114+ perform body: ( ) async throws -> R
115+ ) async rethrows -> R {
116+ let id = addingToAll ? configuration. _addToAll ( ) : nil
105117 defer {
106- configuration. _removeFromAll ( identifiedBy: id)
118+ if let id {
119+ configuration. _removeFromAll ( identifiedBy: id)
120+ }
107121 }
108122
109123 var runtimeState = Runner . RuntimeState. current ?? . init( )
0 commit comments