Skip to content

Commit

Permalink
Ensure cell is focused after scrolling
Browse files Browse the repository at this point in the history
Co-authored-by: ianhi <[email protected]>
  • Loading branch information
krassowski and ianhi committed Feb 8, 2024
1 parent 6e9656a commit be7c017
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/labCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export function addNotebookCommands(
}),
commands.addCommand('vim:select-first-cell', {
label: 'Select First Cell',
execute: args => {
execute: async (args) => {
const current = getCurrent(args);

if (current) {
Expand All @@ -246,24 +246,26 @@ export function addNotebookCommands(
content.deselectAll();
if (content.activeCell !== null) {
// note: using `scrollToItem` because `scrollToCell` changes mode (activate the cell)
content.scrollToItem(content.activeCellIndex, 'smart');
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) {
// note: using `scrollToItem` because `scrollToCell` changes mode (activate the cell)
content.scrollToItem(content.activeCellIndex, 'smart');
// note: using `scrollToItem` because `scrollToCell` changes mode (activates the cell)
await content.scrollToItem(content.activeCellIndex, 'smart');
content.activeCell.node.focus();
}
}
},
Expand Down

0 comments on commit be7c017

Please sign in to comment.