Skip to content

Commit 8ab40eb

Browse files
committed
reuse func
1 parent 6a71619 commit 8ab40eb

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/vs/workbench/contrib/runtimeNotebookKernel/browser/runtimeNotebookKernelActions.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ import { RuntimeExitReason } from '../../../services/languageRuntime/common/lang
1818
import { INotebookLanguageRuntimeSession, IRuntimeSessionService } from '../../../services/runtimeSession/common/runtimeSessionService.js';
1919
import { NotebookEditorWidget } from '../../notebook/browser/notebookEditorWidget.js';
2020
import { NOTEBOOK_KERNEL } from '../../notebook/common/notebookContextKeys.js';
21-
import { isNotebookEditorInput } from '../../notebook/common/notebookEditorInput.js';
2221
import { POSITRON_NOTEBOOK_EDITOR_CONTAINER_FOCUSED } from '../../positronNotebook/browser/ContextKeysManager.js';
23-
import { POSITRON_NOTEBOOK_EDITOR_INPUT_ID } from '../../positronNotebook/common/positronNotebookCommon.js';
24-
import { ActiveNotebookHasRunningRuntime } from '../common/activeRuntimeNotebookContextManager.js';
22+
import { ActiveNotebookHasRunningRuntime, isNotebookEditorInput } from '../common/activeRuntimeNotebookContextManager.js';
2523
import { POSITRON_RUNTIME_NOTEBOOK_KERNELS_EXTENSION_ID } from '../common/runtimeNotebookKernelConfig.js';
2624

2725
const category = localize2('positron.runtimeNotebookKernel.category', "Notebook");
@@ -88,9 +86,7 @@ abstract class BaseRuntimeNotebookKernelAction extends Action2 {
8886
debugMessage: `Restart notebook kernel command ${RuntimeNotebookKernelRestartAction.ID} executed`,
8987
};
9088
const activeEditor = editorService.activeEditor;
91-
if (!(isNotebookEditorInput(activeEditor) ||
92-
// TODO: Wasn't there a function for this?
93-
(activeEditor?.typeId === POSITRON_NOTEBOOK_EDITOR_INPUT_ID))) {
89+
if (!isNotebookEditorInput(activeEditor)) {
9490
throw new Error('No active notebook. This command should only be available when a notebook is active.');
9591
}
9692
notebookUri = activeEditor.resource;

src/vs/workbench/contrib/runtimeNotebookKernel/common/activeRuntimeNotebookContextManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export class ActiveRuntimeNotebookContextManager extends Disposable {
166166
}
167167
}
168168

169-
function isNotebookEditorInput(editor: EditorInput | undefined): editor is EditorInput & { resource: URI } {
169+
export function isNotebookEditorInput(editor: EditorInput | undefined): editor is EditorInput & { resource: URI } {
170170
return editor !== undefined && (
171171
isVSCodeNotebookEditorInput(editor) ||
172172
(editor.typeId === POSITRON_NOTEBOOK_EDITOR_INPUT_ID && editor.resource !== undefined)

0 commit comments

Comments
 (0)