Skip to content

Commit

Permalink
Fix scrolling on g g and G (#137)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
krassowski and ianhi authored Feb 8, 2024
1 parent a6520ef commit 7aa48c1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"@lumino/commands": "^2.0.1",
"@lumino/coreutils": "^2.0.0",
"@lumino/disposable": "^2.1.2",
"@lumino/domutils": "^2.0.0",
"@replit/codemirror-vim": "^6.0.14",
"react": "^18.2.0"
},
Expand Down
19 changes: 8 additions & 11 deletions src/labCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import { ReadonlyPartialJSONObject } from '@lumino/coreutils';

import { IDisposable } from '@lumino/disposable';
import { ElementExt } from '@lumino/domutils';

export function addNotebookCommands(
app: JupyterFrontEnd,
Expand Down Expand Up @@ -238,37 +237,35 @@ export function addNotebookCommands(
}),
commands.addCommand('vim:select-first-cell', {
label: 'Select First Cell',
execute: args => {
execute: async args => {
const current = getCurrent(args);

if (current) {
const { content } = current;
content.activeCellIndex = 0;
content.deselectAll();
if (content.activeCell !== null) {
ElementExt.scrollIntoViewIfNeeded(
content.node,
content.activeCell.node
);
// note: using `scrollToItem` because `scrollToCell` changes mode (activate the cell)
await content.scrollToItem(content.activeCellIndex, 'smart');
content.activeCell.node.focus();
}
}
},
isEnabled
}),
commands.addCommand('vim:select-last-cell', {
label: 'Select Last Cell',
execute: args => {
execute: async args => {
const current = getCurrent(args);

if (current) {
const { content } = current;
content.activeCellIndex = current.content.widgets.length - 1;
content.deselectAll();
if (content.activeCell !== null) {
ElementExt.scrollIntoViewIfNeeded(
content.node,
content.activeCell.node
);
// note: using `scrollToItem` because `scrollToCell` changes mode (activates the cell)
await content.scrollToItem(content.activeCellIndex, 'smart');
content.activeCell.node.focus();
}
}
},
Expand Down
1 change: 0 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ __metadata:
"@lumino/commands": ^2.0.1
"@lumino/coreutils": ^2.0.0
"@lumino/disposable": ^2.1.2
"@lumino/domutils": ^2.0.0
"@replit/codemirror-vim": ^6.0.14
"@types/codemirror": ^0.0.87
"@types/json-schema": ^7.0.11
Expand Down

0 comments on commit 7aa48c1

Please sign in to comment.