Skip to content

Commit 478d1bf

Browse files
authored
Sorting should have the default state checked (microsoft#227007)
and improve label for sort-by-position-in-file Fixes microsoft#226764 Fixes microsoft#226723
1 parent c524486 commit 478d1bf

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/vs/workbench/contrib/comments/browser/commentsView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export class CommentsPanel extends FilterViewPane implements ICommentsView {
172172
this.filters = this._register(new CommentsFilters({
173173
showResolved: this.viewState['showResolved'] !== false,
174174
showUnresolved: this.viewState['showUnresolved'] !== false,
175-
sortBy: this.viewState['sortBy'],
175+
sortBy: this.viewState['sortBy'] ?? CommentsSortOrder.ResourceAscending,
176176
}, this.contextKeyService));
177177
this.filter = new Filter(new FilterOptions(this.filterWidget.getFilterText(), this.filters.showResolved, this.filters.showUnresolved));
178178

src/vs/workbench/contrib/comments/browser/commentsViewActions.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
77
import { Disposable } from 'vs/base/common/lifecycle';
88
import { localize } from 'vs/nls';
99
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
10-
import { ContextKeyExpr, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
10+
import { ContextKeyExpr, IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
1111
import { Event, Emitter } from 'vs/base/common/event';
1212
import { CommentsViewFilterFocusContextKey, ICommentsView } from 'vs/workbench/contrib/comments/browser/comments';
1313
import { MenuId, MenuRegistry, registerAction2 } from 'vs/platform/actions/common/actions';
@@ -74,9 +74,9 @@ export class CommentsFilters extends Disposable {
7474
}
7575
}
7676

77-
private _sortBy = CONTEXT_KEY_SORT_BY.bindTo(this.contextKeyService);
77+
private _sortBy: IContextKey<CommentsSortOrder> = CONTEXT_KEY_SORT_BY.bindTo(this.contextKeyService);
7878
get sortBy(): CommentsSortOrder {
79-
return this._sortBy.get()!;
79+
return this._sortBy.get() ?? CommentsSortOrder.ResourceAscending;
8080
}
8181
set sortBy(sortBy: CommentsSortOrder) {
8282
if (this._sortBy.get() !== sortBy) {
@@ -208,7 +208,7 @@ registerAction2(class extends ViewAction<ICommentsView> {
208208
icon: Codicon.history,
209209
viewId: COMMENTS_VIEW_ID,
210210
toggled: {
211-
condition: ContextKeyExpr.equals('commentsView.sortBy', CommentsSortOrder.UpdatedAtDescending),
211+
condition: ContextKeyExpr.equals(CONTEXT_KEY_SORT_BY.key, CommentsSortOrder.UpdatedAtDescending),
212212
title: localize('sorting by updated at', "Updated Time"),
213213
},
214214
menu: {
@@ -229,13 +229,13 @@ registerAction2(class extends ViewAction<ICommentsView> {
229229
constructor() {
230230
super({
231231
id: `workbench.actions.${COMMENTS_VIEW_ID}.toggleSortByResource`,
232-
title: localize('toggle sorting by resource', "File"),
232+
title: localize('toggle sorting by resource', "Position in File"),
233233
category: localize('comments', "Comments"),
234234
icon: Codicon.history,
235235
viewId: COMMENTS_VIEW_ID,
236236
toggled: {
237-
condition: ContextKeyExpr.equals('commentsView.sortBy', CommentsSortOrder.ResourceAscending),
238-
title: localize('sorting by file', "File"),
237+
condition: ContextKeyExpr.equals(CONTEXT_KEY_SORT_BY.key, CommentsSortOrder.ResourceAscending),
238+
title: localize('sorting by position in file', "Position in File"),
239239
},
240240
menu: {
241241
id: commentSortSubmenu,

0 commit comments

Comments
 (0)