@lvce-editor/source-control-worker 1.21.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 +88 -38
- 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
|
|
|
@@ -2087,6 +2137,7 @@ const getIndex = (state, eventX, eventY) => {
|
|
|
2087
2137
|
};
|
|
2088
2138
|
|
|
2089
2139
|
const warn = (...args) => {
|
|
2140
|
+
// @ts-ignore
|
|
2090
2141
|
console.warn(...args);
|
|
2091
2142
|
};
|
|
2092
2143
|
|
|
@@ -2200,12 +2251,12 @@ const handleClickDirectoryExpanded = async (state, item) => {
|
|
|
2200
2251
|
};
|
|
2201
2252
|
|
|
2202
2253
|
const readFile = async (uri, encoding = 'utf8') => {
|
|
2203
|
-
const content = await
|
|
2254
|
+
const content = await readFile$1(uri);
|
|
2204
2255
|
return content;
|
|
2205
2256
|
};
|
|
2206
2257
|
|
|
2207
2258
|
const openUri = uri => {
|
|
2208
|
-
return
|
|
2259
|
+
return openUri$1(uri);
|
|
2209
2260
|
};
|
|
2210
2261
|
|
|
2211
2262
|
const openDiffEditor = async (before, afterPath, width) => {
|
|
@@ -2245,7 +2296,7 @@ const selectIndex = async (state, index) => {
|
|
|
2245
2296
|
case File:
|
|
2246
2297
|
return handleClickFile(state, item);
|
|
2247
2298
|
default:
|
|
2248
|
-
|
|
2299
|
+
warn(`unknown item type: ${item.type}`);
|
|
2249
2300
|
return state;
|
|
2250
2301
|
}
|
|
2251
2302
|
};
|
|
@@ -2273,27 +2324,6 @@ const handleFocus = async state => {
|
|
|
2273
2324
|
return state;
|
|
2274
2325
|
};
|
|
2275
2326
|
|
|
2276
|
-
const getTextHeight = async (input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight) => {
|
|
2277
|
-
try {
|
|
2278
|
-
// TODO line height could also be like 1.5
|
|
2279
|
-
const lineHeightPx = `${lineHeight}px`;
|
|
2280
|
-
// @ts-ignore
|
|
2281
|
-
const height = await invoke$2(`MeasureTextHeight.measureTextBlockHeight`, input, fontFamily, fontSize, lineHeightPx, width);
|
|
2282
|
-
return height;
|
|
2283
|
-
} catch {
|
|
2284
|
-
// fallback
|
|
2285
|
-
const lines = input.split('\n');
|
|
2286
|
-
const lineCount = lines.length;
|
|
2287
|
-
const inputHeight = lineCount * lineHeight;
|
|
2288
|
-
return inputHeight;
|
|
2289
|
-
}
|
|
2290
|
-
};
|
|
2291
|
-
|
|
2292
|
-
const getInputHeight = async (input, width, fontFamily, fontWeight, fontSize, letterSpacing, lineHeight) => {
|
|
2293
|
-
const height = await getTextHeight(input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight);
|
|
2294
|
-
return height;
|
|
2295
|
-
};
|
|
2296
|
-
|
|
2297
2327
|
const handleInput = async (state, value, inputSource = User) => {
|
|
2298
2328
|
const {
|
|
2299
2329
|
width,
|
|
@@ -2529,12 +2559,13 @@ const getButtonsVirtualDom = buttons => {
|
|
|
2529
2559
|
}, ...buttons.flatMap(getButtonVirtualDom)];
|
|
2530
2560
|
};
|
|
2531
2561
|
|
|
2562
|
+
const classNameDefault = mergeClassNames(Label, Grow);
|
|
2563
|
+
const classNameStrikeThrough = mergeClassNames(classNameDefault, StrikeThrough);
|
|
2532
2564
|
const getLabelClassName = decorationStrikeThrough => {
|
|
2533
|
-
let className = mergeClassNames(Label, Grow);
|
|
2534
2565
|
if (decorationStrikeThrough) {
|
|
2535
|
-
|
|
2566
|
+
return classNameStrikeThrough;
|
|
2536
2567
|
}
|
|
2537
|
-
return
|
|
2568
|
+
return classNameDefault;
|
|
2538
2569
|
};
|
|
2539
2570
|
|
|
2540
2571
|
const PaddingLeft = '1rem';
|
|
@@ -2563,6 +2594,7 @@ const createItemDirectory = item => {
|
|
|
2563
2594
|
ariaSetSize: setSize,
|
|
2564
2595
|
childCount: 3 + (hasButtons ? 1 : 0),
|
|
2565
2596
|
paddingLeft: PaddingLeft,
|
|
2597
|
+
// TODO classname for indent / padding
|
|
2566
2598
|
paddingRight: PaddingRight
|
|
2567
2599
|
}, {
|
|
2568
2600
|
type: Div,
|
|
@@ -2678,11 +2710,11 @@ const getSplitButtonVirtualDom = (hasItems, splitButtonEnabled, buttonText) => {
|
|
|
2678
2710
|
}
|
|
2679
2711
|
return [{
|
|
2680
2712
|
type: Div,
|
|
2681
|
-
className:
|
|
2713
|
+
className: mergeClassNames(SplitButton, hasItems ? '' : SplitButtonDisabled),
|
|
2682
2714
|
childCount: 3
|
|
2683
2715
|
}, {
|
|
2684
2716
|
type: Div,
|
|
2685
|
-
className:
|
|
2717
|
+
className: mergeClassNames(SplitButtonContent, hasItems ? '' : SplitButtonContentDisabled),
|
|
2686
2718
|
childCount: 1,
|
|
2687
2719
|
tabIndex: 0
|
|
2688
2720
|
}, text(buttonText), {
|
|
@@ -2691,12 +2723,12 @@ const getSplitButtonVirtualDom = (hasItems, splitButtonEnabled, buttonText) => {
|
|
|
2691
2723
|
childCount: 0
|
|
2692
2724
|
}, {
|
|
2693
2725
|
type: Div,
|
|
2694
|
-
className:
|
|
2726
|
+
className: mergeClassNames(SplitButtonDropDown, hasItems ? '' : SplitButtonDropDownDisabled),
|
|
2695
2727
|
childCount: 1,
|
|
2696
2728
|
tabIndex: 0
|
|
2697
2729
|
}, {
|
|
2698
2730
|
type: Div,
|
|
2699
|
-
className:
|
|
2731
|
+
className: mergeClassNames(MaskIcon, MaskIconChevronDown),
|
|
2700
2732
|
childCount: 0
|
|
2701
2733
|
}];
|
|
2702
2734
|
};
|
|
@@ -2854,14 +2886,16 @@ const saveState = uid => {
|
|
|
2854
2886
|
const {
|
|
2855
2887
|
root,
|
|
2856
2888
|
maxLineY,
|
|
2857
|
-
expandedGroups
|
|
2889
|
+
expandedGroups,
|
|
2890
|
+
inputValue
|
|
2858
2891
|
} = newState;
|
|
2859
2892
|
return {
|
|
2860
2893
|
root,
|
|
2861
2894
|
minLineY: 0,
|
|
2862
2895
|
maxLineY,
|
|
2863
2896
|
deltaY: 0,
|
|
2864
|
-
expandedGroups
|
|
2897
|
+
expandedGroups,
|
|
2898
|
+
inputValue
|
|
2865
2899
|
};
|
|
2866
2900
|
};
|
|
2867
2901
|
|
|
@@ -2880,6 +2914,20 @@ const updateIcons = async state => {
|
|
|
2880
2914
|
};
|
|
2881
2915
|
};
|
|
2882
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
|
+
|
|
2883
2931
|
const commandMap = {
|
|
2884
2932
|
'Initialize.initialize': initialize,
|
|
2885
2933
|
'SourceControl.create2': create2,
|
|
@@ -2907,7 +2955,9 @@ const commandMap = {
|
|
|
2907
2955
|
'SourceControl.selectIndex': wrapCommand(selectIndex),
|
|
2908
2956
|
'SourceControl.setDeltaY': wrapCommand(setDeltaY),
|
|
2909
2957
|
'SourceControl.terminate': terminate,
|
|
2910
|
-
'SourceControl.updateIcons': wrapCommand(updateIcons)
|
|
2958
|
+
'SourceControl.updateIcons': wrapCommand(updateIcons),
|
|
2959
|
+
'SourceControl.viewAsList': wrapCommand(viewAsList),
|
|
2960
|
+
'SourceControl.viewAsTree': wrapCommand(viewAsTree)
|
|
2911
2961
|
};
|
|
2912
2962
|
|
|
2913
2963
|
const listen = async () => {
|