@lvce-editor/file-search-worker 5.10.0 → 5.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fileSearchWorkerMain.js +107 -15
- package/package.json +1 -1
|
@@ -940,7 +940,7 @@ const create$1 = ({
|
|
|
940
940
|
scrollBarActive: false
|
|
941
941
|
};
|
|
942
942
|
};
|
|
943
|
-
const getListHeight = (height, headerHeight) => {
|
|
943
|
+
const getListHeight$1 = (height, headerHeight) => {
|
|
944
944
|
if (headerHeight) {
|
|
945
945
|
return height - headerHeight;
|
|
946
946
|
}
|
|
@@ -955,7 +955,7 @@ const setDeltaY = (state, deltaY) => {
|
|
|
955
955
|
height,
|
|
956
956
|
headerHeight
|
|
957
957
|
} = state;
|
|
958
|
-
const listHeight = getListHeight(height, headerHeight);
|
|
958
|
+
const listHeight = getListHeight$1(height, headerHeight);
|
|
959
959
|
const itemsLength = items.length;
|
|
960
960
|
const finalDeltaY = itemsLength * itemHeight - listHeight;
|
|
961
961
|
if (deltaY < 0) {
|
|
@@ -1709,6 +1709,23 @@ const getFilterValue = (id, value) => {
|
|
|
1709
1709
|
return filterValue;
|
|
1710
1710
|
};
|
|
1711
1711
|
|
|
1712
|
+
const getFinalDeltaY = (height, itemHeight, itemsLength) => {
|
|
1713
|
+
const contentHeight = itemsLength * itemHeight;
|
|
1714
|
+
const finalDeltaY = Math.max(contentHeight - height, 0);
|
|
1715
|
+
return finalDeltaY;
|
|
1716
|
+
};
|
|
1717
|
+
|
|
1718
|
+
const getListHeight = (itemsLength, itemHeight, maxHeight) => {
|
|
1719
|
+
number(itemsLength);
|
|
1720
|
+
number(itemHeight);
|
|
1721
|
+
number(maxHeight);
|
|
1722
|
+
if (itemsLength === 0) {
|
|
1723
|
+
return itemHeight;
|
|
1724
|
+
}
|
|
1725
|
+
const totalHeight = itemsLength * itemHeight;
|
|
1726
|
+
return Math.min(totalHeight, maxHeight);
|
|
1727
|
+
};
|
|
1728
|
+
|
|
1712
1729
|
const getColorThemeNames = async () => {
|
|
1713
1730
|
return invoke$1(/* Ajax.getJson */'ColorTheme.getColorThemeNames');
|
|
1714
1731
|
};
|
|
@@ -1805,6 +1822,8 @@ const toProtoVisibleItem$1 = item => {
|
|
|
1805
1822
|
};
|
|
1806
1823
|
// @ts-ignore
|
|
1807
1824
|
pick.id = item.id;
|
|
1825
|
+
// @ts-ignore
|
|
1826
|
+
pick.args = item.args;
|
|
1808
1827
|
return pick;
|
|
1809
1828
|
};
|
|
1810
1829
|
const getPicks$b = async () => {
|
|
@@ -2279,7 +2298,9 @@ const setValue = async (state, newValue) => {
|
|
|
2279
2298
|
value,
|
|
2280
2299
|
minLineY,
|
|
2281
2300
|
maxLineY,
|
|
2282
|
-
fileIconCache
|
|
2301
|
+
fileIconCache,
|
|
2302
|
+
itemHeight,
|
|
2303
|
+
height
|
|
2283
2304
|
} = state;
|
|
2284
2305
|
if (value === newValue) {
|
|
2285
2306
|
return state;
|
|
@@ -2295,6 +2316,8 @@ const setValue = async (state, newValue) => {
|
|
|
2295
2316
|
newFileIconCache,
|
|
2296
2317
|
icons
|
|
2297
2318
|
} = await getQuickPickFileIcons(sliced, fileIconCache);
|
|
2319
|
+
const listHeight = getListHeight(items.length, itemHeight, height);
|
|
2320
|
+
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, items.length);
|
|
2298
2321
|
return {
|
|
2299
2322
|
...state,
|
|
2300
2323
|
picks: newPicks,
|
|
@@ -2303,7 +2326,8 @@ const setValue = async (state, newValue) => {
|
|
|
2303
2326
|
inputSource: Script,
|
|
2304
2327
|
value: newValue,
|
|
2305
2328
|
icons,
|
|
2306
|
-
fileIconCache: newFileIconCache
|
|
2329
|
+
fileIconCache: newFileIconCache,
|
|
2330
|
+
finalDeltaY
|
|
2307
2331
|
};
|
|
2308
2332
|
};
|
|
2309
2333
|
|
|
@@ -2479,7 +2503,9 @@ const loadContent = async state => {
|
|
|
2479
2503
|
const {
|
|
2480
2504
|
uri,
|
|
2481
2505
|
args,
|
|
2482
|
-
fileIconCache
|
|
2506
|
+
fileIconCache,
|
|
2507
|
+
itemHeight,
|
|
2508
|
+
height
|
|
2483
2509
|
} = state;
|
|
2484
2510
|
const id = getQuickPickProviderId(uri);
|
|
2485
2511
|
const value = getDefaultValue(id);
|
|
@@ -2497,6 +2523,8 @@ const loadContent = async state => {
|
|
|
2497
2523
|
newFileIconCache,
|
|
2498
2524
|
icons
|
|
2499
2525
|
} = await getQuickPickFileIcons(sliced, fileIconCache);
|
|
2526
|
+
const listHeight = getListHeight(items.length, itemHeight, height);
|
|
2527
|
+
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, items.length);
|
|
2500
2528
|
return {
|
|
2501
2529
|
...state,
|
|
2502
2530
|
picks: newPicks,
|
|
@@ -2511,7 +2539,8 @@ const loadContent = async state => {
|
|
|
2511
2539
|
focused: true,
|
|
2512
2540
|
fileIconCache: newFileIconCache,
|
|
2513
2541
|
icons,
|
|
2514
|
-
providerId: id
|
|
2542
|
+
providerId: id,
|
|
2543
|
+
finalDeltaY
|
|
2515
2544
|
};
|
|
2516
2545
|
};
|
|
2517
2546
|
|
|
@@ -2526,6 +2555,13 @@ const getVisible$1 = (items, minLineY, maxLineY, icons) => {
|
|
|
2526
2555
|
return protoVisibleItems;
|
|
2527
2556
|
};
|
|
2528
2557
|
|
|
2558
|
+
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
2559
|
+
if (size >= contentSize) {
|
|
2560
|
+
return 0;
|
|
2561
|
+
}
|
|
2562
|
+
return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
|
|
2563
|
+
};
|
|
2564
|
+
|
|
2529
2565
|
const emptyHighlightSections = [];
|
|
2530
2566
|
|
|
2531
2567
|
const getHighlightSections = (highlights, label) => {
|
|
@@ -2576,14 +2612,31 @@ const getVisible = (setSize, protoVisibleItems, minLineY, focusedIndex) => {
|
|
|
2576
2612
|
return visibleItems;
|
|
2577
2613
|
};
|
|
2578
2614
|
|
|
2615
|
+
const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
|
|
2616
|
+
const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
|
|
2617
|
+
return scrollBarOffset;
|
|
2618
|
+
};
|
|
2619
|
+
const getScrollBarY = getScrollBarOffset;
|
|
2620
|
+
|
|
2579
2621
|
const createQuickPickViewModel = (oldState, newState) => {
|
|
2580
2622
|
const protoVisibleItems = getVisible$1(newState.items, newState.minLineY, newState.maxLineY, newState.icons);
|
|
2581
2623
|
const visibleItems = getVisible(newState.items.length, protoVisibleItems, newState.minLineY, newState.focusedIndex);
|
|
2582
2624
|
const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY;
|
|
2583
2625
|
const newFocusedIndex = newState.focusedIndex - newState.minLineY;
|
|
2584
|
-
const
|
|
2585
|
-
const
|
|
2586
|
-
|
|
2626
|
+
const itemCount = newState.items.length;
|
|
2627
|
+
const {
|
|
2628
|
+
itemHeight,
|
|
2629
|
+
deltaY,
|
|
2630
|
+
finalDeltaY,
|
|
2631
|
+
minimumSliderSize,
|
|
2632
|
+
headerHeight,
|
|
2633
|
+
height
|
|
2634
|
+
} = newState;
|
|
2635
|
+
const listHeight = getListHeight(itemCount, itemHeight, height);
|
|
2636
|
+
const contentHeight = itemCount * itemHeight;
|
|
2637
|
+
const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, minimumSliderSize);
|
|
2638
|
+
const scrollBarY = getScrollBarY(deltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
2639
|
+
const roundedScrollBarY = Math.round(scrollBarY);
|
|
2587
2640
|
return {
|
|
2588
2641
|
visibleItems,
|
|
2589
2642
|
value: newState.value,
|
|
@@ -2592,7 +2645,9 @@ const createQuickPickViewModel = (oldState, newState) => {
|
|
|
2592
2645
|
height,
|
|
2593
2646
|
oldFocusedIndex,
|
|
2594
2647
|
newFocusedIndex,
|
|
2595
|
-
uid: newState.uid
|
|
2648
|
+
uid: newState.uid,
|
|
2649
|
+
scrollBarHeight,
|
|
2650
|
+
scrollBarTop: roundedScrollBarY
|
|
2596
2651
|
};
|
|
2597
2652
|
};
|
|
2598
2653
|
|
|
@@ -2626,9 +2681,12 @@ const ListBox = 'listbox';
|
|
|
2626
2681
|
const None = 'none';
|
|
2627
2682
|
const Option = 'option';
|
|
2628
2683
|
|
|
2684
|
+
const ContainContent = 'ContainContent';
|
|
2629
2685
|
const FileIcon = 'FileIcon';
|
|
2630
2686
|
const InputBox = 'InputBox';
|
|
2631
2687
|
const Label = 'Label';
|
|
2688
|
+
const List = 'List';
|
|
2689
|
+
const ListItems = 'ListItems';
|
|
2632
2690
|
const MaskIcon = 'MaskIcon';
|
|
2633
2691
|
const QuickPick$1 = 'QuickPick';
|
|
2634
2692
|
const QuickPickHeader = 'QuickPickHeader';
|
|
@@ -2637,9 +2695,11 @@ const QuickPickItem = 'QuickPickItem';
|
|
|
2637
2695
|
const QuickPickItemActive$1 = 'QuickPickItemActive';
|
|
2638
2696
|
const QuickPickItemDescription = 'QuickPickItemDescription';
|
|
2639
2697
|
const QuickPickItemLabel = 'QuickPickItemLabel';
|
|
2640
|
-
const QuickPickItems$1 = 'QuickPickItems';
|
|
2641
2698
|
const QuickPickMaskIcon = 'QuickPickMaskIcon';
|
|
2642
2699
|
const QuickPickStatus = 'QuickPickStatus';
|
|
2700
|
+
const ScrollBar = 'ScrollBar';
|
|
2701
|
+
const ScrollBarSmall = 'ScrollBarSmall';
|
|
2702
|
+
const ScrollBarThumb = 'ScrollBarThumb';
|
|
2643
2703
|
const Viewlet = 'Viewlet';
|
|
2644
2704
|
|
|
2645
2705
|
const HandleWheel = 'handleWheel';
|
|
@@ -2810,8 +2870,36 @@ const getQuickPickItemsVirtualDom = visibleItems => {
|
|
|
2810
2870
|
return dom;
|
|
2811
2871
|
};
|
|
2812
2872
|
|
|
2813
|
-
const
|
|
2873
|
+
const px = value => {
|
|
2874
|
+
return `${value}px`;
|
|
2875
|
+
};
|
|
2876
|
+
const position = (x, y) => {
|
|
2877
|
+
return `${x}px ${y}px`;
|
|
2878
|
+
};
|
|
2879
|
+
|
|
2880
|
+
const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
|
|
2881
|
+
const shouldShowScrollbar = scrollBarHeight > 0;
|
|
2882
|
+
if (!shouldShowScrollbar) {
|
|
2883
|
+
return [];
|
|
2884
|
+
}
|
|
2885
|
+
const heightString = px(scrollBarHeight);
|
|
2886
|
+
const translateString = position(0, scrollBarTop);
|
|
2887
|
+
return [{
|
|
2888
|
+
type: Div,
|
|
2889
|
+
className: mergeClassNames(ScrollBar, ScrollBarSmall),
|
|
2890
|
+
childCount: 1
|
|
2891
|
+
}, {
|
|
2892
|
+
type: Div,
|
|
2893
|
+
className: ScrollBarThumb,
|
|
2894
|
+
childCount: 0,
|
|
2895
|
+
height: heightString,
|
|
2896
|
+
translate: translateString
|
|
2897
|
+
}];
|
|
2898
|
+
};
|
|
2899
|
+
|
|
2900
|
+
const getQuickPickVirtualDom = (visibleItems, scrollBarHeight, scrollBarTop) => {
|
|
2814
2901
|
const quickOpen$1 = quickOpen();
|
|
2902
|
+
const shouldShowScrollbar = scrollBarHeight > 0;
|
|
2815
2903
|
return [{
|
|
2816
2904
|
type: Div,
|
|
2817
2905
|
className: mergeClassNames(Viewlet, QuickPick$1),
|
|
@@ -2820,18 +2908,22 @@ const getQuickPickVirtualDom = visibleItems => {
|
|
|
2820
2908
|
ariaLabel: quickOpen$1
|
|
2821
2909
|
}, ...getQuickPickHeaderVirtualDom(), {
|
|
2822
2910
|
type: Div,
|
|
2823
|
-
className:
|
|
2911
|
+
className: mergeClassNames(List, ContainContent),
|
|
2824
2912
|
id: QuickPickItems,
|
|
2825
2913
|
role: ListBox,
|
|
2826
2914
|
ariaActivedescendant: QuickPickItemActive,
|
|
2827
2915
|
onWheel: HandleWheel,
|
|
2828
2916
|
onPointerDown: HandlePointerDown,
|
|
2917
|
+
childCount: shouldShowScrollbar ? 2 : 1
|
|
2918
|
+
}, {
|
|
2919
|
+
type: Div,
|
|
2920
|
+
className: mergeClassNames(ListItems, ContainContent),
|
|
2829
2921
|
childCount: visibleItems.length
|
|
2830
|
-
}, ...getQuickPickItemsVirtualDom(visibleItems)];
|
|
2922
|
+
}, ...getQuickPickItemsVirtualDom(visibleItems), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarTop)];
|
|
2831
2923
|
};
|
|
2832
2924
|
|
|
2833
2925
|
const renderItems = newState => {
|
|
2834
|
-
const dom = getQuickPickVirtualDom(newState.visibleItems);
|
|
2926
|
+
const dom = getQuickPickVirtualDom(newState.visibleItems, newState.scrollBarHeight, newState.scrollBarTop);
|
|
2835
2927
|
return ['Viewlet.setDom2', dom];
|
|
2836
2928
|
};
|
|
2837
2929
|
|