File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,11 @@ import {
2323} from './status'
2424import { collectFlatExperimentParams } from './modify/collect'
2525import { Experiment , Row } from '../webview/contract'
26- import { definedAndNonEmpty , reorderListSubset } from '../../util/array'
26+ import {
27+ definedAndNonEmpty ,
28+ reorderListSubset ,
29+ reorderObjectList
30+ } from '../../util/array'
2731import { ExperimentsOutput } from '../../cli/reader'
2832import { setContextValue } from '../../vscode/context'
2933import { hasKey } from '../../util/object'
@@ -592,6 +596,10 @@ export class ExperimentsModel extends ModelWithPersistence {
592596 }
593597 }
594598
595- return acc
599+ return reorderObjectList < SelectedExperimentWithColor > (
600+ copyOriginalColors ( ) ,
601+ acc ,
602+ 'displayColor'
603+ )
596604 }
597605}
Original file line number Diff line number Diff line change @@ -1247,11 +1247,17 @@ suite('Experiments Test Suite', () => {
12471247 const selected = testRepository
12481248 . getSelectedExperiments ( )
12491249 . map ( ( { displayColor, id } ) => ( { displayColor, id } ) )
1250- expect ( selected ) . to . deep . equal ( [
1251- { displayColor : colors [ 1 ] , id : 'test-branch' } ,
1250+ expect (
1251+ selected ,
1252+ 'should retain the order that the experiments were selected in'
1253+ ) . to . deep . equal ( [
12521254 {
12531255 displayColor : colors [ 0 ] ,
12541256 id : 'exp-83425'
1257+ } ,
1258+ {
1259+ displayColor : colors [ 1 ] ,
1260+ id : 'test-branch'
12551261 }
12561262 ] )
12571263 } )
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ export const sameContents = (
2121 otherArray : ( null | string | number | undefined ) [ ]
2222) => isEqual ( array . sort ( ) , otherArray . sort ( ) )
2323
24- export const reorderObjectList = < T extends { [ key : string ] : unknown } > (
24+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25+ export const reorderObjectList = < T extends { [ key : string ] : any } > (
2526 order : string [ ] ,
2627 items : T [ ] ,
2728 compareKey : string
You can’t perform that action at this time.
0 commit comments