未验证 提交 c2398f8f 编写于 作者: C Connor Peet

testing: sort by status or location, not name

Fixes #126620
Fixes #127122
上级 583f6d14
......@@ -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,
......
......@@ -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;
}
}
......
......@@ -22,7 +22,7 @@ export const enum TestExplorerViewMode {
export const enum TestExplorerViewSorting {
ByLocation = 'location',
ByName = 'name',
ByStatus = 'status',
}
export const enum TestExplorerStateFilter {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册