Skip to content

Conversation

@cannona
Copy link

@cannona cannona commented Nov 7, 2025

Fixes #262817

When the active editor is in the first group and there is no previous group, "Move Editor into Previous Group" now creates a new group before the current group, and moves the editor there. This mirrors the existing behavior of "Move Editor into Next Group".

The new group is only created if the source group contains 2+ editors, preventing the source group from being left empty. The direction respects the workbench.editor.openSideBySideDirection setting - if the preference is RIGHT (horizontal), the new group is created to the LEFT; if DOWN (vertical), the new group is created UP.

Suggestions on where to add tests for this would be appreciated.

Fixes microsoft#262817

When the active editor is in the leftmost group and there is no previous
group, "Move Editor into Previous Group" now creates a new group in the
opposite direction of the user's preferred side-by-side setting and moves
the editor there. This mirrors the existing behavior of "Move Editor into
Next Group".

The new group is only created if the source group contains 2+ editors,
preventing the source group from being left empty. The direction respects
the `workbench.editor.openSideBySideDirection` setting - if the preference
is RIGHT (horizontal), the new group is created to the LEFT; if DOWN
(vertical), the new group is created UP.
Copilot AI review requested due to automatic review settings November 7, 2025 00:24
@vs-code-engineering
Copy link

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@bpasero

Matched files:

  • src/vs/workbench/browser/parts/editor/editorCommands.ts

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the behavior of the moveActiveEditor command for the 'previous' case. When moving an editor to a previous group and no previous group exists, the code now creates a new group in the opposite direction of the user's preferred side-by-side direction, but only when the source group has 2 or more editors.

Key changes:

  • Added logic to create a new group when moving to 'previous' and no previous group exists
  • The new group is created in the opposite direction (LEFT if preferred is RIGHT, UP if preferred is DOWN)
  • This behavior only activates when the source group has at least 2 editors

Comment on lines +301 to +302
// If no previous group exists and source group has 2+ editors, create a new group to the left/up
if (!targetGroup && sourceGroup.count >= 2) {
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

The 'previous' case has a sourceGroup.count >= 2 condition before creating a new group, but the 'next' case (line 310-312) creates a new group without this condition. This creates an asymmetry where moving to 'next' will always create a group if none exists, but moving to 'previous' only creates a group if there are 2+ editors. Consider whether this asymmetry is intentional or if the behavior should be consistent between 'next' and 'previous' cases.

Suggested change
// If no previous group exists and source group has 2+ editors, create a new group to the left/up
if (!targetGroup && sourceGroup.count >= 2) {
// If no previous group exists, create a new group to the left/up
if (!targetGroup) {

Copilot uses AI. Check for mistakes.
break;
case 'previous':
targetGroup = editorGroupsService.findGroup({ location: GroupLocation.PREVIOUS }, sourceGroup);
// If no previous group exists and source group has 2+ editors, create a new group to the left/up
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

The comment says "create a new group to the left/up" but the actual direction depends on the user's workbench.editor.openSideBySideDirection setting. Consider clarifying: "create a new group in the opposite direction (left if preferred direction is right, up if preferred direction is down)".

Suggested change
// If no previous group exists and source group has 2+ editors, create a new group to the left/up
// If no previous group exists and source group has 2+ editors, create a new group in the opposite direction (left if preferred direction is right, up if preferred direction is down)

Copilot uses AI. Check for mistakes.
@bpasero
Copy link
Member

bpasero commented Nov 7, 2025

I commented about this feature in #262817 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running "Move Editor into Previous Group" from the left-most group should create a new group to the left.

2 participants