Skip to content

Commit 664d8a9

Browse files
AidanGGkarthiknadig
authored andcommitted
Use Octicons in Code Lenses (#8486)
* Use Octicons in Code Lenses * Add news
1 parent 9cbd574 commit 664d8a9

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

news/1 Enhancements/7192.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use Octicons in Code Lenses. (thanks [Aidan Dang](https://github.com/AidanGG))

src/client/testing/codeLenses/testFiles.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,16 @@ export class TestFileCodeLensProvider implements CodeLensProvider {
144144
function getTestStatusIcon(status?: TestStatus): string {
145145
switch (status) {
146146
case TestStatus.Pass: {
147-
return '✔ ';
147+
return `${constants.Octicons.Test_Pass} `;
148+
}
149+
case TestStatus.Error: {
150+
return `${constants.Octicons.Test_Error} `;
148151
}
149-
case TestStatus.Error:
150152
case TestStatus.Fail: {
151-
return '✘ ';
153+
return `${constants.Octicons.Test_Fail} `;
152154
}
153155
case TestStatus.Skipped: {
154-
return '⊘ ';
156+
return `${constants.Octicons.Test_Skip} `;
155157
}
156158
default: {
157159
return '';
@@ -163,15 +165,19 @@ function getTestStatusIcons(fns: TestFunction[]): string {
163165
const statuses: string[] = [];
164166
let count = fns.filter(fn => fn.status === TestStatus.Pass).length;
165167
if (count > 0) {
166-
statuses.push(` ${count}`);
168+
statuses.push(`${constants.Octicons.Test_Pass} ${count}`);
167169
}
168-
count = fns.filter(fn => fn.status === TestStatus.Error || fn.status === TestStatus.Fail).length;
170+
count = fns.filter(fn => fn.status === TestStatus.Skipped).length;
169171
if (count > 0) {
170-
statuses.push(` ${count}`);
172+
statuses.push(`${constants.Octicons.Test_Skip} ${count}`);
171173
}
172-
count = fns.filter(fn => fn.status === TestStatus.Skipped).length;
174+
count = fns.filter(fn => fn.status === TestStatus.Fail).length;
175+
if (count > 0) {
176+
statuses.push(`${constants.Octicons.Test_Fail} ${count}`);
177+
}
178+
count = fns.filter(fn => fn.status === TestStatus.Error).length;
173179
if (count > 0) {
174-
statuses.push(` ${count}`);
180+
statuses.push(`${constants.Octicons.Test_Error} ${count}`);
175181
}
176182

177183
return statuses.join(' ');
@@ -219,12 +225,12 @@ function getFunctionCodeLens(file: Uri, functionsAndSuites: FunctionsAndSuites,
219225
// Find all flattened functions.
220226
return [
221227
new CodeLens(range, {
222-
title: `${getTestStatusIcons(functions)}${constants.Text.CodeLensRunUnitTest} (Multiple)`,
228+
title: `${getTestStatusIcons(functions)} ${constants.Text.CodeLensRunUnitTest} (Multiple)`,
223229
command: constants.Commands.Tests_Picker_UI,
224230
arguments: [undefined, CommandSource.codelens, file, functions]
225231
}),
226232
new CodeLens(range, {
227-
title: `${getTestStatusIcons(functions)}${constants.Text.CodeLensDebugUnitTest} (Multiple)`,
233+
title: `${getTestStatusIcons(functions)} ${constants.Text.CodeLensDebugUnitTest} (Multiple)`,
228234
command: constants.Commands.Tests_Picker_UI_Debug,
229235
arguments: [undefined, CommandSource.codelens, file, functions]
230236
})

0 commit comments

Comments
 (0)