mirror of
https://github.com/voideditor/void
synced 2026-05-24 09:58:23 +00:00
sidebar action
This commit is contained in:
parent
7cc57bf086
commit
5fb30fed87
2 changed files with 36 additions and 12 deletions
|
|
@ -18,11 +18,13 @@ import { IEditorService } from '../../../services/editor/common/editorService.js
|
|||
import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js';
|
||||
import { IRange } from '../../../../editor/common/core/range.js';
|
||||
import { ITextModel } from '../../../../editor/common/model.js';
|
||||
import { VOID_VIEW_ID } from './sidebarPane.js';
|
||||
import { VOID_VIEW_CONTAINER_ID, VOID_VIEW_ID } from './sidebarPane.js';
|
||||
import { IMetricsService } from '../../../../platform/void/common/metricsService.js';
|
||||
import { ISidebarStateService } from './sidebarStateService.js';
|
||||
import { ICommandService } from '../../../../platform/commands/common/commands.js';
|
||||
import { OPEN_VOID_SETTINGS_ACTION_ID } from './voidSettingsPane.js';
|
||||
import { IWorkbenchContribution, registerWorkbenchContribution2, WorkbenchPhase } from '../../../common/contributions.js';
|
||||
import { IViewsService } from '../../../services/views/common/viewsService.js';
|
||||
|
||||
|
||||
// ---------- Register commands and keybindings ----------
|
||||
|
|
@ -180,3 +182,32 @@ registerAction2(class extends Action2 {
|
|||
commandService.executeCommand(OPEN_VOID_SETTINGS_ACTION_ID)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
export const VOID_OPEN_SIDEBAR_ACTION_ID = 'void.openSidebar'
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
super({
|
||||
id: VOID_OPEN_SIDEBAR_ACTION_ID,
|
||||
title: 'Open Void Sidebar',
|
||||
})
|
||||
}
|
||||
run(accessor: ServicesAccessor): void {
|
||||
const viewsService = accessor.get(IViewsService)
|
||||
viewsService.openViewContainer(VOID_VIEW_CONTAINER_ID);
|
||||
viewsService.openView(VOID_VIEW_ID);
|
||||
}
|
||||
});
|
||||
|
||||
// mount at start
|
||||
|
||||
|
||||
export class SidebarStartContribution implements IWorkbenchContribution {
|
||||
static readonly ID = 'workbench.contrib.startupVoidSidebar';
|
||||
constructor(
|
||||
@ICommandService private readonly commandService: ICommandService,
|
||||
) {
|
||||
this.commandService.executeCommand(VOID_OPEN_SIDEBAR_ACTION_ID)
|
||||
}
|
||||
}
|
||||
registerWorkbenchContribution2(SidebarStartContribution.ID, SidebarStartContribution, WorkbenchPhase.BlockRestore);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { Emitter, Event } from '../../../../base/common/event.js';
|
||||
import { Disposable } from '../../../../base/common/lifecycle.js';
|
||||
import { ICommandService } from '../../../../platform/commands/common/commands.js';
|
||||
import { InstantiationType, registerSingleton } from '../../../../platform/instantiation/common/extensions.js';
|
||||
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
|
||||
import { IViewsService } from '../../../services/views/common/viewsService.js';
|
||||
import { VOID_VIEW_CONTAINER_ID, VOID_VIEW_ID } from './sidebarPane.js';
|
||||
import { VOID_OPEN_SIDEBAR_ACTION_ID } from './sidebarActions.js';
|
||||
|
||||
|
||||
// service that manages sidebar's state
|
||||
|
|
@ -23,8 +23,6 @@ export interface ISidebarStateService {
|
|||
onDidBlurChat: Event<void>;
|
||||
fireFocusChat(): void;
|
||||
fireBlurChat(): void;
|
||||
|
||||
openSidebarView(): void;
|
||||
}
|
||||
|
||||
export const ISidebarStateService = createDecorator<ISidebarStateService>('voidSidebarStateService');
|
||||
|
|
@ -47,7 +45,7 @@ class VoidSidebarStateService extends Disposable implements ISidebarStateService
|
|||
state: VoidSidebarState
|
||||
|
||||
constructor(
|
||||
@IViewsService private readonly _viewsService: IViewsService,
|
||||
@ICommandService private readonly commandService: ICommandService,
|
||||
) {
|
||||
super()
|
||||
|
||||
|
|
@ -59,7 +57,7 @@ class VoidSidebarStateService extends Disposable implements ISidebarStateService
|
|||
setState(newState: Partial<VoidSidebarState>) {
|
||||
// make sure view is open if the tab changes
|
||||
if ('currentTab' in newState) {
|
||||
this.openSidebarView()
|
||||
this.commandService.executeCommand(VOID_OPEN_SIDEBAR_ACTION_ID)
|
||||
}
|
||||
|
||||
this.state = { ...this.state, ...newState }
|
||||
|
|
@ -74,11 +72,6 @@ class VoidSidebarStateService extends Disposable implements ISidebarStateService
|
|||
this._onBlurChat.fire()
|
||||
}
|
||||
|
||||
openSidebarView() {
|
||||
this._viewsService.openViewContainer(VOID_VIEW_CONTAINER_ID);
|
||||
this._viewsService.openView(VOID_VIEW_ID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
registerSingleton(ISidebarStateService, VoidSidebarStateService, InstantiationType.Eager);
|
||||
|
|
|
|||
Loading…
Reference in a new issue