@@ -147,6 +147,23 @@ exe_newlist(int count, ectx_T *ectx)
147147 return OK ;
148148}
149149
150+ /*
151+ * If debug_tick changed check if "ufunc" has a breakpoint and update
152+ * "uf_has_breakpoint".
153+ */
154+ static void
155+ update_has_breakpoint (ufunc_T * ufunc )
156+ {
157+ if (ufunc -> uf_debug_tick != debug_tick )
158+ {
159+ linenr_T breakpoint ;
160+
161+ ufunc -> uf_debug_tick = debug_tick ;
162+ breakpoint = dbg_find_breakpoint (FALSE, ufunc -> uf_name , 0 );
163+ ufunc -> uf_has_breakpoint = breakpoint > 0 ;
164+ }
165+ }
166+
150167/*
151168 * Call compiled function "cdf_idx" from compiled code.
152169 * This adds a stack frame and sets the instruction pointer to the start of the
@@ -1444,6 +1461,20 @@ handle_debug(isn_T *iptr, ectx_T *ectx)
14441461 garray_T ga ;
14451462 int lnum ;
14461463
1464+ if (ex_nesting_level > debug_break_level )
1465+ {
1466+ linenr_T breakpoint ;
1467+
1468+ if (!ufunc -> uf_has_breakpoint )
1469+ return ;
1470+
1471+ // check for the next breakpoint if needed
1472+ breakpoint = dbg_find_breakpoint (FALSE, ufunc -> uf_name ,
1473+ iptr -> isn_lnum - 1 );
1474+ if (breakpoint <= 0 || breakpoint > iptr -> isn_lnum )
1475+ return ;
1476+ }
1477+
14471478 SOURCING_LNUM = iptr -> isn_lnum ;
14481479 debug_context = ectx ;
14491480 debug_var_count = iptr -> isn_arg .number ;
@@ -4206,8 +4237,7 @@ exec_instructions(ectx_T *ectx)
42064237 break ;
42074238
42084239 case ISN_DEBUG :
4209- if (ex_nesting_level <= debug_break_level )
4210- handle_debug (iptr , ectx );
4240+ handle_debug (iptr , ectx );
42114241 break ;
42124242
42134243 case ISN_SHUFFLE :
@@ -4383,6 +4413,9 @@ call_def_function(
43834413#undef STACK_TV_VAR
43844414#define STACK_TV_VAR (idx ) (((typval_T *)ectx.ec_stack.ga_data) + ectx.ec_frame_idx + STACK_FRAME_SIZE + idx)
43854415
4416+ // Update uf_has_breakpoint if needed.
4417+ update_has_breakpoint (ufunc );
4418+
43864419 if (ufunc -> uf_def_status == UF_NOT_COMPILED
43874420 || ufunc -> uf_def_status == UF_COMPILE_ERROR
43884421 || (func_needs_compiling (ufunc , COMPILE_TYPE (ufunc ))
0 commit comments