Skip to content

Commit

Permalink
feat: initial notebook support
Browse files Browse the repository at this point in the history
  • Loading branch information
xhayper committed Oct 23, 2022
1 parent 861f6b9 commit 2332c51
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class RPCController {
const fileSwitch = window.onDidChangeActiveTextEditor(() => sendActivity(true));
const fileEdit = workspace.onDidChangeTextDocument(this.activityThrottle.callable);
const fileSelectionChanged = window.onDidChangeTextEditorSelection(this.activityThrottle.callable);
const notebookSelectionChanged = window.onDidChangeNotebookEditorSelection(this.activityThrottle.callable);
const debugStart = debug.onDidStartDebugSession(() => sendActivity());
const debugEnd = debug.onDidTerminateDebugSession(() => sendActivity());
const diagnosticsChange = languages.onDidChangeDiagnostics(() => onDiagnosticsChange());
Expand All @@ -91,7 +92,15 @@ export class RPCController {
if (config.get(CONFIG_KEYS.Status.Problems.Enabled)) this.listeners.push(diagnosticsChange);
if (config.get(CONFIG_KEYS.Status.Idle.Check)) this.listeners.push(changeWindowState);

this.listeners.push(fileSwitch, fileEdit, fileSelectionChanged, debugStart, debugEnd, gitListener);
this.listeners.push(
fileSwitch,
fileEdit,
fileSelectionChanged,
notebookSelectionChanged,
debugStart,
debugEnd,
gitListener
);
}

private async checkIdle(windowState: WindowState) {
Expand Down
9 changes: 8 additions & 1 deletion src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
EventEmitter,
extensions,
window,
workspace
workspace,
NotebookEditor
} from "vscode";

const ALLOWED_SCHEME = ["file", "vscode-remote"];
Expand All @@ -39,6 +40,7 @@ export class Data implements DisposableLike {
private gitApi: GitApi | undefined;

public editor: TextEditor | undefined;
public notebookEditor: NotebookEditor | undefined;

public constructor(debug: boolean = false) {
this._debug = debug;
Expand All @@ -58,6 +60,11 @@ export class Data implements DisposableLike {
this.editor = e;
this.updateGit();
}),
window.onDidChangeActiveNotebookEditor((e) => {
this.debug("root(): window.onDidChangeActiveNotebookEditor");
this.notebookEditor = e;
this.updateGit();
}),
workspace.onDidChangeWorkspaceFolders(() => {
this.debug("root(): workspace.onDidChangeWorkspaceFolders");
this.updateGit();
Expand Down

0 comments on commit 2332c51

Please sign in to comment.