@lvce-editor/source-control-worker 1.22.0 → 1.23.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/sourceControlWorkerMain.js +84 -35
- package/package.json +1 -1
|
@@ -1619,7 +1619,10 @@ const create2 = (id, uri, x, y, width, height, workspacePath) => {
|
|
|
1619
1619
|
inputFontSize: 13,
|
|
1620
1620
|
inputFontWeight: 400,
|
|
1621
1621
|
inputLetterSpacing: 0,
|
|
1622
|
-
inputLineHeight:
|
|
1622
|
+
inputLineHeight: 20,
|
|
1623
|
+
inputBoxMaxHeight: 214,
|
|
1624
|
+
history: [],
|
|
1625
|
+
viewMode: 1
|
|
1623
1626
|
};
|
|
1624
1627
|
set$1(id, state, state);
|
|
1625
1628
|
};
|
|
@@ -1896,6 +1899,28 @@ const getGroups = async enabledProviderIds => {
|
|
|
1896
1899
|
};
|
|
1897
1900
|
};
|
|
1898
1901
|
|
|
1902
|
+
const getTextHeight = async (input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight) => {
|
|
1903
|
+
try {
|
|
1904
|
+
const actualInput = '\n' + input;
|
|
1905
|
+
// TODO line height could also be like 1.5
|
|
1906
|
+
const lineHeightPx = `${lineHeight}px`;
|
|
1907
|
+
// @ts-ignore
|
|
1908
|
+
const height = await invoke$2(`MeasureTextHeight.measureTextBlockHeight`, actualInput, fontFamily, fontSize, lineHeightPx, width);
|
|
1909
|
+
return height;
|
|
1910
|
+
} catch {
|
|
1911
|
+
// fallback
|
|
1912
|
+
const lines = input.split('\n');
|
|
1913
|
+
const lineCount = lines.length;
|
|
1914
|
+
const inputHeight = lineCount * lineHeight;
|
|
1915
|
+
return inputHeight;
|
|
1916
|
+
}
|
|
1917
|
+
};
|
|
1918
|
+
|
|
1919
|
+
const getInputHeight = async (input, width, fontFamily, fontWeight, fontSize, letterSpacing, lineHeight) => {
|
|
1920
|
+
const height = await getTextHeight(input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight);
|
|
1921
|
+
return height;
|
|
1922
|
+
};
|
|
1923
|
+
|
|
1899
1924
|
const getListHeight = (itemsLength, itemHeight, maxHeight) => {
|
|
1900
1925
|
number(itemsLength);
|
|
1901
1926
|
number(itemHeight);
|
|
@@ -1984,6 +2009,19 @@ const restoreExpandedGroups = groups => {
|
|
|
1984
2009
|
}, Object.create(null));
|
|
1985
2010
|
};
|
|
1986
2011
|
|
|
2012
|
+
const getRestoredInputValue = savedState => {
|
|
2013
|
+
if (savedState && typeof savedState === 'object' && 'inputValue' in savedState && typeof savedState['inputValue'] === 'string') {
|
|
2014
|
+
return savedState.inputValue;
|
|
2015
|
+
}
|
|
2016
|
+
return '';
|
|
2017
|
+
};
|
|
2018
|
+
const restoreState = savedState => {
|
|
2019
|
+
const inputValue = getRestoredInputValue(savedState);
|
|
2020
|
+
return {
|
|
2021
|
+
inputValue
|
|
2022
|
+
};
|
|
2023
|
+
};
|
|
2024
|
+
|
|
1987
2025
|
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
1988
2026
|
if (size >= contentSize) {
|
|
1989
2027
|
return 0;
|
|
@@ -2013,16 +2051,25 @@ const sourceControlInput = () => {
|
|
|
2013
2051
|
return i18nString(SourceControlInput$1);
|
|
2014
2052
|
};
|
|
2015
2053
|
|
|
2016
|
-
const loadContent = async state => {
|
|
2054
|
+
const loadContent = async (state, savedState) => {
|
|
2017
2055
|
const {
|
|
2018
2056
|
itemHeight,
|
|
2019
2057
|
height,
|
|
2020
2058
|
minimumSliderSize,
|
|
2021
2059
|
workspacePath,
|
|
2022
|
-
fileIconCache
|
|
2060
|
+
fileIconCache,
|
|
2061
|
+
width,
|
|
2062
|
+
inputFontFamily,
|
|
2063
|
+
inputFontSize,
|
|
2064
|
+
inputFontWeight,
|
|
2065
|
+
inputLetterSpacing,
|
|
2066
|
+
inputLineHeight
|
|
2023
2067
|
} = state;
|
|
2024
2068
|
const root = workspacePath;
|
|
2025
2069
|
const scheme = getProtocol(root);
|
|
2070
|
+
const {
|
|
2071
|
+
inputValue
|
|
2072
|
+
} = restoreState(savedState);
|
|
2026
2073
|
const enabledProviderIds = await getEnabledProviderIds(scheme, root);
|
|
2027
2074
|
const {
|
|
2028
2075
|
allGroups,
|
|
@@ -2043,6 +2090,7 @@ const loadContent = async state => {
|
|
|
2043
2090
|
const visibleItems = getVisibleSourceControlItems(displayItems, minLineY, maxLineY, actionsCache, newFileIconCache);
|
|
2044
2091
|
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
|
|
2045
2092
|
const inputPlaceholder = messageEnterToCommitOnMaster();
|
|
2093
|
+
const inputBoxHeight = await getInputHeight(inputValue, width, inputFontFamily, inputFontSize, inputFontWeight, inputLetterSpacing, inputLineHeight);
|
|
2046
2094
|
return {
|
|
2047
2095
|
...state,
|
|
2048
2096
|
actionsCache,
|
|
@@ -2051,7 +2099,9 @@ const loadContent = async state => {
|
|
|
2051
2099
|
fileIconCache: newFileIconCache,
|
|
2052
2100
|
finalDeltaY,
|
|
2053
2101
|
gitRoot,
|
|
2102
|
+
inputBoxHeight,
|
|
2054
2103
|
inputPlaceholder,
|
|
2104
|
+
inputValue,
|
|
2055
2105
|
items: displayItems,
|
|
2056
2106
|
maxLineY,
|
|
2057
2107
|
root,
|
|
@@ -2071,7 +2121,7 @@ const handleButtonClick = async (state, clickedIndex) => {
|
|
|
2071
2121
|
return state;
|
|
2072
2122
|
}
|
|
2073
2123
|
await executeCommand(button.command, item.file);
|
|
2074
|
-
const newState = await loadContent(state);
|
|
2124
|
+
const newState = await loadContent(state, {});
|
|
2075
2125
|
return newState;
|
|
2076
2126
|
};
|
|
2077
2127
|
|
|
@@ -2274,27 +2324,6 @@ const handleFocus = async state => {
|
|
|
2274
2324
|
return state;
|
|
2275
2325
|
};
|
|
2276
2326
|
|
|
2277
|
-
const getTextHeight = async (input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight) => {
|
|
2278
|
-
try {
|
|
2279
|
-
// TODO line height could also be like 1.5
|
|
2280
|
-
const lineHeightPx = `${lineHeight}px`;
|
|
2281
|
-
// @ts-ignore
|
|
2282
|
-
const height = await invoke$2(`MeasureTextHeight.measureTextBlockHeight`, input, fontFamily, fontSize, lineHeightPx, width);
|
|
2283
|
-
return height;
|
|
2284
|
-
} catch {
|
|
2285
|
-
// fallback
|
|
2286
|
-
const lines = input.split('\n');
|
|
2287
|
-
const lineCount = lines.length;
|
|
2288
|
-
const inputHeight = lineCount * lineHeight;
|
|
2289
|
-
return inputHeight;
|
|
2290
|
-
}
|
|
2291
|
-
};
|
|
2292
|
-
|
|
2293
|
-
const getInputHeight = async (input, width, fontFamily, fontWeight, fontSize, letterSpacing, lineHeight) => {
|
|
2294
|
-
const height = await getTextHeight(input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight);
|
|
2295
|
-
return height;
|
|
2296
|
-
};
|
|
2297
|
-
|
|
2298
2327
|
const handleInput = async (state, value, inputSource = User) => {
|
|
2299
2328
|
const {
|
|
2300
2329
|
width,
|
|
@@ -2530,12 +2559,13 @@ const getButtonsVirtualDom = buttons => {
|
|
|
2530
2559
|
}, ...buttons.flatMap(getButtonVirtualDom)];
|
|
2531
2560
|
};
|
|
2532
2561
|
|
|
2562
|
+
const classNameDefault = mergeClassNames(Label, Grow);
|
|
2563
|
+
const classNameStrikeThrough = mergeClassNames(classNameDefault, StrikeThrough);
|
|
2533
2564
|
const getLabelClassName = decorationStrikeThrough => {
|
|
2534
|
-
let className = mergeClassNames(Label, Grow);
|
|
2535
2565
|
if (decorationStrikeThrough) {
|
|
2536
|
-
|
|
2566
|
+
return classNameStrikeThrough;
|
|
2537
2567
|
}
|
|
2538
|
-
return
|
|
2568
|
+
return classNameDefault;
|
|
2539
2569
|
};
|
|
2540
2570
|
|
|
2541
2571
|
const PaddingLeft = '1rem';
|
|
@@ -2564,6 +2594,7 @@ const createItemDirectory = item => {
|
|
|
2564
2594
|
ariaSetSize: setSize,
|
|
2565
2595
|
childCount: 3 + (hasButtons ? 1 : 0),
|
|
2566
2596
|
paddingLeft: PaddingLeft,
|
|
2597
|
+
// TODO classname for indent / padding
|
|
2567
2598
|
paddingRight: PaddingRight
|
|
2568
2599
|
}, {
|
|
2569
2600
|
type: Div,
|
|
@@ -2679,11 +2710,11 @@ const getSplitButtonVirtualDom = (hasItems, splitButtonEnabled, buttonText) => {
|
|
|
2679
2710
|
}
|
|
2680
2711
|
return [{
|
|
2681
2712
|
type: Div,
|
|
2682
|
-
className:
|
|
2713
|
+
className: mergeClassNames(SplitButton, hasItems ? '' : SplitButtonDisabled),
|
|
2683
2714
|
childCount: 3
|
|
2684
2715
|
}, {
|
|
2685
2716
|
type: Div,
|
|
2686
|
-
className:
|
|
2717
|
+
className: mergeClassNames(SplitButtonContent, hasItems ? '' : SplitButtonContentDisabled),
|
|
2687
2718
|
childCount: 1,
|
|
2688
2719
|
tabIndex: 0
|
|
2689
2720
|
}, text(buttonText), {
|
|
@@ -2692,12 +2723,12 @@ const getSplitButtonVirtualDom = (hasItems, splitButtonEnabled, buttonText) => {
|
|
|
2692
2723
|
childCount: 0
|
|
2693
2724
|
}, {
|
|
2694
2725
|
type: Div,
|
|
2695
|
-
className:
|
|
2726
|
+
className: mergeClassNames(SplitButtonDropDown, hasItems ? '' : SplitButtonDropDownDisabled),
|
|
2696
2727
|
childCount: 1,
|
|
2697
2728
|
tabIndex: 0
|
|
2698
2729
|
}, {
|
|
2699
2730
|
type: Div,
|
|
2700
|
-
className:
|
|
2731
|
+
className: mergeClassNames(MaskIcon, MaskIconChevronDown),
|
|
2701
2732
|
childCount: 0
|
|
2702
2733
|
}];
|
|
2703
2734
|
};
|
|
@@ -2855,14 +2886,16 @@ const saveState = uid => {
|
|
|
2855
2886
|
const {
|
|
2856
2887
|
root,
|
|
2857
2888
|
maxLineY,
|
|
2858
|
-
expandedGroups
|
|
2889
|
+
expandedGroups,
|
|
2890
|
+
inputValue
|
|
2859
2891
|
} = newState;
|
|
2860
2892
|
return {
|
|
2861
2893
|
root,
|
|
2862
2894
|
minLineY: 0,
|
|
2863
2895
|
maxLineY,
|
|
2864
2896
|
deltaY: 0,
|
|
2865
|
-
expandedGroups
|
|
2897
|
+
expandedGroups,
|
|
2898
|
+
inputValue
|
|
2866
2899
|
};
|
|
2867
2900
|
};
|
|
2868
2901
|
|
|
@@ -2881,6 +2914,20 @@ const updateIcons = async state => {
|
|
|
2881
2914
|
};
|
|
2882
2915
|
};
|
|
2883
2916
|
|
|
2917
|
+
const viewAsList = state => {
|
|
2918
|
+
return {
|
|
2919
|
+
...state,
|
|
2920
|
+
viewMode: 1
|
|
2921
|
+
};
|
|
2922
|
+
};
|
|
2923
|
+
|
|
2924
|
+
const viewAsTree = state => {
|
|
2925
|
+
return {
|
|
2926
|
+
...state,
|
|
2927
|
+
viewMode: 2
|
|
2928
|
+
};
|
|
2929
|
+
};
|
|
2930
|
+
|
|
2884
2931
|
const commandMap = {
|
|
2885
2932
|
'Initialize.initialize': initialize,
|
|
2886
2933
|
'SourceControl.create2': create2,
|
|
@@ -2908,7 +2955,9 @@ const commandMap = {
|
|
|
2908
2955
|
'SourceControl.selectIndex': wrapCommand(selectIndex),
|
|
2909
2956
|
'SourceControl.setDeltaY': wrapCommand(setDeltaY),
|
|
2910
2957
|
'SourceControl.terminate': terminate,
|
|
2911
|
-
'SourceControl.updateIcons': wrapCommand(updateIcons)
|
|
2958
|
+
'SourceControl.updateIcons': wrapCommand(updateIcons),
|
|
2959
|
+
'SourceControl.viewAsList': wrapCommand(viewAsList),
|
|
2960
|
+
'SourceControl.viewAsTree': wrapCommand(viewAsTree)
|
|
2912
2961
|
};
|
|
2913
2962
|
|
|
2914
2963
|
const listen = async () => {
|