@@ -517,6 +517,18 @@ export class CommentController implements IEditorContribution {
517
517
}
518
518
}
519
519
520
+ public collapseAll ( ) : void {
521
+ for ( const widget of this . _commentWidgets ) {
522
+ widget . collapse ( ) ;
523
+ }
524
+ }
525
+
526
+ public expandAll ( ) : void {
527
+ for ( const widget of this . _commentWidgets ) {
528
+ widget . expand ( ) ;
529
+ }
530
+ }
531
+
520
532
public nextCommentThread ( ) : void {
521
533
this . _findNearestCommentThread ( ) ;
522
534
}
@@ -1063,6 +1075,40 @@ MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
1063
1075
when : ActiveCursorHasCommentingRange
1064
1076
} ) ;
1065
1077
1078
+ const COLLAPSE_ALL_COMMENT_COMMAND = 'workbench.action.collapseAllComments' ;
1079
+ CommandsRegistry . registerCommand ( {
1080
+ id : COLLAPSE_ALL_COMMENT_COMMAND ,
1081
+ handler : ( accessor ) => {
1082
+ return getActiveController ( accessor ) ?. collapseAll ( ) ;
1083
+ }
1084
+ } ) ;
1085
+
1086
+ MenuRegistry . appendMenuItem ( MenuId . CommandPalette , {
1087
+ command : {
1088
+ id : COLLAPSE_ALL_COMMENT_COMMAND ,
1089
+ title : nls . localize ( 'comments.collapseAll' , "Collapse All Comments" ) ,
1090
+ category : 'Comments'
1091
+ } ,
1092
+ when : WorkspaceHasCommenting
1093
+ } ) ;
1094
+
1095
+ const EXPAND_ALL_COMMENT_COMMAND = 'workbench.action.expandAllComments' ;
1096
+ CommandsRegistry . registerCommand ( {
1097
+ id : EXPAND_ALL_COMMENT_COMMAND ,
1098
+ handler : ( accessor ) => {
1099
+ return getActiveController ( accessor ) ?. expandAll ( ) ;
1100
+ }
1101
+ } ) ;
1102
+
1103
+ MenuRegistry . appendMenuItem ( MenuId . CommandPalette , {
1104
+ command : {
1105
+ id : EXPAND_ALL_COMMENT_COMMAND ,
1106
+ title : nls . localize ( 'comments.expandAll' , "Expand All Comments" ) ,
1107
+ category : 'Comments'
1108
+ } ,
1109
+ when : WorkspaceHasCommenting
1110
+ } ) ;
1111
+
1066
1112
KeybindingsRegistry . registerCommandAndKeybindingRule ( {
1067
1113
id : 'workbench.action.submitComment' ,
1068
1114
weight : KeybindingWeight . EditorContrib ,
@@ -1108,6 +1154,19 @@ export function getActiveEditor(accessor: ServicesAccessor): IActiveCodeEditor |
1108
1154
return activeTextEditorControl ;
1109
1155
}
1110
1156
1157
+ function getActiveController ( accessor : ServicesAccessor ) : CommentController | undefined {
1158
+ const activeEditor = getActiveEditor ( accessor ) ;
1159
+ if ( ! activeEditor ) {
1160
+ return undefined ;
1161
+ }
1162
+
1163
+ const controller = CommentController . get ( activeEditor ) ;
1164
+ if ( ! controller ) {
1165
+ return undefined ;
1166
+ }
1167
+ return controller ;
1168
+ }
1169
+
1111
1170
registerThemingParticipant ( ( theme , collector ) => {
1112
1171
const peekViewBackground = theme . getColor ( peekViewResultsBackground ) ;
1113
1172
if ( peekViewBackground ) {
0 commit comments