Skip to content

Added a setting for closing the active editor group when the last edi… - #49517

Closed
Alex Ross (alexr00) wants to merge 2 commits into
microsoft:ben/editorfrom
alexr00:alex/editor_collapseEmptyGroupsOnClose
Closed

Alex Ross (alexr00) wants to merge 2 commits into
microsoft:ben/editorfrom
alexr00:alex/editor_collapseEmptyGroupsOnClose

Conversation

@alexr00

Copy link
Copy Markdown
Member

…tor in the group is closed.

@bpasero Benjamin Pasero (bpasero) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alex Ross (@alexr00) some feedback provided

getGroup(identifier: GroupIdentifier): INextEditorGroupView;

addGroup(location: INextEditorGroupView | GroupIdentifier, direction: GroupDirection, options?: IAddGroupOptions): INextEditorGroup;
removeGroup(): void;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my merge caused a bad formatting here, suggest to code format once

const copyEditor = this.shouldCopyEditor(draggedEditor, event);
if (!copyEditor) {
sourceGroup.closeEditor(draggedEditor.editor);
sourceGroup.closeEditor(draggedEditor.editor, true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can tweak this a little bit: If the user drags an editor to another group and drops it there, I would think that it is fine to close the editor if its the last. Same for dragging it to another group to split the group there.

In other words, maybe the only time we should allow the editor group to stay empty is when you drag the editor into the same group it originates from and you are splitting that group into one of the directions.

'workbench.editor.collapseEmptyGroupsOnClose': {
'type': 'boolean',
'description': nls.localize('collapseEmptyGroupsOnClose', "Controls the behavior of empty editor groups when the last tab in the group is closed. When enabled, empty groups will automatically collapse. When disabled, empty groups will remain part of the grid."),
'default': false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would make this the default to preserve our todays liquid layout.

'description': nls.localize('revealIfOpen', "Controls if an editor is revealed in any of the visible groups if opened. If disabled, an editor will prefer to open in the currently active editor group. If enabled, an already opened editor will be revealed instead of opened again in the currently active editor group. Note that there are some cases where this setting is ignored, e.g. when forcing an editor to open in a specific group or to the side of the currently active group."),
'default': false
},
'workbench.editor.collapseEmptyGroupsOnClose': {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setting name is a bit hard to understand. How about removeEmptyGroups or collapseEmptyGroups and then explaining in the description that it applies when you close the last editor?

}

removeGroup(group: INextEditorGroupView | GroupIdentifier): void {
removeGroup(group: INextEditorGroupView | GroupIdentifier = this.activeGroup): void {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will unfortunately not work if the group where the editor gets closed is not active. This happens when you just click on the tab close button while the group is not active. I suggest to expose the group parameter to the accessor and then using it.

@IConfigurationService private configurationService: IConfigurationService,
) {
super(themeService);
this.workbenchEditorOptions = getEditorPartOptions(this.configurationService.getValue<IWorkbenchEditorConfiguration>());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to just use the accessor here to get to the editor options instead of keeping it as variable.

@bpasero Benjamin Pasero (bpasero) added this to the May 2018 milestone May 9, 2018
@bpasero Benjamin Pasero (bpasero) added the workbench-editor-grid Grid layout issues in the editor area label May 10, 2018
@bpasero

Copy link
Copy Markdown
Contributor

I pushed this in a slightly modified form via 26ee938. The change ended up to be much simpler because of changes I did meanwhile. I no longer think that there should be different behaviour when dragging compared to just closing the last editor.

@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

workbench-editor-grid Grid layout issues in the editor area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants