Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix modifyCell or modifyEditor not called after text editor is opened after notebook #105

2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
ILabShell,
JupyterFrontEnd,
JupyterFrontEndPlugin
} from '@jupyterlab/application';
Expand Down Expand Up @@ -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);

Expand Down
Loading