@@ -141,50 +141,60 @@ public bool IsMutatingBreakpoints
141141
142142 public async Task UpdatedByServerAsync ( BreakpointUpdatedEventArgs eventArgs )
143143 {
144- if ( ! _map . ByPwshId . TryGetValue ( eventArgs . Breakpoint . Id , out SyncedBreakpoint existing ) )
144+ if ( _map . ByPwshId . TryGetValue ( eventArgs . Breakpoint . Id , out SyncedBreakpoint existing ) )
145145 {
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 ) ;
158147 return ;
159148 }
160149
150+ // If we haven't told the client about the breakpoint yet then we can just ignore.
161151 if ( eventArgs . UpdateType is BreakpointUpdateType . Removed )
162152 {
163- UnregisterBreakpoint ( existing ) ;
164- await SendToClientAsync ( existing . Client , BreakpointUpdateType . Removed ) . ConfigureAwait ( false ) ;
165153 return ;
166154 }
167155
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 )
169169 {
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 )
173178 {
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
175182 {
176- Enabled = isActive ,
177- } ,
178- } ;
183+ Client = existing . Client with
184+ {
185+ Enabled = isActive ,
186+ } ,
187+ } ;
179188
180- UnregisterBreakpoint ( existing ) ;
181- RegisterBreakpoint ( newBreakpoint ) ;
182- return ;
183- }
189+ UnregisterBreakpoint ( existing ) ;
190+ RegisterBreakpoint ( newBreakpoint ) ;
191+ return ;
192+ }
184193
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+ }
188198 }
189199
190200 public IReadOnlyList < SyncedBreakpoint > GetSyncedBreakpoints ( ) => _map . ByGuid . Values . ToArray ( ) ;
@@ -521,7 +531,6 @@ private static SyncedBreakpoint CreateFromServerBreakpoint(Breakpoint serverBrea
521531 else if ( serverBreakpoint is LineBreakpoint lbp )
522532 {
523533 location = new ClientLocation (
524- // TODO: fix the translation of this
525534 lbp . Script ,
526535 new Range (
527536 lbp . Line - 1 ,
0 commit comments