@@ -10,7 +10,6 @@ import {
10
10
import { ReadonlyPartialJSONObject } from '@lumino/coreutils' ;
11
11
12
12
import { IDisposable } from '@lumino/disposable' ;
13
- import { ElementExt } from '@lumino/domutils' ;
14
13
15
14
export function addNotebookCommands (
16
15
app : JupyterFrontEnd ,
@@ -238,37 +237,35 @@ export function addNotebookCommands(
238
237
} ) ,
239
238
commands . addCommand ( 'vim:select-first-cell' , {
240
239
label : 'Select First Cell' ,
241
- execute : args => {
240
+ execute : async args => {
242
241
const current = getCurrent ( args ) ;
243
242
244
243
if ( current ) {
245
244
const { content } = current ;
246
245
content . activeCellIndex = 0 ;
247
246
content . deselectAll ( ) ;
248
247
if ( content . activeCell !== null ) {
249
- ElementExt . scrollIntoViewIfNeeded (
250
- content . node ,
251
- content . activeCell . node
252
- ) ;
248
+ // note: using `scrollToItem` because `scrollToCell` changes mode (activate the cell)
249
+ await content . scrollToItem ( content . activeCellIndex , 'smart' ) ;
250
+ content . activeCell . node . focus ( ) ;
253
251
}
254
252
}
255
253
} ,
256
254
isEnabled
257
255
} ) ,
258
256
commands . addCommand ( 'vim:select-last-cell' , {
259
257
label : 'Select Last Cell' ,
260
- execute : args => {
258
+ execute : async args => {
261
259
const current = getCurrent ( args ) ;
262
260
263
261
if ( current ) {
264
262
const { content } = current ;
265
263
content . activeCellIndex = current . content . widgets . length - 1 ;
266
264
content . deselectAll ( ) ;
267
265
if ( content . activeCell !== null ) {
268
- ElementExt . scrollIntoViewIfNeeded (
269
- content . node ,
270
- content . activeCell . node
271
- ) ;
266
+ // note: using `scrollToItem` because `scrollToCell` changes mode (activates the cell)
267
+ await content . scrollToItem ( content . activeCellIndex , 'smart' ) ;
268
+ content . activeCell . node . focus ( ) ;
272
269
}
273
270
}
274
271
} ,
0 commit comments