Skip to content

Commit 24a0699

Browse files
committed
1 parent 30e7a52 commit 24a0699

2 files changed

Lines changed: 38 additions & 11 deletions

File tree

src/vs/workbench/contrib/debug/common/debugUtils.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ export function getVisibleAndSorted<T extends { presentation?: IConfigPresentati
246246
return -1;
247247
}
248248
if (!first.presentation.group) {
249+
if (!second.presentation.group) {
250+
return compareOrders(first.presentation.order, second.presentation.order);
251+
}
249252
return 1;
250253
}
251254
if (!second.presentation.group) {
@@ -254,13 +257,18 @@ export function getVisibleAndSorted<T extends { presentation?: IConfigPresentati
254257
if (first.presentation.group !== second.presentation.group) {
255258
return first.presentation.group.localeCompare(second.presentation.group);
256259
}
257-
if (typeof first.presentation.order !== 'number') {
258-
return 1;
259-
}
260-
if (typeof second.presentation.order !== 'number') {
261-
return -1;
262-
}
263260

264-
return first.presentation.order - second.presentation.order;
261+
return compareOrders(first.presentation.order, second.presentation.order);
265262
});
266263
}
264+
265+
function compareOrders(first: number | undefined, second: number | undefined): number {
266+
if (typeof first !== 'number') {
267+
return 1;
268+
}
269+
if (typeof second !== 'number') {
270+
return -1;
271+
}
272+
273+
return first - second;
274+
}

src/vs/workbench/contrib/debug/test/common/debugUtils.test.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,34 @@ suite('Debug - Utils', () => {
103103
order: 500
104104
}
105105
});
106+
configs.push({
107+
type: 'node',
108+
request: 'launch',
109+
name: 'h',
110+
presentation: {
111+
order: 700
112+
}
113+
});
114+
configs.push({
115+
type: 'node',
116+
request: 'launch',
117+
name: 'i',
118+
presentation: {
119+
order: 1000
120+
}
121+
});
106122

107123
const sorted = getVisibleAndSorted(configs);
108-
assert.equal(sorted.length, 7);
124+
assert.equal(sorted.length, 9);
109125
assert.equal(sorted[0].name, 'f');
110126
assert.equal(sorted[1].name, 'd');
111127
assert.equal(sorted[2].name, 'e');
112128
assert.equal(sorted[3].name, 'g');
113-
assert.equal(sorted[4].name, 'b');
114-
assert.equal(sorted[5].name, 'p');
115-
assert.equal(sorted[6].name, 'a');
129+
assert.equal(sorted[4].name, 'h');
130+
assert.equal(sorted[5].name, 'i');
131+
assert.equal(sorted[6].name, 'b');
132+
assert.equal(sorted[7].name, 'p');
133+
assert.equal(sorted[8].name, 'a');
134+
116135
});
117136
});

0 commit comments

Comments
 (0)