@@ -1357,9 +1357,15 @@ CodeMirror.modes.eval = CodeMirror.modes.prolog;
1357
1357
1358
1358
/**
1359
1359
* Returns all program cells in current notebook that are loaded
1360
- * for executing the current cell. This always starts with the
1361
- * background programs. If `this` is a program cell, it is added.
1362
- * Otherwise the program cell before `this` is added.
1360
+ * for executing the current cell. These are
1361
+ *
1362
+ * - All global cells (.nbcell.background:not(.below))
1363
+ * - All _below_ cells above current cell (.nbcell.background.below)
1364
+ * - The last local cell above the current cell if there
1365
+ * are no other program cells in between.
1366
+ *
1367
+ * The order of the set is defined by the order on the page.
1368
+ *
1363
1369
* @return {jQuery } set of nbCell elements that form the
1364
1370
* sources for the receiving query cell.
1365
1371
*/
@@ -1373,24 +1379,28 @@ CodeMirror.modes.eval = CodeMirror.modes.prolog;
1373
1379
const c = $ ( this ) ;
1374
1380
if ( c . hasClass ( "program" ) )
1375
1381
{ const scope = c . nbCell ( 'scope' ) ;
1376
- if ( scope == 'global' )
1377
- programs . push ( c [ 0 ] ) ;
1378
- else if ( scope == 'below' && before )
1379
- programs . push ( c [ 0 ] ) ;
1380
- else if ( scope == 'local' )
1381
- local = c ;
1382
+ if ( scope == 'local' )
1383
+ { if ( before )
1384
+ local = c ;
1385
+ } else
1386
+ { local = 'undefined' ;
1387
+
1388
+ if ( scope == 'global' )
1389
+ programs . push ( c [ 0 ] ) ;
1390
+ else if ( scope == 'below' && before )
1391
+ programs . push ( c [ 0 ] ) ;
1392
+ }
1382
1393
}
1383
1394
if ( c . is ( elem ) )
1384
1395
{ if ( local )
1385
- programs . push ( local [ 0 ] ) ;
1396
+ { programs . push ( local [ 0 ] ) ;
1397
+ local = undefined ;
1398
+ }
1386
1399
before = false ;
1387
1400
}
1388
- if ( c . hasClass ( "query" ) )
1389
- local = undefined ;
1390
1401
} ) ;
1391
1402
1392
1403
const jprograms = $ ( programs ) ;
1393
- console . log ( jprograms ) ;
1394
1404
return jprograms ;
1395
1405
} ,
1396
1406
0 commit comments