Skip to content

Middle-click empty space to create folders and open terminals - #334530

Open
Fahad Iftikhar (Fahad090NP) wants to merge 4 commits into
microsoft:mainfrom
Fahad090NP:middle-click-new-terminal
Open

Middle-click empty space to create folders and open terminals#334530
Fahad Iftikhar (Fahad090NP) wants to merge 4 commits into
microsoft:mainfrom
Fahad090NP:middle-click-new-terminal

Conversation

@Fahad090NP

Copy link
Copy Markdown

Fixes #329948

Summary

Add middle-click shortcuts for the two surfaces where double-click already creates a new file:

  • Explorer view (empty space) — middle-click creates a new folder, matching the existing double-click → new file. The Linux middle-click paste is suppressed so the new folder's name input starts empty.
  • Editor area (empty canvas or empty tabs row) — middle-click opens a new terminal in the editor area, matching the existing double-click → new file. Middle-click on an empty editor group now opens a terminal instead of closing the group.

Commits

  • Create a folder when middle-clicking empty Explorer space
    • src/vs/base/browser/ui/tree/asyncDataTree.ts — expose onMouseMiddleClick.
    • src/vs/workbench/contrib/files/browser/views/explorerView.ts — middle-click empty space → new folder.
    • src/vs/workbench/contrib/files/browser/views/explorerViewer.ts — swallow the Linux middle-click paste into the new-folder input.
  • Open a new terminal when middle-clicking empty editor space
    • src/vs/workbench/browser/parts/editor/editorGroupView.ts — empty-container middle-click → new terminal.
    • src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts — empty tabs-row middle-click → new terminal.

Validation

  • Hygiene passed; no compile errors; npm run transpile-client clean.
  • Verified conflict-free merge against latest origin/main.

Restored PR: This replaces #329446, which was closed automatically when my fork was deleted from GitHub. GitHub cannot reopen a PR whose head repository was deleted, so the branch was rebuilt from the original commits (same commit messages and authorship) on top of the current main — which also resolves the merge conflicts #329446 had. Please review this PR in place of #329446.

Middle-clicking empty space in the Explorer view opens a new-folder input,
matching the existing double-click behavior for new files. The paste that
Linux delivers to the freshly focused input is swallowed so the name starts
empty.
Plain middle-click keeps the stock close-group behavior; Ctrl/Cmd+middle-click
opens a new terminal in the empty group.
Copilot AI balanced review requested due to automatic review settings September 4, 2026 15:41
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

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

Benjamin Christopher Simmonds (@benibenj)

Matched files:

  • src/vs/base/browser/ui/tree/asyncDataTree.ts
  • src/vs/workbench/browser/parts/editor/editorGroupView.ts
  • src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts
  • src/vs/workbench/browser/parts/editor/swallowMiddleClickPaste.ts

@Fahad090NP

Copy link
Copy Markdown
Author

Context: this PR replaces #329446, which was closed automatically when my fork was deleted from GitHub. GitHub cannot reopen a PR whose head repository was deleted, so the branch was rebuilt from the original commits (same commit messages and authorship) on top of the current main, which also resolves the merge conflicts the original had.

Maintainers: please judge this PR in place of the closed #329446. Thank you!

Copilot AI 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.

🟡 Changes recommended

Listener retention, terminal targeting, and paste suppression issues remain unresolved.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds middle-click shortcuts for creating Explorer folders and opening terminal editors.

Changes:

  • Exposes tree middle-click events.
  • Handles middle-clicks on empty Explorer and editor surfaces.
  • Suppresses Linux middle-click paste behavior.
File summaries
File Description
src/vs/workbench/contrib/files/browser/views/explorerViewer.ts Guards new-name inputs against middle-click paste.
src/vs/workbench/contrib/files/browser/views/explorerView.ts Creates folders from empty Explorer space.
src/vs/workbench/browser/parts/editor/swallowMiddleClickPaste.ts Adds middle-click paste suppression.
src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts Opens terminals from empty tab rows.
src/vs/workbench/browser/parts/editor/editorGroupView.ts Handles empty editor-group middle-clicks.
src/vs/base/browser/ui/tree/asyncDataTree.ts Exposes middle-click events.
Review details

Suppressed comments (2)

src/vs/workbench/browser/parts/editor/editorGroupView.ts:430

  • Plain middle-click still reaches this branch and closes the empty group, while the PR and linked issue require plain middle-click to open a terminal instead. Requiring Ctrl/Meta means the advertised empty-canvas shortcut is not implemented; remove the modifier split and always take the terminal path.
				} else {
					this.groupsView.removeGroup(this);

src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts:428

  • This command defaults to ACTIVE_GROUP (terminalActions.ts:322), but middle-button presses on the title are ignored by the group focus handler (editorGroupView.ts:509). Middle-clicking an inactive group's empty tabs row can therefore open the terminal in a different group (or window). Pass the clicked group as the command location.
				this.commandService.executeCommand('workbench.action.createTerminalEditor');
  • Files reviewed: 6/6 changed files
  • Comments generated: 5
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vs/workbench/browser/parts/editor/editorGroupView.ts Outdated
Comment thread src/vs/workbench/browser/parts/editor/editorGroupView.ts Outdated
Comment thread src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts Outdated
Comment thread src/vs/workbench/browser/parts/editor/swallowMiddleClickPaste.ts
Comment thread src/vs/workbench/contrib/files/browser/views/explorerViewer.ts Outdated
- editorGroupView: use MutableDisposable for paste guard, activate group
  before creating terminal, remove modifier-key requirement
- multiEditorTabsControl: use MutableDisposable for paste guard, activate
  group before creating terminal
- swallowMiddleClickPaste: dispose guard immediately after capturing
  matching event instead of waiting for full timeout
- explorerViewer: replace value === '' check with explicit one-shot
  Linux middle-click flag to avoid blocking pastes on non-middle-click
  inputs
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.

Middle-click empty Explorer space to create a new folder and middle-click empty editor space to open a new terminal

3 participants