Add "collapse visible comments" keybinding#289116
Conversation
There was a problem hiding this comment.
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
commentWidgetVisiblecontext 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 |
| await zoneWidget.display(thread.range, shouldReveal); | ||
| this._commentWidgets.push(zoneWidget); | ||
| zoneWidget.onDidChangeExpandedState(() => this._updateCommentWidgetVisibleContext()); | ||
| zoneWidget.onDidClose(() => this._updateCommentWidgetVisibleContext()); |
There was a problem hiding this comment.
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.
| 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); |
No description provided.