@@ -148,36 +148,40 @@ export class NotebookAdapter extends WidgetAdapter<NotebookPanel> {
148
148
let convertedToMarkdownOrRaw = [ ] ;
149
149
let convertedToCode = [ ] ;
150
150
151
- if ( change . newValues . length ! == change . oldValues . length ) {
151
+ if ( change . newValues . length = == change . oldValues . length ) {
152
152
// during conversion the cells should not get deleted nor added
153
- return ;
154
- }
155
-
156
- for ( let i = 0 ; i < change . newValues . length ; i ++ ) {
157
- if (
158
- change . oldValues [ i ] . type === 'code' &&
159
- change . newValues [ i ] . type !== 'code'
160
- ) {
161
- convertedToMarkdownOrRaw . push ( change . newValues [ i ] ) ;
162
- } else if (
163
- change . oldValues [ i ] . type !== 'code' &&
164
- change . newValues [ i ] . type === 'code'
165
- ) {
166
- convertedToCode . push ( change . newValues [ i ] ) ;
153
+ for ( let i = 0 ; i < change . newValues . length ; i ++ ) {
154
+ if (
155
+ change . oldValues [ i ] . type === 'code' &&
156
+ change . newValues [ i ] . type !== 'code'
157
+ ) {
158
+ convertedToMarkdownOrRaw . push ( change . newValues [ i ] ) ;
159
+ } else if (
160
+ change . oldValues [ i ] . type !== 'code' &&
161
+ change . newValues [ i ] . type === 'code'
162
+ ) {
163
+ convertedToCode . push ( change . newValues [ i ] ) ;
164
+ }
167
165
}
166
+ cellsAdded = convertedToCode ;
167
+ cellsRemoved = convertedToMarkdownOrRaw ;
168
168
}
169
- cellsAdded = convertedToCode ;
170
- cellsRemoved = convertedToMarkdownOrRaw ;
171
-
172
169
} else if ( change . type == 'add' ) {
173
- cellsAdded = change . newValues . filter ( ( cellModel ) => cellModel . type === 'code' )
170
+ cellsAdded = change . newValues . filter (
171
+ cellModel => cellModel . type === 'code'
172
+ ) ;
174
173
}
175
174
// note: editorRemoved is not emitted for removal of cells by change of type 'remove' (but only during cell type conversion)
176
175
// because there is no easy way to get the widget associated with the removed cell(s) - because it is no
177
176
// longer in the notebook widget list! It would need to be tracked on our side, but it is not necessary
178
177
// as (except for a tiny memory leak) it should not impact the functionality in any way
179
178
180
- if ( cellsRemoved . length || cellsAdded . length || change . type === 'move' || change . type === 'remove' ) {
179
+ if (
180
+ cellsRemoved . length ||
181
+ cellsAdded . length ||
182
+ change . type === 'move' ||
183
+ change . type === 'remove'
184
+ ) {
181
185
// in contrast to the file editor document which can be only changed by the modification of the editor content,
182
186
// the notebook document cna also get modified by a change in the number or arrangement of editors themselves;
183
187
// for this reason each change has to trigger documents update (so that LSP mirror is in sync).
@@ -188,7 +192,7 @@ export class NotebookAdapter extends WidgetAdapter<NotebookPanel> {
188
192
let cellWidget = this . widget . content . widgets . find (
189
193
cell => cell . model . id === cellModel . id
190
194
) ;
191
- this . known_editors_ids . delete ( cellWidget . editor . uuid )
195
+ this . known_editors_ids . delete ( cellWidget . editor . uuid ) ;
192
196
193
197
// for practical purposes this editor got removed from our consideration;
194
198
// it might seem that we should instead look for the editor indicated by
@@ -203,13 +207,12 @@ export class NotebookAdapter extends WidgetAdapter<NotebookPanel> {
203
207
let cellWidget = this . widget . content . widgets . find (
204
208
cell => cell . model . id === cellModel . id
205
209
) ;
206
- this . known_editors_ids . add ( cellWidget . editor . uuid )
210
+ this . known_editors_ids . add ( cellWidget . editor . uuid ) ;
207
211
208
212
this . editorAdded . emit ( {
209
213
editor : cellWidget . editor
210
214
} ) ;
211
215
}
212
-
213
216
} ) ;
214
217
}
215
218
0 commit comments