Skip to content

Focus Left Editor Tab After Close #247253

Closed as not planned
Closed as not planned
@eickr

Description

@eickr

The ability, presumably via configuration setting, to focus the left tab when an editor tab is closed.
Functionality previously described in issues #174499, #102034, #47410, #46150, #43459, #43119, many of which were closed prematurely or by mistake.

Currently there are two behavior options:

  1. Closing a tab will focus the tab that was recently focused. ["workbench.editor.focusRecentEditorAfterClose": true (default)]
  2. Closing a tab will focus the tab to the right. ["workbench.editor.focusRecentEditorAfterClose": false]

There should be a third behavior option, closing a tab will focus the tab to the left. In fact, I'd say this should've been the default over focusing the tab to the right (when focus recent is disabled) in the first place, as it means closing temporary tabs would return you to the previous tab.

This can likely be implemented with little effort by reverting part of the last commit from PR #66635, turning the focusRecentEditorAfterClose option from a boolean back into an enum. Or alternatively, it could be accomplished by repeating most of PR #66635 to add another boolean that toggles close to left vs close to right when focusRecentEditorAfterClose is set to false.

E.g.: If adding a new boolean config, workbench.editor.focusRightEditorAfterClose: true (default), then the main logic change would be changing vscode/src/vs/workbench/common/editor/editorGroupModel.ts LN563-567 from this to this.

					if (index === this.editors.length - 1) {
						newActive = this.editors[index - 1]; // last editor is closed, pick previous as new active
					} else {
						newActive = this.editors[index + 1]; // pick next editor as new active
					}
					if (index === this.editors.length - 1) {
						newActive = this.editors[index - 1]; // last editor is closed, pick previous as new active
					} else if (index === 0 || this.focusRightEditorAfterClose) {
                                                newActive = this.editors[index + 1]; // first editor is closed, or close to right desired, pick next as new active
                                        } else { // !this.focusRightEditorAfterClose
						newActive = this.editors[index - 1]; // pick previous editor as new active
					}

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestRequest for new features or functionalityworkbench-editorsManaging of editor widgets in workbench window

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions