editor group lock - indicate locked group when group empty

This commit is contained in:
Benjamin Pasero 2021-08-18 13:58:20 +02:00
parent e909ece93a
commit 3dba958817
No known key found for this signature in database
GPG key ID: E6380CC4C8219E65
2 changed files with 25 additions and 11 deletions

View file

@ -293,7 +293,8 @@ if (isMacintosh) {
}
// Empty Editor Group Toolbar
MenuRegistry.appendMenuItem(MenuId.EmptyEditorGroup, { command: { id: CLOSE_EDITOR_GROUP_COMMAND_ID, title: localize('closeGroupAction', "Close"), icon: Codicon.close }, group: 'navigation', order: 10 });
MenuRegistry.appendMenuItem(MenuId.EmptyEditorGroup, { command: { id: UNLOCK_GROUP_COMMAND_ID, title: localize('unlockGroupAction', "Unlock Group"), icon: Codicon.unlock }, group: 'navigation', order: 10, when: ActiveEditorGroupLockedContext });
MenuRegistry.appendMenuItem(MenuId.EmptyEditorGroup, { command: { id: CLOSE_EDITOR_GROUP_COMMAND_ID, title: localize('closeGroupAction', "Close Group"), icon: Codicon.close }, group: 'navigation', order: 10, when: ActiveEditorGroupLockedContext.toNegated() });
// Empty Editor Group Context Menu
MenuRegistry.appendMenuItem(MenuId.EmptyEditorGroupContext, { command: { id: SPLIT_EDITOR_UP, title: localize('splitUp', "Split Up") }, group: '2_split', order: 10 });

View file

@ -5,7 +5,7 @@
import 'vs/css!./media/editorgroupview';
import { EditorGroupModel, IEditorOpenOptions, EditorCloseEvent, ISerializedEditorGroupModel, isSerializedEditorGroupModel } from 'vs/workbench/common/editor/editorGroupModel';
import { GroupIdentifier, CloseDirection, IEditorCloseEvent, ActiveEditorDirtyContext, IEditorPane, EditorGroupEditorsCountContext, SaveReason, IEditorPartOptionsChangeEvent, EditorsOrder, IVisibleEditorPane, ActiveEditorStickyContext, ActiveEditorPinnedContext, EditorResourceAccessor, IEditorMoveEvent, EditorInputCapabilities, IEditorOpenEvent, IUntypedEditorInput, DEFAULT_EDITOR_ASSOCIATION } from 'vs/workbench/common/editor';
import { GroupIdentifier, CloseDirection, IEditorCloseEvent, ActiveEditorDirtyContext, IEditorPane, EditorGroupEditorsCountContext, SaveReason, IEditorPartOptionsChangeEvent, EditorsOrder, IVisibleEditorPane, ActiveEditorStickyContext, ActiveEditorPinnedContext, EditorResourceAccessor, IEditorMoveEvent, EditorInputCapabilities, IEditorOpenEvent, IUntypedEditorInput, DEFAULT_EDITOR_ASSOCIATION, ActiveEditorGroupLockedContext } from 'vs/workbench/common/editor';
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
import { SideBySideEditorInput } from 'vs/workbench/common/editor/sideBySideEditorInput';
import { Event, Emitter, Relay } from 'vs/base/common/event';
@ -25,7 +25,7 @@ import { IEditorProgressService } from 'vs/platform/progress/common/progress';
import { EditorProgressIndicator } from 'vs/workbench/services/progress/browser/progressIndicator';
import { localize } from 'vs/nls';
import { isErrorWithActions, isPromiseCanceledError } from 'vs/base/common/errors';
import { dispose, MutableDisposable } from 'vs/base/common/lifecycle';
import { combinedDisposable, dispose, MutableDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { Severity, INotificationService } from 'vs/platform/notification/common/notification';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
@ -161,6 +161,9 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
//#region create()
{
// Scoped context key service
this.scopedContextKeyService = this._register(this.contextKeyService.createScoped(this.element));
// Container
this.element.classList.add('editor-group-container');
@ -183,8 +186,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
this._register(attachProgressBarStyler(this.progressBar, this.themeService));
this.progressBar.hide();
// Scoped services
this.scopedContextKeyService = this._register(this.contextKeyService.createScoped(this.element));
// Scoped instantiation service
this.scopedInstantiationService = this.instantiationService.createChild(new ServiceCollection(
[IContextKeyService, this.scopedContextKeyService],
[IEditorProgressService, this._register(new EditorProgressIndicator(this.progressBar, this))]
@ -240,6 +242,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
const groupActiveEditorPinnedContext = ActiveEditorPinnedContext.bindTo(this.scopedContextKeyService);
const groupActiveEditorStickyContext = ActiveEditorStickyContext.bindTo(this.scopedContextKeyService);
const groupEditorsCountContext = EditorGroupEditorsCountContext.bindTo(this.scopedContextKeyService);
const groupLockedContext = ActiveEditorGroupLockedContext.bindTo(this.scopedContextKeyService);
const activeEditorListener = new MutableDisposable();
@ -275,6 +278,9 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
groupActiveEditorStickyContext.set(this.model.isSticky(this.model.activeEditor));
}
break;
case GroupChangeKind.GROUP_LOCKED:
groupLockedContext.set(this.isLocked);
break;
}
// Group editors count context
@ -325,15 +331,22 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
}));
// Toolbar actions
const containerToolbarMenu = this._register(this.menuService.createMenu(MenuId.EmptyEditorGroup, this.contextKeyService));
const containerToolbarMenu = this._register(this.menuService.createMenu(MenuId.EmptyEditorGroup, this.scopedContextKeyService));
const updateContainerToolbar = () => {
const actions: { primary: IAction[], secondary: IAction[] } = { primary: [], secondary: [] };
this.containerToolBarMenuDisposables.value = createAndFillInActionBarActions(
containerToolbarMenu,
{ arg: { groupId: this.id }, shouldForwardArgs: true },
actions,
'navigation'
this.containerToolBarMenuDisposables.value = combinedDisposable(
// Clear old actions
toDisposable(() => containerToolbar.clear()),
// Create new actions
createAndFillInActionBarActions(
containerToolbarMenu,
{ arg: { groupId: this.id }, shouldForwardArgs: true },
actions,
'navigation'
)
);
for (const action of [...actions.primary, ...actions.secondary]) {