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

instantiate status bar contribs with services scoped to the window #211997

Merged
merged 2 commits into from
May 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeat
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILogService } from 'vs/platform/log/common/log';
import { Registry } from 'vs/platform/registry/common/platform';
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions, WorkbenchPhase, registerWorkbenchContribution2 } from 'vs/workbench/common/contributions';
import { IWorkbenchContribution, WorkbenchPhase, registerWorkbenchContribution2 } from 'vs/workbench/common/contributions';
import { CENTER_ACTIVE_CELL } from 'vs/workbench/contrib/notebook/browser/contrib/navigation/arrow';
import { SELECT_KERNEL_ID } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
import { SELECT_NOTEBOOK_INDENTATION_ID } from 'vs/workbench/contrib/notebook/browser/controller/editActions';
Expand All @@ -20,8 +19,9 @@ import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/no
import { NotebookCellsChangeType } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookKernel, INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { IStatusbarEntry, IStatusbarEntryAccessor, IStatusbarService, StatusbarAlignment } from 'vs/workbench/services/statusbar/browser/statusbar';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';

class ImplictKernelSelector implements IDisposable {

Expand Down Expand Up @@ -179,8 +179,6 @@ export class KernelStatus extends Disposable implements IWorkbenchContribution {
}
}

Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(KernelStatus, LifecyclePhase.Restored);

export class ActiveCellStatus extends Disposable implements IWorkbenchContribution {

private readonly _itemDisposables = this._register(new DisposableStore());
Expand Down Expand Up @@ -255,9 +253,7 @@ export class ActiveCellStatus extends Disposable implements IWorkbenchContributi
}
}

Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(ActiveCellStatus, LifecyclePhase.Restored);

export class NotebookIndentationStatus extends Disposable implements IWorkbenchContribution {
export class NotebookIndentationStatus extends Disposable {

private readonly _itemDisposables = this._register(new DisposableStore());
private readonly _accessor = this._register(new MutableDisposable<IStatusbarEntryAccessor>());
Expand Down Expand Up @@ -339,4 +335,33 @@ export class NotebookIndentationStatus extends Disposable implements IWorkbenchC
}
}

registerWorkbenchContribution2(NotebookIndentationStatus.ID, NotebookIndentationStatus, WorkbenchPhase.AfterRestored); // TODO@Yoyokrazy -- unsure on the phase
export class NotebookEditorStatusContribution extends Disposable implements IWorkbenchContribution {

static readonly ID = 'notebook.contrib.editorStatus';

constructor(
@IInstantiationService instantiationService: IInstantiationService,
@IEditorGroupsService editorGroupService: IEditorGroupsService,
@IEditorService editorService: IEditorService
) {
super();

// Main Editor Status
const mainInstantiationService = instantiationService.createChild(new ServiceCollection(
[IEditorService, editorService.createScoped('main', this._store)]
));
this._register(mainInstantiationService.createInstance(KernelStatus));
this._register(mainInstantiationService.createInstance(ActiveCellStatus));
this._register(mainInstantiationService.createInstance(NotebookIndentationStatus));

// Auxiliary Editor Status
this._register(editorGroupService.onDidCreateAuxiliaryEditorPart(({ part, instantiationService, disposables }) => {
disposables.add(instantiationService.createInstance(KernelStatus));
disposables.add(instantiationService.createInstance(ActiveCellStatus));
disposables.add(instantiationService.createInstance(NotebookIndentationStatus));
}));
}
}


registerWorkbenchContribution2(NotebookEditorStatusContribution.ID, NotebookEditorStatusContribution, WorkbenchPhase.AfterRestored);