@@ -141,50 +141,60 @@ public bool IsMutatingBreakpoints
141
141
142
142
public async Task UpdatedByServerAsync ( BreakpointUpdatedEventArgs eventArgs )
143
143
{
144
- if ( ! _map . ByPwshId . TryGetValue ( eventArgs . Breakpoint . Id , out SyncedBreakpoint existing ) )
144
+ if ( _map . ByPwshId . TryGetValue ( eventArgs . Breakpoint . Id , out SyncedBreakpoint existing ) )
145
145
{
146
- // If we haven't told the client about the breakpoint yet then we can just ignore.
147
- if ( eventArgs . UpdateType is BreakpointUpdateType . Removed )
148
- {
149
- return ;
150
- }
151
-
152
- existing = CreateFromServerBreakpoint ( eventArgs . Breakpoint ) ;
153
- string ? id = await SendToClientAsync ( existing . Client , BreakpointUpdateType . Set )
154
- . ConfigureAwait ( false ) ;
155
-
156
- existing . Client . Id = id ! ;
157
- RegisterBreakpoint ( existing ) ;
146
+ await ProcessExistingBreakpoint ( eventArgs , existing ) . ConfigureAwait ( false ) ;
158
147
return ;
159
148
}
160
149
150
+ // If we haven't told the client about the breakpoint yet then we can just ignore.
161
151
if ( eventArgs . UpdateType is BreakpointUpdateType . Removed )
162
152
{
163
- UnregisterBreakpoint ( existing ) ;
164
- await SendToClientAsync ( existing . Client , BreakpointUpdateType . Removed ) . ConfigureAwait ( false ) ;
165
153
return ;
166
154
}
167
155
168
- if ( eventArgs . UpdateType is BreakpointUpdateType . Enabled or BreakpointUpdateType . Disabled )
156
+ SyncedBreakpoint newBreakpoint = CreateFromServerBreakpoint ( eventArgs . Breakpoint ) ;
157
+ string ? id = await SendToClientAsync ( newBreakpoint . Client , BreakpointUpdateType . Set )
158
+ . ConfigureAwait ( false ) ;
159
+
160
+ if ( id is null )
161
+ {
162
+ LogBreakpointError ( newBreakpoint , "Did not receive a breakpoint ID from the client." ) ;
163
+ }
164
+
165
+ newBreakpoint . Client . Id = id ;
166
+ RegisterBreakpoint ( newBreakpoint ) ;
167
+
168
+ async Task ProcessExistingBreakpoint ( BreakpointUpdatedEventArgs eventArgs , SyncedBreakpoint existing )
169
169
{
170
- await SendToClientAsync ( existing . Client , eventArgs . UpdateType ) . ConfigureAwait ( false ) ;
171
- bool isActive = eventArgs . UpdateType is BreakpointUpdateType . Enabled ;
172
- SyncedBreakpoint newBreakpoint = existing with
170
+ if ( eventArgs . UpdateType is BreakpointUpdateType . Removed )
171
+ {
172
+ UnregisterBreakpoint ( existing ) ;
173
+ await SendToClientAsync ( existing . Client , BreakpointUpdateType . Removed ) . ConfigureAwait ( false ) ;
174
+ return ;
175
+ }
176
+
177
+ if ( eventArgs . UpdateType is BreakpointUpdateType . Enabled or BreakpointUpdateType . Disabled )
173
178
{
174
- Client = existing . Client with
179
+ await SendToClientAsync ( existing . Client , eventArgs . UpdateType ) . ConfigureAwait ( false ) ;
180
+ bool isActive = eventArgs . UpdateType is BreakpointUpdateType . Enabled ;
181
+ SyncedBreakpoint newBreakpoint = existing with
175
182
{
176
- Enabled = isActive ,
177
- } ,
178
- } ;
183
+ Client = existing . Client with
184
+ {
185
+ Enabled = isActive ,
186
+ } ,
187
+ } ;
179
188
180
- UnregisterBreakpoint ( existing ) ;
181
- RegisterBreakpoint ( newBreakpoint ) ;
182
- return ;
183
- }
189
+ UnregisterBreakpoint ( existing ) ;
190
+ RegisterBreakpoint ( newBreakpoint ) ;
191
+ return ;
192
+ }
184
193
185
- LogBreakpointError (
186
- existing ,
187
- "Somehow we're syncing a new breakpoint that we've already sync'd. That's not supposed to happen." ) ;
194
+ LogBreakpointError (
195
+ existing ,
196
+ "Somehow we're syncing a new breakpoint that we've already sync'd. That's not supposed to happen." ) ;
197
+ }
188
198
}
189
199
190
200
public IReadOnlyList < SyncedBreakpoint > GetSyncedBreakpoints ( ) => _map . ByGuid . Values . ToArray ( ) ;
@@ -521,7 +531,6 @@ private static SyncedBreakpoint CreateFromServerBreakpoint(Breakpoint serverBrea
521
531
else if ( serverBreakpoint is LineBreakpoint lbp )
522
532
{
523
533
location = new ClientLocation (
524
- // TODO: fix the translation of this
525
534
lbp . Script ,
526
535
new Range (
527
536
lbp . Line - 1 ,
0 commit comments