@@ -113,4 +113,51 @@ void breakpoint_conditions_are_sent_to_server() throws Exception {
113113 manager .shutdown ();
114114 }
115115 }
116+
117+ @ Test
118+ void changing_breakpoint_condition_replaces_existing_entry () throws Exception {
119+ IFile file = TestUtils .createUniqueTestFile (project , "txt" , "first line\n second line\n " );
120+
121+ var bp = new DSPLineBreakpoint (file , 2 );
122+ bp .setCondition ("x > 0" );
123+ created .add (bp );
124+
125+ var server = new CapturingServer ();
126+ var manager = new DSPBreakpointManager (DebugPlugin .getDefault ().getBreakpointManager (), server , null );
127+
128+ try {
129+ // Simulate initial registration of the breakpoint with the manager
130+ manager .initialize ().join ();
131+ manager .breakpointAdded (bp );
132+
133+ // Change the condition and simulate the platform reporting the change
134+ server .calls .clear ();
135+ bp .setCondition ("x > 1" );
136+ manager .breakpointChanged (bp , null );
137+
138+ SetBreakpointsArguments matching = null ;
139+ synchronized (server .calls ) {
140+ assertTrue (!server .calls .isEmpty (),
141+ "No setBreakpoints() calls captured after breakpoint condition change" );
142+ String path = file .getLocation ().toOSString ();
143+ for (SetBreakpointsArguments a : server .calls ) {
144+ if (a .getSource () != null && path .equals (a .getSource ().getPath ())) {
145+ matching = a ;
146+ break ;
147+ }
148+ }
149+ }
150+
151+ assertNotNull (matching ,
152+ "No setBreakpoints() call for our file was captured after breakpoint condition change" );
153+ SourceBreakpoint [] sent = matching .getBreakpoints ();
154+ assertNotNull (sent );
155+ assertEquals (1 , sent .length , "Expected exactly one SourceBreakpoint after condition change" );
156+
157+ SourceBreakpoint sb = sent [0 ];
158+ assertEquals ("x > 1" , sb .getCondition ());
159+ } finally {
160+ manager .shutdown ();
161+ }
162+ }
116163}
0 commit comments