testing: sort by status or location, not name

Fixes #126620
Fixes #127122
This commit is contained in:
Connor Peet 2021-07-07 12:57:02 -07:00
parent 583f6d1418
commit c2398f8fbd
No known key found for this signature in database
GPG key ID: CF8FD2EA0DBC61BD
3 changed files with 16 additions and 19 deletions

View file

@ -411,14 +411,14 @@ export class TestingViewAsTreeAction extends ViewAction<TestingExplorerView> {
}
export class TestingSortByNameAction extends ViewAction<TestingExplorerView> {
public static readonly ID = 'testing.sortByName';
export class TestingSortByStatusAction extends ViewAction<TestingExplorerView> {
public static readonly ID = 'testing.sortByStatus';
constructor() {
super({
id: TestingSortByNameAction.ID,
id: TestingSortByStatusAction.ID,
viewId: Testing.ExplorerViewId,
title: localize('testing.sortByName', "Sort by Name"),
toggled: TestingContextKeys.viewSorting.isEqualTo(TestExplorerViewSorting.ByName),
title: localize('testing.sortByStatus', "Sort by Status"),
toggled: TestingContextKeys.viewSorting.isEqualTo(TestExplorerViewSorting.ByStatus),
menu: {
id: MenuId.ViewTitle,
order: ActionOrder.Sort,
@ -432,7 +432,7 @@ export class TestingSortByNameAction extends ViewAction<TestingExplorerView> {
* @override
*/
public runInView(_accessor: ServicesAccessor, view: TestingExplorerView) {
view.viewModel.viewSorting = TestExplorerViewSorting.ByName;
view.viewModel.viewSorting = TestExplorerViewSorting.ByStatus;
}
}
@ -1182,7 +1182,7 @@ export const allTestActions = [
SearchForTestExtension,
ShowMostRecentOutputAction,
TestingSortByLocationAction,
TestingSortByNameAction,
TestingSortByStatusAction,
TestingViewAsListAction,
TestingViewAsTreeAction,
UnhideTestAction,

View file

@ -252,7 +252,7 @@ export class TestingExplorerViewModel extends Disposable {
public get viewSorting() {
return this._viewSorting.get() ?? TestExplorerViewSorting.ByLocation;
return this._viewSorting.get() ?? TestExplorerViewSorting.ByStatus;
}
public set viewSorting(newSorting: TestExplorerViewSorting) {
@ -714,18 +714,15 @@ class TreeSorter implements ITreeSorter<TestExplorerTreeElement> {
return (a instanceof TestTreeErrorMessage ? -1 : 0) + (b instanceof TestTreeErrorMessage ? 1 : 0);
}
let delta = cmpPriority(a.state, b.state);
if (delta !== 0) {
return delta;
const stateDelta = cmpPriority(a.state, b.state);
if (this.viewModel.viewSorting === TestExplorerViewSorting.ByStatus && stateDelta !== 0) {
return stateDelta;
}
if (this.viewModel.viewSorting === TestExplorerViewSorting.ByLocation) {
if (a instanceof TestItemTreeElement && b instanceof TestItemTreeElement
&& a.test.item.uri && b.test.item.uri && a.test.item.uri.toString() === b.test.item.uri.toString() && a.test.item.range && b.test.item.range) {
const delta = a.test.item.range.startLineNumber - b.test.item.range.startLineNumber;
if (delta !== 0) {
return delta;
}
if (a instanceof TestItemTreeElement && b instanceof TestItemTreeElement && a.test.item.uri && b.test.item.uri && a.test.item.uri.toString() === b.test.item.uri.toString() && a.test.item.range && b.test.item.range) {
const delta = a.test.item.range.startLineNumber - b.test.item.range.startLineNumber;
if (delta !== 0) {
return delta;
}
}

View file

@ -22,7 +22,7 @@ export const enum TestExplorerViewMode {
export const enum TestExplorerViewSorting {
ByLocation = 'location',
ByName = 'name',
ByStatus = 'status',
}
export const enum TestExplorerStateFilter {