@@ -13,7 +13,7 @@ import { field_cmp, len } from "@cocalc/util/misc";
1313export function positions_between (
1414 before_pos : number | undefined ,
1515 after_pos : number | undefined ,
16- num : number
16+ num : number ,
1717) {
1818 // Return an array of num equally spaced positions starting after
1919 // before_pos and ending before after_pos, so
@@ -96,10 +96,10 @@ export function ensure_positions_are_unique(cells?: Map<string, any>) {
9696}
9797
9898export function new_cell_pos (
99- cells : Map < string , any > ,
99+ cells ? : Map < string , any > ,
100100 cell_list : List < string > ,
101101 cur_id : string ,
102- delta : - 1 | 1
102+ delta : - 1 | 1 ,
103103) : number {
104104 /*
105105 Returns pos for a new cell whose position
@@ -129,8 +129,8 @@ export function new_cell_pos(
129129 return false ; // break iteration
130130 }
131131 } ) ;
132- const adjacent_pos = cells . getIn ( [ adjacent_id , "pos" ] ) as number | undefined ;
133- const current_pos = cells . getIn ( [ cur_id , "pos" ] ) as number ;
132+ const adjacent_pos = cells ? .getIn ( [ adjacent_id , "pos" ] ) as number | undefined ;
133+ const current_pos = ( cells ? .getIn ( [ cur_id , "pos" ] ) ?? 0 ) as number ;
134134 let pos : number ;
135135 if ( adjacent_pos != null ) {
136136 // there is a cell after (or before) cur_id cell
@@ -145,7 +145,7 @@ export function new_cell_pos(
145145export function move_selected_cells (
146146 v ?: string [ ] ,
147147 selected ?: { [ id : string ] : true } ,
148- delta ?: number
148+ delta ?: number ,
149149) {
150150 /*
151151 - v = ordered js array of all cell id's
0 commit comments