Skip to content

Commit 7aa48c1

Browse files
krassowskiianhi
andauthored
Fix scrolling on g g and G (#137)
* Fix scrolling on `g g` and `G` * Ensure cell is focused after scrolling Co-authored-by: ianhi <[email protected]> * Lint --------- Co-authored-by: ianhi <[email protected]>
1 parent a6520ef commit 7aa48c1

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
"@lumino/commands": "^2.0.1",
6868
"@lumino/coreutils": "^2.0.0",
6969
"@lumino/disposable": "^2.1.2",
70-
"@lumino/domutils": "^2.0.0",
7170
"@replit/codemirror-vim": "^6.0.14",
7271
"react": "^18.2.0"
7372
},

src/labCommands.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
import { ReadonlyPartialJSONObject } from '@lumino/coreutils';
1111

1212
import { IDisposable } from '@lumino/disposable';
13-
import { ElementExt } from '@lumino/domutils';
1413

1514
export function addNotebookCommands(
1615
app: JupyterFrontEnd,
@@ -238,37 +237,35 @@ export function addNotebookCommands(
238237
}),
239238
commands.addCommand('vim:select-first-cell', {
240239
label: 'Select First Cell',
241-
execute: args => {
240+
execute: async args => {
242241
const current = getCurrent(args);
243242

244243
if (current) {
245244
const { content } = current;
246245
content.activeCellIndex = 0;
247246
content.deselectAll();
248247
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();
253251
}
254252
}
255253
},
256254
isEnabled
257255
}),
258256
commands.addCommand('vim:select-last-cell', {
259257
label: 'Select Last Cell',
260-
execute: args => {
258+
execute: async args => {
261259
const current = getCurrent(args);
262260

263261
if (current) {
264262
const { content } = current;
265263
content.activeCellIndex = current.content.widgets.length - 1;
266264
content.deselectAll();
267265
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();
272269
}
273270
}
274271
},

yarn.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ __metadata:
3131
"@lumino/commands": ^2.0.1
3232
"@lumino/coreutils": ^2.0.0
3333
"@lumino/disposable": ^2.1.2
34-
"@lumino/domutils": ^2.0.0
3534
"@replit/codemirror-vim": ^6.0.14
3635
"@types/codemirror": ^0.0.87
3736
"@types/json-schema": ^7.0.11

0 commit comments

Comments
 (0)