diff --git a/src/vs/base/browser/ui/splitview/splitview.ts b/src/vs/base/browser/ui/splitview/splitview.ts index 2022b7df424336d620e2bba93eb29788c338b1a4..17501bcfafbf8a1d1a37ec21e2d9c317df32f716 100644 --- a/src/vs/base/browser/ui/splitview/splitview.ts +++ b/src/vs/base/browser/ui/splitview/splitview.ts @@ -11,7 +11,7 @@ import { Event, mapEvent, Emitter } from 'vs/base/common/event'; import * as types from 'vs/base/common/types'; import * as dom from 'vs/base/browser/dom'; import { clamp } from 'vs/base/common/numbers'; -import { range, firstIndex } from 'vs/base/common/arrays'; +import { range, firstIndex, pushToStart, pushToEnd } from 'vs/base/common/arrays'; import { Sash, Orientation, ISashEvent as IBaseSashEvent, SashState } from 'vs/base/browser/ui/sash/sash'; import { Color } from 'vs/base/common/color'; import { domEvent } from 'vs/base/browser/event'; @@ -77,44 +77,6 @@ enum State { Busy } -function pushToStart(arr: T[], value: T): T[] { - let didFindValue = false; - - const result = arr.filter(v => { - if (v === value) { - didFindValue = true; - return false; - } - - return true; - }); - - if (didFindValue) { - result.unshift(value); - } - - return result; -} - -function pushToEnd(arr: T[], value: T): T[] { - let didFindValue = false; - - const result = arr.filter(v => { - if (v === value) { - didFindValue = true; - return false; - } - - return true; - }); - - if (didFindValue) { - result.push(value); - } - - return result; -} - export type DistributeSizing = { type: 'distribute' }; export type SplitSizing = { type: 'split', index: number }; export type Sizing = DistributeSizing | SplitSizing; diff --git a/src/vs/base/common/arrays.ts b/src/vs/base/common/arrays.ts index f9ddfdc71aaec6754df0216dce7066d4cb7e41f8..2de4ad21a44d7db2b930b37fe82885a35a32bd86 100644 --- a/src/vs/base/common/arrays.ts +++ b/src/vs/base/common/arrays.ts @@ -463,3 +463,47 @@ export function shuffle(array: T[]): void { array[j] = temp; } } + +/** + * Pushes an element to the start of the array, if found. + */ +export function pushToStart(arr: T[], value: T): T[] { + let didFindValue = false; + + const result = arr.filter(v => { + if (v === value) { + didFindValue = true; + return false; + } + + return true; + }); + + if (didFindValue) { + result.unshift(value); + } + + return result; +} + +/** + * Pushes an element to the end of the array, if found. + */ +export function pushToEnd(arr: T[], value: T): T[] { + let didFindValue = false; + + const result = arr.filter(v => { + if (v === value) { + didFindValue = true; + return false; + } + + return true; + }); + + if (didFindValue) { + result.push(value); + } + + return result; +} \ No newline at end of file