-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re-run edited cells automatically when they lose focus
- Loading branch information
Jake Donham
committed
May 2, 2024
1 parent
b3a6e6c
commit e068ae0
Showing
5 changed files
with
67 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/vscode/src/handleDidChangeNotebookEditorSelection.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { NotebookEditorSelectionChangeEvent } from "vscode"; | ||
import { getRerunCellsWhenDirty } from "./controller"; | ||
import type { NotebookController } from "./controller"; | ||
|
||
export function makeHandleDidChangeNotebookEditorSelection( | ||
controller: NotebookController | ||
) { | ||
return (e: NotebookEditorSelectionChangeEvent) => { | ||
// what we really want here is to run when an edited cell loses focus | ||
// but it doesn't seem to be possible in the VS Code API | ||
// so instead we run when the notebook selection changes | ||
// (i.e. you switch to a different cell) | ||
// but unfortunately this doesn't fire when you click outside any cell | ||
if (getRerunCellsWhenDirty()) { | ||
controller.runDirty(e.notebookEditor.notebook.uri.toString()); | ||
} | ||
}; | ||
} |