Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: prefer to keep insertion order on the same location without sortText #173350

Merged
merged 1 commit into from Feb 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -991,14 +991,19 @@ class TreeSorter implements ITreeSorter<TestExplorerTreeElement> {
return stateDelta;
}

let inSameLocation = false;
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) {
inSameLocation = true;

const delta = a.test.item.range.startLineNumber - b.test.item.range.startLineNumber;
if (delta !== 0) {
return delta;
}
}

return (a.sortText || a.label).localeCompare(b.sortText || b.label);
// If tests are in the same location and there's no preferred sortText,
// keep the extension's insertion order (#163449).
return inSameLocation && !a.sortText && !b.sortText ? 0 : (a.sortText || a.label).localeCompare(b.sortText || b.label);
}
}

Expand Down