Skip to content

Add "collapse visible comments" keybinding#289116

Merged
alexr00 merged 1 commit intomainfrom
alexr00/bright-grouse
Jan 20, 2026
Merged

Add "collapse visible comments" keybinding#289116
alexr00 merged 1 commit intomainfrom
alexr00/bright-grouse

Conversation

@alexr00
Copy link
Copy Markdown
Member

@alexr00 alexr00 commented Jan 20, 2026

No description provided.

Copilot AI review requested due to automatic review settings January 20, 2026 14:39
@alexr00 alexr00 enabled auto-merge (squash) January 20, 2026 14:39
@alexr00 alexr00 self-assigned this Jan 20, 2026
@vs-code-engineering vs-code-engineering bot added this to the January 2026 milestone Jan 20, 2026
Copy link
Copy Markdown
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 adds a new keybinding (Cmd+Escape / Alt+Backspace on Windows) to collapse all visible comment widgets in the editor. It introduces a commentWidgetVisible context key to enable the keybinding only when comment widgets are visible, and updates the chat cancel action to prevent keybinding conflicts.

Changes:

  • Added commentWidgetVisible context key to track when comment widgets are visible
  • Implemented collapseVisibleComments() method to collapse only visible comment threads
  • Registered new keybinding with context-aware activation
  • Updated chat cancel action keybinding to avoid conflicts with the new comment keybinding

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/vs/workbench/contrib/comments/common/commentContextKeys.ts Adds new commentWidgetVisible context key definition
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts Registers new keybinding for collapsing visible comments with Cmd+Escape
src/vs/workbench/contrib/comments/browser/commentsController.ts Implements context key tracking, widget visibility updates, and collapseVisibleComments() method
src/vs/workbench/contrib/comments/browser/commentsAccessibility.ts Updates accessibility help text to use dynamic keybinding reference
src/vs/workbench/contrib/comments/browser/commentThreadZoneWidget.ts Adds expand/collapse state change events to notify controller
src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts Adds context condition to chat cancel keybinding to prevent conflicts

Comment on lines 1099 to +1102
await zoneWidget.display(thread.range, shouldReveal);
this._commentWidgets.push(zoneWidget);
zoneWidget.onDidChangeExpandedState(() => this._updateCommentWidgetVisibleContext());
zoneWidget.onDidClose(() => this._updateCommentWidgetVisibleContext());
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The event listeners for onDidChangeExpandedState and onDidClose are registered after the widget is displayed. If the widget expands during the display() call (which happens when collapsibleState === Expanded), the expand event will fire before the listeners are registered, causing the context key commentWidgetVisible not to be set to true. The listeners should be registered before calling display(), or _updateCommentWidgetVisibleContext() should be called explicitly after the widget is added.

Suggested change
await zoneWidget.display(thread.range, shouldReveal);
this._commentWidgets.push(zoneWidget);
zoneWidget.onDidChangeExpandedState(() => this._updateCommentWidgetVisibleContext());
zoneWidget.onDidClose(() => this._updateCommentWidgetVisibleContext());
this._commentWidgets.push(zoneWidget);
zoneWidget.onDidChangeExpandedState(() => this._updateCommentWidgetVisibleContext());
zoneWidget.onDidClose(() => this._updateCommentWidgetVisibleContext());
await zoneWidget.display(thread.range, shouldReveal);

Copilot uses AI. Check for mistakes.
@alexr00 alexr00 merged commit 9d2710f into main Jan 20, 2026
27 of 28 checks passed
@alexr00 alexr00 deleted the alexr00/bright-grouse branch January 20, 2026 15:02
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants