@lvce-editor/main-area-worker 9.37.2 → 9.37.4
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/mainAreaWorkerMain.js +116 -85
- package/package.json +1 -1
|
@@ -1468,8 +1468,12 @@ const SetPatches = 'Viewlet.setPatches';
|
|
|
1468
1468
|
const FocusEditorText = 12;
|
|
1469
1469
|
|
|
1470
1470
|
const {
|
|
1471
|
+
invoke: invoke$3,
|
|
1471
1472
|
set: set$4
|
|
1472
1473
|
} = create$4(ClipBoardWorker);
|
|
1474
|
+
const writeText = async text => {
|
|
1475
|
+
return invoke$3('ClipBoard.writeText', text);
|
|
1476
|
+
};
|
|
1473
1477
|
|
|
1474
1478
|
const {
|
|
1475
1479
|
invoke: invoke$2,
|
|
@@ -1578,9 +1582,6 @@ const confirm$1 = async (message, options) => {
|
|
|
1578
1582
|
const result = await invoke('ConfirmPrompt.prompt', message, options);
|
|
1579
1583
|
return result;
|
|
1580
1584
|
};
|
|
1581
|
-
const writeClipBoardText = async text => {
|
|
1582
|
-
await invoke('ClipBoard.writeText', /* text */text);
|
|
1583
|
-
};
|
|
1584
1585
|
|
|
1585
1586
|
const toCommandId = key => {
|
|
1586
1587
|
const dotIndex = key.indexOf('.');
|
|
@@ -1873,7 +1874,7 @@ const withGroupsAndActiveGroup = (state, groups, activeGroupId) => {
|
|
|
1873
1874
|
};
|
|
1874
1875
|
|
|
1875
1876
|
const withEmptyGroups = state => {
|
|
1876
|
-
return withGroupsAndActiveGroup(state, [],
|
|
1877
|
+
return withGroupsAndActiveGroup(state, [], -1);
|
|
1877
1878
|
};
|
|
1878
1879
|
|
|
1879
1880
|
const withGroups = (state, groups) => {
|
|
@@ -1924,7 +1925,7 @@ const closeTab = (state, groupId, tabId) => {
|
|
|
1924
1925
|
if (newTabs.length > 0) {
|
|
1925
1926
|
newActiveTabId = newTabs[Math.min(tabIndex, newTabs.length - 1)].id;
|
|
1926
1927
|
} else {
|
|
1927
|
-
newActiveTabId =
|
|
1928
|
+
newActiveTabId = -1;
|
|
1928
1929
|
}
|
|
1929
1930
|
}
|
|
1930
1931
|
return {
|
|
@@ -1945,7 +1946,7 @@ const closeTab = (state, groupId, tabId) => {
|
|
|
1945
1946
|
// If there are remaining groups, redistribute sizes
|
|
1946
1947
|
if (remainingGroups.length > 0) {
|
|
1947
1948
|
const redistributedGroups = redistributeSizesWithRounding(remainingGroups);
|
|
1948
|
-
const newActiveGroupId = activeGroupId === groupId ? remainingGroups[0]?.id : activeGroupId;
|
|
1949
|
+
const newActiveGroupId = activeGroupId === groupId ? remainingGroups[0]?.id ?? -1 : activeGroupId;
|
|
1949
1950
|
return withGroupsAndActiveGroup(stateWithClosedTab, redistributedGroups, newActiveGroupId);
|
|
1950
1951
|
}
|
|
1951
1952
|
|
|
@@ -1969,8 +1970,12 @@ const getTitle$1 = async editorUid => {
|
|
|
1969
1970
|
return undefined;
|
|
1970
1971
|
}
|
|
1971
1972
|
};
|
|
1972
|
-
const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri) => {
|
|
1973
|
-
|
|
1973
|
+
const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri, args) => {
|
|
1974
|
+
if (args === undefined) {
|
|
1975
|
+
await invoke('Layout.createViewlet', viewletModuleId, editorUid, tabId, bounds, uri);
|
|
1976
|
+
} else {
|
|
1977
|
+
await invoke('Layout.createViewlet', viewletModuleId, editorUid, tabId, bounds, uri, args);
|
|
1978
|
+
}
|
|
1974
1979
|
return getTitle$1(editorUid);
|
|
1975
1980
|
};
|
|
1976
1981
|
|
|
@@ -2460,6 +2465,9 @@ const closeTabAndSave = async (state, groupId, tabId) => {
|
|
|
2460
2465
|
return closeTabWithViewlet(state, groupId, tabId);
|
|
2461
2466
|
};
|
|
2462
2467
|
|
|
2468
|
+
const isFocused$1 = group => {
|
|
2469
|
+
return group.focused;
|
|
2470
|
+
};
|
|
2463
2471
|
const getFocusedGroup = state => {
|
|
2464
2472
|
const {
|
|
2465
2473
|
layout
|
|
@@ -2467,7 +2475,7 @@ const getFocusedGroup = state => {
|
|
|
2467
2475
|
const {
|
|
2468
2476
|
groups
|
|
2469
2477
|
} = layout;
|
|
2470
|
-
return groups.find(
|
|
2478
|
+
return groups.find(isFocused$1);
|
|
2471
2479
|
};
|
|
2472
2480
|
|
|
2473
2481
|
const closeActiveEditor = async state => {
|
|
@@ -2478,7 +2486,7 @@ const closeActiveEditor = async state => {
|
|
|
2478
2486
|
const {
|
|
2479
2487
|
activeTabId
|
|
2480
2488
|
} = focusedGroup;
|
|
2481
|
-
if (activeTabId ===
|
|
2489
|
+
if (activeTabId === -1) {
|
|
2482
2490
|
return state;
|
|
2483
2491
|
}
|
|
2484
2492
|
return closeTabAndSave(state, focusedGroup.id, activeTabId);
|
|
@@ -2563,7 +2571,7 @@ const closeFocusedTab = async state => {
|
|
|
2563
2571
|
const {
|
|
2564
2572
|
activeTabId
|
|
2565
2573
|
} = focusedGroup;
|
|
2566
|
-
if (activeTabId ===
|
|
2574
|
+
if (activeTabId === -1) {
|
|
2567
2575
|
return state;
|
|
2568
2576
|
}
|
|
2569
2577
|
return closeTabAndSave(state, focusedGroup.id, activeTabId);
|
|
@@ -2578,7 +2586,7 @@ const closeOtherTabs = (state, groupId) => {
|
|
|
2578
2586
|
groups
|
|
2579
2587
|
} = layout;
|
|
2580
2588
|
const targetGroupId = groupId ?? activeGroupId;
|
|
2581
|
-
if (targetGroupId ===
|
|
2589
|
+
if (targetGroupId === -1) {
|
|
2582
2590
|
return state;
|
|
2583
2591
|
}
|
|
2584
2592
|
const group = groups.find(g => g.id === targetGroupId);
|
|
@@ -2588,7 +2596,7 @@ const closeOtherTabs = (state, groupId) => {
|
|
|
2588
2596
|
const {
|
|
2589
2597
|
activeTabId
|
|
2590
2598
|
} = group;
|
|
2591
|
-
if (activeTabId ===
|
|
2599
|
+
if (activeTabId === -1) {
|
|
2592
2600
|
return state;
|
|
2593
2601
|
}
|
|
2594
2602
|
const closedTabs = group.tabs.map((tab, tabIndex) => ({
|
|
@@ -2619,15 +2627,15 @@ const closeOtherTabs = (state, groupId) => {
|
|
|
2619
2627
|
};
|
|
2620
2628
|
|
|
2621
2629
|
const getNextActiveTabId = (tabs, newTabs, activeTabId) => {
|
|
2622
|
-
if (activeTabId ===
|
|
2623
|
-
return
|
|
2630
|
+
if (activeTabId === -1) {
|
|
2631
|
+
return -1;
|
|
2624
2632
|
}
|
|
2625
2633
|
if (newTabs.some(tab => tab.id === activeTabId)) {
|
|
2626
2634
|
return activeTabId;
|
|
2627
2635
|
}
|
|
2628
2636
|
const activeTabIndex = tabs.findIndex(tab => tab.id === activeTabId);
|
|
2629
2637
|
if (activeTabIndex === -1 || newTabs.length === 0) {
|
|
2630
|
-
return
|
|
2638
|
+
return -1;
|
|
2631
2639
|
}
|
|
2632
2640
|
return newTabs[Math.min(activeTabIndex, newTabs.length - 1)].id;
|
|
2633
2641
|
};
|
|
@@ -2720,7 +2728,7 @@ const closeTabsRight = (state, groupId) => {
|
|
|
2720
2728
|
activeTabId,
|
|
2721
2729
|
tabs
|
|
2722
2730
|
} = group;
|
|
2723
|
-
if (activeTabId ===
|
|
2731
|
+
if (activeTabId === -1) {
|
|
2724
2732
|
return state;
|
|
2725
2733
|
}
|
|
2726
2734
|
const activeTabIndex = tabs.findIndex(tab => tab.id === activeTabId);
|
|
@@ -2768,14 +2776,14 @@ const copyIntoNewWindow$1 = async state => {
|
|
|
2768
2776
|
const {
|
|
2769
2777
|
activeGroupId
|
|
2770
2778
|
} = layout;
|
|
2771
|
-
const group = findGroupById(state, activeGroupId
|
|
2779
|
+
const group = findGroupById(state, activeGroupId);
|
|
2772
2780
|
if (!group) {
|
|
2773
2781
|
return state;
|
|
2774
2782
|
}
|
|
2775
2783
|
const {
|
|
2776
2784
|
activeTabId
|
|
2777
2785
|
} = group;
|
|
2778
|
-
if (activeTabId ===
|
|
2786
|
+
if (activeTabId === -1) {
|
|
2779
2787
|
return state;
|
|
2780
2788
|
}
|
|
2781
2789
|
const tab = group.tabs.find(tab => tab.id === activeTabId);
|
|
@@ -2788,15 +2796,14 @@ const copyIntoNewWindow$1 = async state => {
|
|
|
2788
2796
|
|
|
2789
2797
|
const copyPath$1 = async (state, path) => {
|
|
2790
2798
|
string(path);
|
|
2791
|
-
await
|
|
2799
|
+
await writeText(path);
|
|
2792
2800
|
return state;
|
|
2793
2801
|
};
|
|
2794
2802
|
|
|
2795
2803
|
const copyRelativePath$1 = async (state, path) => {
|
|
2796
2804
|
string(path);
|
|
2797
|
-
// TODO use clipboard worker
|
|
2798
2805
|
const relativePath = await invoke('Workspace.pathBaseName', path);
|
|
2799
|
-
await
|
|
2806
|
+
await writeText(relativePath);
|
|
2800
2807
|
return state;
|
|
2801
2808
|
};
|
|
2802
2809
|
|
|
@@ -2828,7 +2835,7 @@ const create$1 = (uid, uri, x, y, width, height, platform, assetDir, tabHeight =
|
|
|
2828
2835
|
iframes: [],
|
|
2829
2836
|
initial: true,
|
|
2830
2837
|
layout: {
|
|
2831
|
-
activeGroupId:
|
|
2838
|
+
activeGroupId: -1,
|
|
2832
2839
|
direction: Horizontal,
|
|
2833
2840
|
groups: []
|
|
2834
2841
|
},
|
|
@@ -3656,7 +3663,9 @@ const restoreClosedTab = async state => {
|
|
|
3656
3663
|
if (!restored) {
|
|
3657
3664
|
return state;
|
|
3658
3665
|
}
|
|
3659
|
-
|
|
3666
|
+
const newState = await selectTab(restored.newState, restored.groupIndex, restored.tabIndex);
|
|
3667
|
+
set(state.uid, state, newState);
|
|
3668
|
+
return newState;
|
|
3660
3669
|
};
|
|
3661
3670
|
|
|
3662
3671
|
const focusEditorGroup = (state, groupId) => {
|
|
@@ -3924,7 +3933,7 @@ const ensureActiveGroup = (state, uri, preview = false, title = getLabel(uri), e
|
|
|
3924
3933
|
activeGroupId,
|
|
3925
3934
|
groups
|
|
3926
3935
|
} = layout;
|
|
3927
|
-
const activeGroup = activeGroupId ===
|
|
3936
|
+
const activeGroup = activeGroupId === -1 ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
|
|
3928
3937
|
|
|
3929
3938
|
// Generate a request ID for content loading
|
|
3930
3939
|
const requestId = getNextRequestId();
|
|
@@ -4214,7 +4223,7 @@ const getActivePreviewEditorUid = state => {
|
|
|
4214
4223
|
activeGroupId,
|
|
4215
4224
|
groups
|
|
4216
4225
|
} = layout;
|
|
4217
|
-
const activeGroup = activeGroupId ===
|
|
4226
|
+
const activeGroup = activeGroupId === -1 ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
|
|
4218
4227
|
const activeTab = activeGroup?.tabs.find(tab => tab.id === activeGroup.activeTabId);
|
|
4219
4228
|
return activeTab?.isPreview ? activeTab.editorUid : -1;
|
|
4220
4229
|
};
|
|
@@ -4290,7 +4299,7 @@ const openInputWithContext = async (context, options) => {
|
|
|
4290
4299
|
if (editorUid === -1) {
|
|
4291
4300
|
throw new Error('invalid editorUid');
|
|
4292
4301
|
}
|
|
4293
|
-
const renderedTitle = await createViewlet(viewletModuleId, editorUid, tabId, bounds, uri);
|
|
4302
|
+
const renderedTitle = await createViewlet(viewletModuleId, editorUid, tabId, bounds, uri, options.args);
|
|
4294
4303
|
const latestState = context.getState();
|
|
4295
4304
|
const readyState = handleViewletReady(latestState, editorUid, renderedTitle);
|
|
4296
4305
|
await context.updateState(() => readyState);
|
|
@@ -4334,20 +4343,31 @@ const getOptionUriOptions = options => {
|
|
|
4334
4343
|
return options.uri;
|
|
4335
4344
|
};
|
|
4336
4345
|
|
|
4337
|
-
const
|
|
4346
|
+
const getViewletContext = (options, viewletContext) => {
|
|
4347
|
+
if (viewletContext !== undefined || typeof options === 'string') {
|
|
4348
|
+
return viewletContext;
|
|
4349
|
+
}
|
|
4350
|
+
const context = Object.fromEntries(Object.entries(options).filter(([key]) => key !== 'focus' && key !== 'preview' && key !== 'uri'));
|
|
4351
|
+
return Object.keys(context).length === 0 ? undefined : context;
|
|
4352
|
+
};
|
|
4353
|
+
const getOpenInputOptions = (options, focus = true, viewletContext) => {
|
|
4338
4354
|
const uri = getOptionUriOptions(options);
|
|
4339
4355
|
const preview = typeof options === 'string' ? false : options.preview ?? false;
|
|
4356
|
+
const context = getViewletContext(options, viewletContext);
|
|
4340
4357
|
return {
|
|
4358
|
+
...(context !== undefined && {
|
|
4359
|
+
args: [context]
|
|
4360
|
+
}),
|
|
4341
4361
|
editorInput: getNormalizedOpenEditorInput(uri),
|
|
4342
|
-
focus: typeof options === 'string' ?
|
|
4362
|
+
focus: typeof options === 'string' ? focus : options.focus,
|
|
4343
4363
|
preview
|
|
4344
4364
|
};
|
|
4345
4365
|
};
|
|
4346
|
-
const openUri = async (state, options) => {
|
|
4347
|
-
return openInput(state, getOpenInputOptions(options));
|
|
4366
|
+
const openUri = async (state, options, focus = true, viewletContext) => {
|
|
4367
|
+
return openInput(state, getOpenInputOptions(options, focus, viewletContext));
|
|
4348
4368
|
};
|
|
4349
|
-
const openUriWithContext = async (context, options) => {
|
|
4350
|
-
await openInputWithContext(context, getOpenInputOptions(options));
|
|
4369
|
+
const openUriWithContext = async (context, options, focus = true, viewletContext) => {
|
|
4370
|
+
await openInputWithContext(context, getOpenInputOptions(options, focus, viewletContext));
|
|
4351
4371
|
};
|
|
4352
4372
|
|
|
4353
4373
|
const retryOpen = async state => {
|
|
@@ -4550,7 +4570,7 @@ const splitEditorGroup$1 = (state, groupId, direction) => {
|
|
|
4550
4570
|
const newGroupId = create$2();
|
|
4551
4571
|
const splitLayoutDirection = getSplitLayoutDirection(direction);
|
|
4552
4572
|
const baseNewGroup = {
|
|
4553
|
-
activeTabId:
|
|
4573
|
+
activeTabId: -1,
|
|
4554
4574
|
direction: sourceGroup.direction,
|
|
4555
4575
|
focused: true,
|
|
4556
4576
|
id: newGroupId,
|
|
@@ -4589,7 +4609,7 @@ const handleClickAction = async (state, action, rawGroupId) => {
|
|
|
4589
4609
|
if (action === RestoreClosedTab) {
|
|
4590
4610
|
return restoreClosedTab(state);
|
|
4591
4611
|
}
|
|
4592
|
-
if (activeGroupId ===
|
|
4612
|
+
if (activeGroupId === -1) {
|
|
4593
4613
|
return state;
|
|
4594
4614
|
}
|
|
4595
4615
|
const activeGroup = getActiveGroup(groups, activeGroupId);
|
|
@@ -4852,36 +4872,10 @@ const parseUriList = value => {
|
|
|
4852
4872
|
return value.split(lineSeparatorRegex).map(uri => uri.trim()).filter(uri => uri && !uri.startsWith('#'));
|
|
4853
4873
|
};
|
|
4854
4874
|
|
|
4855
|
-
const windowsDriveLetterRegex = /^[a-zA-Z]:\\/;
|
|
4856
|
-
const encodeFilePath = path => {
|
|
4857
|
-
return encodeURI(path).replaceAll('#', '%23').replaceAll('?', '%3F');
|
|
4858
|
-
};
|
|
4859
|
-
const toFileUri$1 = path => {
|
|
4860
|
-
if (path.startsWith('file://')) {
|
|
4861
|
-
return path;
|
|
4862
|
-
}
|
|
4863
|
-
if (windowsDriveLetterRegex.test(path)) {
|
|
4864
|
-
const normalizedPath = path.replaceAll('\\', '/');
|
|
4865
|
-
return `file:///${encodeFilePath(normalizedPath)}`;
|
|
4866
|
-
}
|
|
4867
|
-
return `file://${encodeFilePath(path)}`;
|
|
4868
|
-
};
|
|
4869
|
-
|
|
4870
4875
|
const suffixByHandleKind = {
|
|
4871
4876
|
directory: '/',
|
|
4872
4877
|
file: ''
|
|
4873
4878
|
};
|
|
4874
|
-
const getDroppedElectronUris = async (itemIds, files) => {
|
|
4875
|
-
if (itemIds.length > 0) {
|
|
4876
|
-
await getFileHandles(itemIds);
|
|
4877
|
-
}
|
|
4878
|
-
const uris = [];
|
|
4879
|
-
for (const file of files) {
|
|
4880
|
-
const path = await invoke('FileSystemHandle.getFilePathElectron', file);
|
|
4881
|
-
uris.push(toFileUri$1(path));
|
|
4882
|
-
}
|
|
4883
|
-
return uris;
|
|
4884
|
-
};
|
|
4885
4879
|
const getDroppedBrowserUris = async itemIds => {
|
|
4886
4880
|
if (itemIds.length === 0) {
|
|
4887
4881
|
return [];
|
|
@@ -4922,6 +4916,34 @@ const getDroppedBrowserUris = async itemIds => {
|
|
|
4922
4916
|
}
|
|
4923
4917
|
return uris;
|
|
4924
4918
|
};
|
|
4919
|
+
|
|
4920
|
+
const windowsDriveLetterRegex = /^[a-zA-Z]:\\/;
|
|
4921
|
+
const encodeFilePath = path => {
|
|
4922
|
+
return encodeURI(path).replaceAll('#', '%23').replaceAll('?', '%3F');
|
|
4923
|
+
};
|
|
4924
|
+
const toFileUri$1 = path => {
|
|
4925
|
+
if (path.startsWith('file://')) {
|
|
4926
|
+
return path;
|
|
4927
|
+
}
|
|
4928
|
+
if (windowsDriveLetterRegex.test(path)) {
|
|
4929
|
+
const normalizedPath = path.replaceAll('\\', '/');
|
|
4930
|
+
return `file:///${encodeFilePath(normalizedPath)}`;
|
|
4931
|
+
}
|
|
4932
|
+
return `file://${encodeFilePath(path)}`;
|
|
4933
|
+
};
|
|
4934
|
+
|
|
4935
|
+
const getDroppedElectronUris = async (itemIds, files) => {
|
|
4936
|
+
if (itemIds.length > 0) {
|
|
4937
|
+
await getFileHandles(itemIds);
|
|
4938
|
+
}
|
|
4939
|
+
const uris = [];
|
|
4940
|
+
for (const file of files) {
|
|
4941
|
+
const path = await invoke('FileSystemHandle.getFilePathElectron', file);
|
|
4942
|
+
uris.push(toFileUri$1(path));
|
|
4943
|
+
}
|
|
4944
|
+
return uris;
|
|
4945
|
+
};
|
|
4946
|
+
|
|
4925
4947
|
const getDroppedUris = async (itemIds, files = [], platform = Web) => {
|
|
4926
4948
|
if (platform === Electron && files.length > 0) {
|
|
4927
4949
|
return getDroppedElectronUris(itemIds, files);
|
|
@@ -5004,7 +5026,7 @@ const newFile = async state => {
|
|
|
5004
5026
|
} = layout;
|
|
5005
5027
|
|
|
5006
5028
|
// Find the active group
|
|
5007
|
-
const activeGroup = activeGroupId ===
|
|
5029
|
+
const activeGroup = activeGroupId === -1 ? groups.find(group => group.focused) : groups.find(group => group.id === activeGroupId);
|
|
5008
5030
|
|
|
5009
5031
|
// Prepare initial state
|
|
5010
5032
|
let newState = state;
|
|
@@ -5029,7 +5051,7 @@ const newFile = async state => {
|
|
|
5029
5051
|
if (group.id === targetGroupId) {
|
|
5030
5052
|
return {
|
|
5031
5053
|
...group,
|
|
5032
|
-
activeTabId:
|
|
5054
|
+
activeTabId: -1,
|
|
5033
5055
|
tabs: []
|
|
5034
5056
|
};
|
|
5035
5057
|
}
|
|
@@ -5638,7 +5660,7 @@ const isValidTab = tab => {
|
|
|
5638
5660
|
};
|
|
5639
5661
|
|
|
5640
5662
|
const isValidEditorGroup = group => {
|
|
5641
|
-
return group && typeof group.id === 'number' && Array.isArray(group.tabs) && group.tabs.every(isValidTab) &&
|
|
5663
|
+
return group && typeof group.id === 'number' && Array.isArray(group.tabs) && group.tabs.every(isValidTab) && typeof group.activeTabId === 'number' && isLayoutDirection(group.direction) && typeof group.focused === 'boolean' && (group.segmentId === undefined || typeof group.segmentId === 'number') && typeof group.size === 'number' && group.size > 0 && typeof group.isEmpty === 'boolean';
|
|
5642
5664
|
};
|
|
5643
5665
|
|
|
5644
5666
|
const isValidMainAreaLayout = layout => {
|
|
@@ -5646,7 +5668,7 @@ const isValidMainAreaLayout = layout => {
|
|
|
5646
5668
|
return false;
|
|
5647
5669
|
}
|
|
5648
5670
|
const layoutObj = layout;
|
|
5649
|
-
if (
|
|
5671
|
+
if (typeof layoutObj.activeGroupId !== 'number') {
|
|
5650
5672
|
return false;
|
|
5651
5673
|
}
|
|
5652
5674
|
if (!isLayoutDirection(layoutObj.direction)) {
|
|
@@ -5707,11 +5729,13 @@ const tryRestoreLayout = savedState => {
|
|
|
5707
5729
|
// Mark all restored tabs as not dirty
|
|
5708
5730
|
const normalizedLayout = {
|
|
5709
5731
|
...rawLayout,
|
|
5732
|
+
activeGroupId: rawLayout.activeGroupId === undefined ? -1 : rawLayout.activeGroupId,
|
|
5710
5733
|
direction: layoutDirection,
|
|
5711
5734
|
groups: rawLayout.groups.map(group => {
|
|
5712
5735
|
const groupDirection = normalizeGroupDirection(group, layoutDirection);
|
|
5713
5736
|
return {
|
|
5714
5737
|
...group,
|
|
5738
|
+
activeTabId: group?.activeTabId === undefined ? -1 : group.activeTabId,
|
|
5715
5739
|
direction: groupDirection,
|
|
5716
5740
|
tabs: Array.isArray(group?.tabs) ? group.tabs.map(normalizeRestoredTab) : []
|
|
5717
5741
|
};
|
|
@@ -5876,7 +5900,7 @@ const loadContent$1 = async (state, savedState) => {
|
|
|
5876
5900
|
...stateWithHomeDir,
|
|
5877
5901
|
initial: false,
|
|
5878
5902
|
layout: {
|
|
5879
|
-
activeGroupId:
|
|
5903
|
+
activeGroupId: -1,
|
|
5880
5904
|
direction: Horizontal,
|
|
5881
5905
|
groups: []
|
|
5882
5906
|
}
|
|
@@ -5884,7 +5908,11 @@ const loadContent$1 = async (state, savedState) => {
|
|
|
5884
5908
|
};
|
|
5885
5909
|
|
|
5886
5910
|
const handleWorkspaceChange = async (state, _workspacePath, savedState) => {
|
|
5887
|
-
|
|
5911
|
+
const newState = await loadContent$1(state, savedState);
|
|
5912
|
+
return {
|
|
5913
|
+
...newState,
|
|
5914
|
+
closedTabs: []
|
|
5915
|
+
};
|
|
5888
5916
|
};
|
|
5889
5917
|
|
|
5890
5918
|
const handleWorkspaceRefresh = async (state, refresh = {}) => {
|
|
@@ -6280,14 +6308,14 @@ const moveIntoNewWindow = async state => {
|
|
|
6280
6308
|
const {
|
|
6281
6309
|
activeGroupId
|
|
6282
6310
|
} = layout;
|
|
6283
|
-
const group = findGroupById(state, activeGroupId
|
|
6311
|
+
const group = findGroupById(state, activeGroupId);
|
|
6284
6312
|
if (!group) {
|
|
6285
6313
|
return state;
|
|
6286
6314
|
}
|
|
6287
6315
|
const {
|
|
6288
6316
|
activeTabId
|
|
6289
6317
|
} = group;
|
|
6290
|
-
if (activeTabId ===
|
|
6318
|
+
if (activeTabId === -1) {
|
|
6291
6319
|
return state;
|
|
6292
6320
|
}
|
|
6293
6321
|
const tab = group.tabs.find(tab => tab.id === activeTabId);
|
|
@@ -6431,16 +6459,19 @@ const getSashCss = (layout, width = 0) => {
|
|
|
6431
6459
|
return getProtoSashCss(layout, width).map(renderSashCss);
|
|
6432
6460
|
};
|
|
6433
6461
|
|
|
6462
|
+
const getSashCornerCss = (left, top) => {
|
|
6463
|
+
return `.SashCorner {
|
|
6464
|
+
left: ${left}%;
|
|
6465
|
+
top: ${top}%;
|
|
6466
|
+
}`;
|
|
6467
|
+
};
|
|
6434
6468
|
const getCss = (layout, width = 0, dragOverlay) => {
|
|
6435
6469
|
const rules = [];
|
|
6436
6470
|
if (layout) {
|
|
6437
6471
|
rules.push(...getEditorGroupCss(layout), ...getDragOverlayCss(dragOverlay), ...getSashCss(layout, width));
|
|
6438
6472
|
const sashCorner = getSashCorner(layout);
|
|
6439
6473
|
if (sashCorner) {
|
|
6440
|
-
rules.push(
|
|
6441
|
-
left: ${sashCorner.leftOffset}%;
|
|
6442
|
-
top: ${sashCorner.topOffset}%;
|
|
6443
|
-
}`);
|
|
6474
|
+
rules.push(getSashCornerCss(sashCorner.leftOffset, sashCorner.topOffset));
|
|
6444
6475
|
}
|
|
6445
6476
|
}
|
|
6446
6477
|
const css = rules.join('\n');
|
|
@@ -7588,7 +7619,7 @@ const getSavedTab = tab => {
|
|
|
7588
7619
|
const getFilteredGroups = groups => {
|
|
7589
7620
|
return groups.map(group => {
|
|
7590
7621
|
const tabs = group.tabs.filter(tab => !tab.uri?.startsWith('untitled://')).map(getSavedTab);
|
|
7591
|
-
const activeTabId = tabs.some(tab => tab.id === group.activeTabId) ? group.activeTabId : tabs[0]?.id;
|
|
7622
|
+
const activeTabId = tabs.some(tab => tab.id === group.activeTabId) ? group.activeTabId : tabs[0]?.id ?? -1;
|
|
7592
7623
|
return {
|
|
7593
7624
|
...group,
|
|
7594
7625
|
activeTabId,
|
|
@@ -7611,7 +7642,7 @@ const saveState = state => {
|
|
|
7611
7642
|
const {
|
|
7612
7643
|
activeGroupId: originalActiveGroupId
|
|
7613
7644
|
} = layout;
|
|
7614
|
-
const activeGroupId = originalActiveGroupId !==
|
|
7645
|
+
const activeGroupId = originalActiveGroupId !== -1 && filteredGroups.every(g => g.id !== originalActiveGroupId) ? -1 : originalActiveGroupId;
|
|
7615
7646
|
return {
|
|
7616
7647
|
layout: {
|
|
7617
7648
|
...layout,
|
|
@@ -7626,7 +7657,7 @@ const flipDirection = direction => {
|
|
|
7626
7657
|
};
|
|
7627
7658
|
const createEmptyGroup = direction => {
|
|
7628
7659
|
return {
|
|
7629
|
-
activeTabId:
|
|
7660
|
+
activeTabId: -1,
|
|
7630
7661
|
direction,
|
|
7631
7662
|
focused: false,
|
|
7632
7663
|
id: create$2(),
|
|
@@ -7649,8 +7680,8 @@ const getActiveGroupIndex = (groups, activeGroupId) => {
|
|
|
7649
7680
|
const mergeGroups = (target, groups, activeGroupId) => {
|
|
7650
7681
|
const allGroups = [target, ...groups];
|
|
7651
7682
|
const tabs = allGroups.flatMap(group => group.tabs);
|
|
7652
|
-
const activeGroup = allGroups.find(group => group.id === activeGroupId) ?? groups.findLast(group => group.activeTabId !==
|
|
7653
|
-
const activeTabId = activeGroup.activeTabId
|
|
7683
|
+
const activeGroup = allGroups.find(group => group.id === activeGroupId) ?? groups.findLast(group => group.activeTabId !== -1) ?? target;
|
|
7684
|
+
const activeTabId = activeGroup.activeTabId === -1 ? tabs[0]?.id ?? -1 : activeGroup.activeTabId;
|
|
7654
7685
|
return {
|
|
7655
7686
|
...target,
|
|
7656
7687
|
activeTabId,
|
|
@@ -7705,7 +7736,7 @@ const setEditorLayout = (state, direction, slots) => {
|
|
|
7705
7736
|
return {
|
|
7706
7737
|
...state,
|
|
7707
7738
|
layout: {
|
|
7708
|
-
activeGroupId: nextGroups[activeIndex]?.id,
|
|
7739
|
+
activeGroupId: nextGroups[activeIndex]?.id ?? -1,
|
|
7709
7740
|
direction,
|
|
7710
7741
|
groups: nextGroups
|
|
7711
7742
|
}
|
|
@@ -7845,7 +7876,7 @@ const splitDown = (state, groupId) => {
|
|
|
7845
7876
|
if (groups.length === 0) {
|
|
7846
7877
|
const initialGroupId = create$2();
|
|
7847
7878
|
const initialGroup = {
|
|
7848
|
-
activeTabId:
|
|
7879
|
+
activeTabId: -1,
|
|
7849
7880
|
direction,
|
|
7850
7881
|
focused: true,
|
|
7851
7882
|
id: initialGroupId,
|
|
@@ -7882,7 +7913,7 @@ const splitLeft = (state, groupId) => {
|
|
|
7882
7913
|
if (groups.length === 0) {
|
|
7883
7914
|
const initialGroupId = create$2();
|
|
7884
7915
|
const initialGroup = {
|
|
7885
|
-
activeTabId:
|
|
7916
|
+
activeTabId: -1,
|
|
7886
7917
|
direction,
|
|
7887
7918
|
focused: true,
|
|
7888
7919
|
id: initialGroupId,
|
|
@@ -7900,7 +7931,7 @@ const splitLeft = (state, groupId) => {
|
|
|
7900
7931
|
};
|
|
7901
7932
|
return splitEditorGroup$1(stateWithInitialGroup, initialGroupId, Left$1);
|
|
7902
7933
|
}
|
|
7903
|
-
const targetGroupId = groupId ?? activeGroupId
|
|
7934
|
+
const targetGroupId = groupId ?? (activeGroupId === -1 ? groups[0]?.id : activeGroupId) ?? 0;
|
|
7904
7935
|
return splitEditorGroup$1(state, targetGroupId, Left$1);
|
|
7905
7936
|
};
|
|
7906
7937
|
|
|
@@ -7918,7 +7949,7 @@ const splitRight = (state, groupId) => {
|
|
|
7918
7949
|
if (groups.length === 0) {
|
|
7919
7950
|
const initialGroupId = create$2();
|
|
7920
7951
|
const initialGroup = {
|
|
7921
|
-
activeTabId:
|
|
7952
|
+
activeTabId: -1,
|
|
7922
7953
|
direction,
|
|
7923
7954
|
focused: true,
|
|
7924
7955
|
id: initialGroupId,
|
|
@@ -7936,7 +7967,7 @@ const splitRight = (state, groupId) => {
|
|
|
7936
7967
|
};
|
|
7937
7968
|
return splitEditorGroup$1(stateWithInitialGroup, initialGroupId, Right$1);
|
|
7938
7969
|
}
|
|
7939
|
-
const targetGroupId = groupId ?? activeGroupId
|
|
7970
|
+
const targetGroupId = groupId ?? (activeGroupId === -1 ? groups[0]?.id : activeGroupId) ?? 0;
|
|
7940
7971
|
return splitEditorGroup$1(state, targetGroupId, Right$1);
|
|
7941
7972
|
};
|
|
7942
7973
|
|
|
@@ -7952,7 +7983,7 @@ const splitUp = (state, groupId) => {
|
|
|
7952
7983
|
if (groups.length === 0) {
|
|
7953
7984
|
const initialGroupId = create$2();
|
|
7954
7985
|
const initialGroup = {
|
|
7955
|
-
activeTabId:
|
|
7986
|
+
activeTabId: -1,
|
|
7956
7987
|
direction,
|
|
7957
7988
|
focused: true,
|
|
7958
7989
|
id: initialGroupId,
|