提交 e60eaf71 编写于 作者: J Joao Moreno

splitview: more 💄

上级 be455106
......@@ -498,17 +498,17 @@ export class SplitView implements IDisposable {
return 0;
}
let upIndexes = range(index, -1);
let downIndexes = range(index + 1, this.viewItems.length);
const upIndexes = range(index, -1);
const downIndexes = range(index + 1, this.viewItems.length);
if (typeof highPriorityIndex === 'number') {
upIndexes = pushToStart(upIndexes, highPriorityIndex);
downIndexes = pushToStart(downIndexes, highPriorityIndex);
pushToStart(upIndexes, highPriorityIndex);
pushToStart(downIndexes, highPriorityIndex);
}
if (typeof lowPriorityIndex === 'number') {
upIndexes = pushToEnd(upIndexes, lowPriorityIndex);
downIndexes = pushToEnd(downIndexes, lowPriorityIndex);
pushToEnd(upIndexes, lowPriorityIndex);
pushToEnd(downIndexes, lowPriorityIndex);
}
const upItems = upIndexes.map(i => this.viewItems[i]);
......
......@@ -467,43 +467,23 @@ export function shuffle<T>(array: T[]): void {
/**
* Pushes an element to the start of the array, if found.
*/
export function pushToStart<T>(arr: T[], value: T): T[] {
let didFindValue = false;
export function pushToStart<T>(arr: T[], value: T): void {
const index = arr.indexOf(value);
const result = arr.filter(v => {
if (v === value) {
didFindValue = true;
return false;
}
return true;
});
if (didFindValue) {
result.unshift(value);
if (index > -1) {
arr.splice(index, 1);
arr.unshift(value);
}
return result;
}
/**
* Pushes an element to the end of the array, if found.
*/
export function pushToEnd<T>(arr: T[], value: T): T[] {
let didFindValue = false;
export function pushToEnd<T>(arr: T[], value: T): void {
const index = arr.indexOf(value);
const result = arr.filter(v => {
if (v === value) {
didFindValue = true;
return false;
}
return true;
});
if (didFindValue) {
result.push(value);
if (index > -1) {
arr.splice(index, 1);
arr.push(value);
}
return result;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册