diff --git a/CHANGELOG.md b/CHANGELOG.md index 7193717..cf2e136 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ - fix: override browser shift-esc in command mode [#100](https://github.com/jupyterlab-contrib/jupyterlab-vim/pull/100) ([@ianhi](https://github.com/ianhi)) - Additional thanks to [@petergthatsme](https://github.com/petergthatsme) [@firai](https://github.com/firai) [@lukashergt](https://github.com/lukashergt) for reporting, debugging and testing -- Fix __init__.py for wheel [#99](https://github.com/jupyterlab-contrib/jupyterlab-vim/pull/99) ([@fcollonval](https://github.com/fcollonval)) +- Fix `__init__.py` for wheel [#99](https://github.com/jupyterlab-contrib/jupyterlab-vim/pull/99) ([@fcollonval](https://github.com/fcollonval)) ### Maintenance and upkeep improvements diff --git a/src/index.ts b/src/index.ts index 910fda0..2e74f48 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ import { + ILabShell, JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application'; @@ -144,6 +145,19 @@ async function activateCellVim( editorManager.onActiveEditorChanged, editorManager ); + const shell = app.shell as ILabShell; + shell.currentChanged.connect(() => { + const current = shell.currentWidget; + if (!current) { + // no-op + } else if (editorTracker.currentWidget === current) { + editorManager.modifyEditor(editorTracker.currentWidget.content.editor); + } else if (notebookTracker.currentWidget === current) { + cellManager.modifyCell(notebookTracker.currentWidget.content.activeCell); + } else { + // no-op + } + }); addNotebookCommands(app, notebookTracker);