Skip to content

Commit 919e071

Browse files
committed
FIXED: Make cells selection better compatible.
1. All global cells (.nbcell.background:not(.below)) 2. All _below_ cells above current cell (.nbcell.background.below) 3. The last local cell above the current cell if there are no other program cells in between.
1 parent 891c5eb commit 919e071

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

web/js/notebook.js

+23-13
Original file line numberDiff line numberDiff line change
@@ -1357,9 +1357,15 @@ CodeMirror.modes.eval = CodeMirror.modes.prolog;
13571357

13581358
/**
13591359
* 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+
*
13631369
* @return {jQuery} set of nbCell elements that form the
13641370
* sources for the receiving query cell.
13651371
*/
@@ -1373,24 +1379,28 @@ CodeMirror.modes.eval = CodeMirror.modes.prolog;
13731379
const c = $(this);
13741380
if ( c.hasClass("program") )
13751381
{ 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+
}
13821393
}
13831394
if ( c.is(elem) )
13841395
{ if ( local )
1385-
programs.push(local[0]);
1396+
{ programs.push(local[0]);
1397+
local = undefined;
1398+
}
13861399
before = false;
13871400
}
1388-
if ( c.hasClass("query") )
1389-
local = undefined;
13901401
});
13911402

13921403
const jprograms = $(programs);
1393-
console.log(jprograms);
13941404
return jprograms;
13951405
},
13961406

0 commit comments

Comments
 (0)