Skip to content

Commit dbff586

Browse files
committed
Remove all uses of the notebook service active instance getter
1 parent 897e1d5 commit dbff586

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

src/vs/workbench/contrib/positronNotebook/browser/SelectPositronNotebookKernelAction.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import { IQuickInputService, IQuickPickItem } from '../../../../platform/quickin
1111
import { selectKernelIcon } from '../../notebook/browser/notebookIcons.js';
1212
import { INotebookKernelService, INotebookKernel } from '../../notebook/common/notebookKernelService.js';
1313
import { PositronNotebookInstance } from './PositronNotebookInstance.js';
14-
import { IPositronNotebookService } from './positronNotebookService.js';
1514
import { POSITRON_RUNTIME_NOTEBOOK_KERNELS_EXTENSION_ID } from '../../runtimeNotebookKernel/common/runtimeNotebookKernelConfig.js';
15+
import { IEditorService } from '../../../services/editor/common/editorService.js';
16+
import { getActiveNotebook } from './notebookUtils.js';
1617

1718
export const SELECT_KERNEL_ID_POSITRON = 'positronNotebook.selectKernel';
1819
const NOTEBOOK_ACTIONS_CATEGORY_POSITRON = localize2('positronNotebookActions.category', 'Positron Notebook');
@@ -38,8 +39,7 @@ class SelectPositronNotebookKernelAction extends Action2 {
3839
async run(accessor: ServicesAccessor, context?: SelectPositronNotebookKernelContext): Promise<boolean> {
3940
const { forceDropdown } = context || { forceDropdown: false };
4041
const notebookKernelService = accessor.get(INotebookKernelService);
41-
const notebookService = accessor.get(IPositronNotebookService);
42-
const activeNotebook = notebookService.getActiveInstance();
42+
const activeNotebook = getActiveNotebook(accessor.get(IEditorService));
4343
const quickInputService = accessor.get(IQuickInputService);
4444

4545
if (!activeNotebook) {

src/vs/workbench/contrib/positronNotebook/browser/contrib/undoRedo/positronNotebookUndoRedo.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66
import { Disposable } from '../../../../../../base/common/lifecycle.js';
77
import { WorkbenchPhase, registerWorkbenchContribution2 } from '../../../../../common/contributions.js';
88
import { UndoCommand, RedoCommand } from '../../../../../../editor/browser/editorExtensions.js';
9-
import { IPositronNotebookService } from '../../positronNotebookService.js';
109
import { POSITRON_NOTEBOOK_EDITOR_CONTAINER_FOCUSED, POSITRON_NOTEBOOK_CELL_EDITOR_FOCUSED } from '../../ContextKeysManager.js';
1110
import { IUndoRedoService } from '../../../../../../platform/undoRedo/common/undoRedo.js';
1211
import { IContextKeyService } from '../../../../../../platform/contextkey/common/contextkey.js';
12+
import { IEditorService } from '../../../../../services/editor/common/editorService.js';
13+
import { getActiveNotebook } from '../../notebookUtils.js';
1314

1415
class PositronNotebookUndoRedoContribution extends Disposable {
1516

1617
static readonly ID = 'workbench.contrib.positronNotebookUndoRedo';
1718

1819
constructor(
1920
@IUndoRedoService private readonly undoRedoService: IUndoRedoService,
20-
@IPositronNotebookService private readonly positronNotebookService: IPositronNotebookService,
21+
@IEditorService private readonly editorService: IEditorService,
2122
@IContextKeyService private readonly contextKeyService: IContextKeyService
2223
) {
2324
super();
@@ -30,7 +31,7 @@ class PositronNotebookUndoRedoContribution extends Disposable {
3031

3132
private shouldHandleUndoRedo(): boolean {
3233
// Get the active notebook instance to access its scoped context key service
33-
const instance = this.positronNotebookService.getActiveInstance();
34+
const instance = getActiveNotebook(this.editorService);
3435
if (!instance) {
3536
return false;
3637
}
@@ -61,7 +62,7 @@ class PositronNotebookUndoRedoContribution extends Disposable {
6162
return false;
6263
}
6364

64-
const instance = this.positronNotebookService.getActiveInstance();
65+
const instance = getActiveNotebook(this.editorService);
6566
if (!instance) {
6667
return false;
6768
}
@@ -79,7 +80,7 @@ class PositronNotebookUndoRedoContribution extends Disposable {
7980
return false;
8081
}
8182

82-
const instance = this.positronNotebookService.getActiveInstance();
83+
const instance = getActiveNotebook(this.editorService);
8384
if (!instance) {
8485
return false;
8586
}

src/vs/workbench/contrib/positronNotebook/browser/positronNotebookService.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ export interface IPositronNotebookService {
3030
*/
3131
listInstances(uri?: URI): Array<IPositronNotebookInstance>;
3232

33-
/**
34-
* Get the currently active notebook instance, if it exists.
35-
*/
36-
getActiveInstance(): IPositronNotebookInstance | null;
37-
3833
/**
3934
* Register a new notebook instance.
4035
* @param instance The instance to register.
@@ -68,7 +63,6 @@ class PositronNotebookService extends Disposable implements IPositronNotebookSer
6863
constructor(
6964
@IConfigurationService private readonly _configurationService: IConfigurationService
7065
) {
71-
// Call the disposable constrcutor.
7266
super();
7367
}
7468

@@ -90,10 +84,6 @@ class PositronNotebookService extends Disposable implements IPositronNotebookSer
9084
return instances;
9185
}
9286

93-
public getActiveInstance(): IPositronNotebookInstance | null {
94-
return this._activeInstance;
95-
}
96-
9787
public registerInstance(instance: IPositronNotebookInstance): void {
9888
if (!this._instanceById.has(instance.id)) {
9989
this._instanceById.set(instance.id, instance);

0 commit comments

Comments
 (0)