@lvce-editor/main-area-worker 9.22.0 → 9.27.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/mainAreaWorkerMain.js +409 -217
- package/package.json +1 -1
|
@@ -3,10 +3,67 @@ const toCommandId = key => {
|
|
|
3
3
|
return key.slice(dotIndex + 1);
|
|
4
4
|
};
|
|
5
5
|
const create$f = () => {
|
|
6
|
+
const commandQueues = new Map();
|
|
7
|
+
const generations = Object.create(null);
|
|
6
8
|
const states = Object.create(null);
|
|
7
9
|
const commandMapRef = {};
|
|
10
|
+
const getGeneration = uid => generations[uid] || 0;
|
|
11
|
+
const isCurrentGeneration = (uid, generation) => {
|
|
12
|
+
return states[uid] !== undefined && getGeneration(uid) === generation;
|
|
13
|
+
};
|
|
14
|
+
const updateState = (uid, generation, fallbackState, updater) => {
|
|
15
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
16
|
+
return Promise.resolve(fallbackState);
|
|
17
|
+
}
|
|
18
|
+
const current = states[uid];
|
|
19
|
+
const updatedState = updater(current.newState);
|
|
20
|
+
if (updatedState !== current.newState) {
|
|
21
|
+
states[uid] = {
|
|
22
|
+
newState: updatedState,
|
|
23
|
+
oldState: current.oldState,
|
|
24
|
+
scheduledState: updatedState
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return Promise.resolve(updatedState);
|
|
28
|
+
};
|
|
29
|
+
const createAsyncCommandContext = (uid, generation) => {
|
|
30
|
+
let latestState = states[uid].newState;
|
|
31
|
+
return {
|
|
32
|
+
getState: () => {
|
|
33
|
+
if (isCurrentGeneration(uid, generation)) {
|
|
34
|
+
latestState = states[uid].newState;
|
|
35
|
+
}
|
|
36
|
+
return latestState;
|
|
37
|
+
},
|
|
38
|
+
updateState: async updater => {
|
|
39
|
+
latestState = await updateState(uid, generation, latestState, updater);
|
|
40
|
+
return latestState;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const enqueueCommand = async (uid, command) => {
|
|
45
|
+
const previous = commandQueues.get(uid) || Promise.resolve();
|
|
46
|
+
const run = async () => {
|
|
47
|
+
try {
|
|
48
|
+
await previous;
|
|
49
|
+
} catch {
|
|
50
|
+
// The previous caller receives its error; later commands must still run.
|
|
51
|
+
}
|
|
52
|
+
await command();
|
|
53
|
+
};
|
|
54
|
+
const current = run();
|
|
55
|
+
commandQueues.set(uid, current);
|
|
56
|
+
try {
|
|
57
|
+
await current;
|
|
58
|
+
} finally {
|
|
59
|
+
if (commandQueues.get(uid) === current) {
|
|
60
|
+
commandQueues.delete(uid);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
8
64
|
return {
|
|
9
65
|
clear() {
|
|
66
|
+
commandQueues.clear();
|
|
10
67
|
for (const key of Object.keys(states)) {
|
|
11
68
|
delete states[key];
|
|
12
69
|
}
|
|
@@ -26,6 +83,7 @@ const create$f = () => {
|
|
|
26
83
|
return diffResult;
|
|
27
84
|
},
|
|
28
85
|
dispose(uid) {
|
|
86
|
+
commandQueues.delete(uid);
|
|
29
87
|
delete states[uid];
|
|
30
88
|
},
|
|
31
89
|
get(uid) {
|
|
@@ -43,14 +101,27 @@ const create$f = () => {
|
|
|
43
101
|
Object.assign(commandMapRef, commandMap);
|
|
44
102
|
},
|
|
45
103
|
set(uid, oldState, newState, scheduledState) {
|
|
104
|
+
const current = states[uid];
|
|
105
|
+
if (!current || oldState === newState && newState !== current.newState) {
|
|
106
|
+
generations[uid] = getGeneration(uid) + 1;
|
|
107
|
+
}
|
|
46
108
|
states[uid] = {
|
|
47
109
|
newState,
|
|
48
110
|
oldState,
|
|
49
111
|
scheduledState: scheduledState ?? newState
|
|
50
112
|
};
|
|
51
113
|
},
|
|
114
|
+
wrapAsyncCommand(fn) {
|
|
115
|
+
const wrapped = async (uid, ...args) => {
|
|
116
|
+
const generation = getGeneration(uid);
|
|
117
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
118
|
+
await fn(context, ...args);
|
|
119
|
+
};
|
|
120
|
+
return wrapped;
|
|
121
|
+
},
|
|
52
122
|
wrapCommand(fn) {
|
|
53
123
|
const wrapped = async (uid, ...args) => {
|
|
124
|
+
const generation = getGeneration(uid);
|
|
54
125
|
const {
|
|
55
126
|
newState,
|
|
56
127
|
oldState
|
|
@@ -59,6 +130,9 @@ const create$f = () => {
|
|
|
59
130
|
if (oldState === newerState || newState === newerState) {
|
|
60
131
|
return;
|
|
61
132
|
}
|
|
133
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
62
136
|
const latestOld = states[uid];
|
|
63
137
|
const latestNew = {
|
|
64
138
|
...latestOld.newState,
|
|
@@ -83,6 +157,7 @@ const create$f = () => {
|
|
|
83
157
|
},
|
|
84
158
|
wrapLoadContent(fn) {
|
|
85
159
|
const wrapped = async (uid, ...args) => {
|
|
160
|
+
const generation = getGeneration(uid);
|
|
86
161
|
const {
|
|
87
162
|
newState,
|
|
88
163
|
oldState
|
|
@@ -97,6 +172,11 @@ const create$f = () => {
|
|
|
97
172
|
error
|
|
98
173
|
};
|
|
99
174
|
}
|
|
175
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
176
|
+
return {
|
|
177
|
+
error
|
|
178
|
+
};
|
|
179
|
+
}
|
|
100
180
|
const latestOld = states[uid];
|
|
101
181
|
const latestNew = {
|
|
102
182
|
...latestOld.newState,
|
|
@@ -112,6 +192,51 @@ const create$f = () => {
|
|
|
112
192
|
};
|
|
113
193
|
};
|
|
114
194
|
return wrapped;
|
|
195
|
+
},
|
|
196
|
+
wrapSerialAsyncCommand(fn) {
|
|
197
|
+
const wrapped = async (uid, ...args) => {
|
|
198
|
+
await enqueueCommand(uid, async () => {
|
|
199
|
+
if (!states[uid]) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const generation = getGeneration(uid);
|
|
203
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
204
|
+
await fn(context, ...args);
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
return wrapped;
|
|
208
|
+
},
|
|
209
|
+
wrapSerialCommand(fn) {
|
|
210
|
+
const wrapped = async (uid, ...args) => {
|
|
211
|
+
await enqueueCommand(uid, async () => {
|
|
212
|
+
if (!states[uid]) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const generation = getGeneration(uid);
|
|
216
|
+
const {
|
|
217
|
+
newState,
|
|
218
|
+
oldState
|
|
219
|
+
} = states[uid];
|
|
220
|
+
const newerState = await fn(newState, ...args);
|
|
221
|
+
if (oldState === newerState || newState === newerState) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const latestOld = states[uid];
|
|
228
|
+
const latestNew = {
|
|
229
|
+
...latestOld.newState,
|
|
230
|
+
...newerState
|
|
231
|
+
};
|
|
232
|
+
states[uid] = {
|
|
233
|
+
newState: latestNew,
|
|
234
|
+
oldState: latestOld.oldState,
|
|
235
|
+
scheduledState: latestNew
|
|
236
|
+
};
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
return wrapped;
|
|
115
240
|
}
|
|
116
241
|
};
|
|
117
242
|
};
|
|
@@ -2125,8 +2250,10 @@ const {
|
|
|
2125
2250
|
getKeys: getKeys$1,
|
|
2126
2251
|
registerCommands,
|
|
2127
2252
|
set,
|
|
2128
|
-
|
|
2129
|
-
wrapGetter
|
|
2253
|
+
wrapAsyncCommand,
|
|
2254
|
+
wrapGetter,
|
|
2255
|
+
wrapSerialAsyncCommand,
|
|
2256
|
+
wrapSerialCommand
|
|
2130
2257
|
} = create$f();
|
|
2131
2258
|
|
|
2132
2259
|
const create$2 = (uid, uri, x, y, width, height, platform, assetDir, tabHeight = 35) => {
|
|
@@ -2145,6 +2272,7 @@ const create$2 = (uid, uri, x, y, width, height, platform, assetDir, tabHeight =
|
|
|
2145
2272
|
},
|
|
2146
2273
|
maxOpenEditorGroups: Infinity,
|
|
2147
2274
|
maxOpenEditors: Infinity,
|
|
2275
|
+
minGroupHeightPx: 80,
|
|
2148
2276
|
minGroupWidthPx: 250,
|
|
2149
2277
|
platform,
|
|
2150
2278
|
splitButtonEnabled: false,
|
|
@@ -2199,6 +2327,19 @@ const handleAttach = async command => {
|
|
|
2199
2327
|
await invoke('Layout.attachViewlet', parentNodeSelector, command.instanceId);
|
|
2200
2328
|
};
|
|
2201
2329
|
|
|
2330
|
+
const getTitle$1 = async editorUid => {
|
|
2331
|
+
try {
|
|
2332
|
+
const title = await invoke('Viewlet.getTitle', editorUid);
|
|
2333
|
+
return typeof title === 'string' && title ? title : undefined;
|
|
2334
|
+
} catch {
|
|
2335
|
+
return undefined;
|
|
2336
|
+
}
|
|
2337
|
+
};
|
|
2338
|
+
const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri) => {
|
|
2339
|
+
await invoke('Layout.createViewlet', viewletModuleId, editorUid, tabId, bounds, uri);
|
|
2340
|
+
return getTitle$1(editorUid);
|
|
2341
|
+
};
|
|
2342
|
+
|
|
2202
2343
|
const create$1 = () => {
|
|
2203
2344
|
return Math.random();
|
|
2204
2345
|
};
|
|
@@ -2371,7 +2512,7 @@ const findTabByEditorUid = (state, editorUid) => {
|
|
|
2371
2512
|
* With reference nodes, attachment is handled automatically by virtual DOM rendering.
|
|
2372
2513
|
* No commands needed - state update is sufficient.
|
|
2373
2514
|
*/
|
|
2374
|
-
const handleViewletReady = (state, editorUid) => {
|
|
2515
|
+
const handleViewletReady = (state, editorUid, title) => {
|
|
2375
2516
|
if (editorUid === -1) {
|
|
2376
2517
|
throw new Error('Invalid editorUid -1');
|
|
2377
2518
|
}
|
|
@@ -2386,7 +2527,10 @@ const handleViewletReady = (state, editorUid) => {
|
|
|
2386
2527
|
// Reference nodes will handle rendering at the correct position automatically
|
|
2387
2528
|
const newState = updateTab(state, tab.id, {
|
|
2388
2529
|
editorUid,
|
|
2389
|
-
loadingState: 'loaded'
|
|
2530
|
+
loadingState: 'loaded',
|
|
2531
|
+
...(title && {
|
|
2532
|
+
title
|
|
2533
|
+
})
|
|
2390
2534
|
});
|
|
2391
2535
|
|
|
2392
2536
|
// No attach commands needed - virtual DOM reference nodes handle positioning
|
|
@@ -2396,9 +2540,7 @@ const handleViewletReady = (state, editorUid) => {
|
|
|
2396
2540
|
const handleCreate = async command => {
|
|
2397
2541
|
// Safe to call - no visible side effects
|
|
2398
2542
|
|
|
2399
|
-
const
|
|
2400
|
-
|
|
2401
|
-
await invoke('Layout.createViewlet', command.viewletModuleId, command.tabId, command.bounds, command.uri, instanceId);
|
|
2543
|
+
const title = await createViewlet(command.viewletModuleId, command.editorUid, command.tabId, command.bounds, command.uri || '');
|
|
2402
2544
|
|
|
2403
2545
|
// After viewlet is created, mark it as ready
|
|
2404
2546
|
// Attachment is handled automatically by virtual DOM reference nodes
|
|
@@ -2406,7 +2548,7 @@ const handleCreate = async command => {
|
|
|
2406
2548
|
newState: state,
|
|
2407
2549
|
oldState
|
|
2408
2550
|
} = get(command.uid);
|
|
2409
|
-
const readyState = handleViewletReady(state, command.editorUid);
|
|
2551
|
+
const readyState = handleViewletReady(state, command.editorUid, title);
|
|
2410
2552
|
set(command.uid, oldState, readyState);
|
|
2411
2553
|
return readyState;
|
|
2412
2554
|
};
|
|
@@ -2465,6 +2607,7 @@ const getEditorInputEditorType = editorInput => {
|
|
|
2465
2607
|
case 'extension-detail-view':
|
|
2466
2608
|
case 'image':
|
|
2467
2609
|
case 'process-explorer':
|
|
2610
|
+
case 'running-extensions':
|
|
2468
2611
|
case 'video':
|
|
2469
2612
|
return 'custom';
|
|
2470
2613
|
case 'editor':
|
|
@@ -2484,6 +2627,8 @@ const getEditorInputUri = editorInput => {
|
|
|
2484
2627
|
return `extension-detail://${editorInput.extensionId}`;
|
|
2485
2628
|
case 'process-explorer':
|
|
2486
2629
|
return 'process-explorer://';
|
|
2630
|
+
case 'running-extensions':
|
|
2631
|
+
return 'running-extensions://';
|
|
2487
2632
|
}
|
|
2488
2633
|
};
|
|
2489
2634
|
|
|
@@ -2553,6 +2698,11 @@ const getEditorInputFromUri = uri => {
|
|
|
2553
2698
|
type: 'process-explorer'
|
|
2554
2699
|
};
|
|
2555
2700
|
}
|
|
2701
|
+
if (uri.startsWith('running-extensions://')) {
|
|
2702
|
+
return {
|
|
2703
|
+
type: 'running-extensions'
|
|
2704
|
+
};
|
|
2705
|
+
}
|
|
2556
2706
|
const extension = getLowerCaseExtension(uri);
|
|
2557
2707
|
if (imageExtensions.has(extension)) {
|
|
2558
2708
|
return {
|
|
@@ -2676,10 +2826,6 @@ const getUpdatedGroups = (groups, groupIndex, needsLoading, tabId) => {
|
|
|
2676
2826
|
});
|
|
2677
2827
|
};
|
|
2678
2828
|
|
|
2679
|
-
const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri) => {
|
|
2680
|
-
await invoke('Layout.createViewlet', viewletModuleId, editorUid, tabId, bounds, uri);
|
|
2681
|
-
};
|
|
2682
|
-
|
|
2683
2829
|
const findTabById = (state, tabId) => {
|
|
2684
2830
|
const {
|
|
2685
2831
|
layout
|
|
@@ -2723,6 +2869,7 @@ const DiffEditor = 'DiffEditor';
|
|
|
2723
2869
|
const EditorText = 'Editor';
|
|
2724
2870
|
const ExtensionDetail = 'ExtensionDetail';
|
|
2725
2871
|
const ProcessExplorer = 'ProcessExplorer';
|
|
2872
|
+
const RunningExtensions = 'RunningExtensions';
|
|
2726
2873
|
const QuickPick = 'QuickPick';
|
|
2727
2874
|
|
|
2728
2875
|
const getViewletModuleIdForEditorInput = async editorInput => {
|
|
@@ -2737,6 +2884,8 @@ const getViewletModuleIdForEditorInput = async editorInput => {
|
|
|
2737
2884
|
return ExtensionDetail;
|
|
2738
2885
|
case 'process-explorer':
|
|
2739
2886
|
return ProcessExplorer;
|
|
2887
|
+
case 'running-extensions':
|
|
2888
|
+
return RunningExtensions;
|
|
2740
2889
|
}
|
|
2741
2890
|
};
|
|
2742
2891
|
|
|
@@ -2791,8 +2940,8 @@ const maybeCreateViewletForSelectedTab = async (state, newState, groupIndex, ind
|
|
|
2791
2940
|
editorUid
|
|
2792
2941
|
} = tabWithViewlet.tab;
|
|
2793
2942
|
if (editorUid !== -1 && selectedTab.uri) {
|
|
2794
|
-
await createViewlet(viewletModuleId, editorUid, tabId, bounds, selectedTab.uri);
|
|
2795
|
-
stateWithViewlet = handleViewletReady(stateWithViewlet, editorUid);
|
|
2943
|
+
const title = await createViewlet(viewletModuleId, editorUid, tabId, bounds, selectedTab.uri);
|
|
2944
|
+
stateWithViewlet = handleViewletReady(stateWithViewlet, editorUid, title);
|
|
2796
2945
|
set(uid, state, stateWithViewlet);
|
|
2797
2946
|
}
|
|
2798
2947
|
}
|
|
@@ -3265,6 +3414,9 @@ const getLabel = uri => {
|
|
|
3265
3414
|
if (uri.startsWith('process-explorer://')) {
|
|
3266
3415
|
return 'Process Explorer';
|
|
3267
3416
|
}
|
|
3417
|
+
if (uri.startsWith('running-extensions://')) {
|
|
3418
|
+
return 'Running Extensions';
|
|
3419
|
+
}
|
|
3268
3420
|
if (uri.startsWith(inlineDiffPrefix)) {
|
|
3269
3421
|
return getInlineDiffLabel(uri);
|
|
3270
3422
|
}
|
|
@@ -3287,6 +3439,8 @@ const getEditorInputTitle = editorInput => {
|
|
|
3287
3439
|
return editorInput.extensionId;
|
|
3288
3440
|
case 'process-explorer':
|
|
3289
3441
|
return 'Process Explorer';
|
|
3442
|
+
case 'running-extensions':
|
|
3443
|
+
return 'Running Extensions';
|
|
3290
3444
|
}
|
|
3291
3445
|
};
|
|
3292
3446
|
|
|
@@ -3571,6 +3725,7 @@ const getIconsCached = (dirents, fileIconCache) => {
|
|
|
3571
3725
|
};
|
|
3572
3726
|
|
|
3573
3727
|
const ExtensionDetailScheme$1 = 'extension-detail://';
|
|
3728
|
+
const RunningExtensionsScheme$1 = 'running-extensions://';
|
|
3574
3729
|
const getBasename = uri => {
|
|
3575
3730
|
const lastSlashIndex = uri.lastIndexOf('/');
|
|
3576
3731
|
if (lastSlashIndex === -1) {
|
|
@@ -3581,7 +3736,7 @@ const getBasename = uri => {
|
|
|
3581
3736
|
const getMissingTabs = (tabs, fileIconCache) => {
|
|
3582
3737
|
const missingTabs = [];
|
|
3583
3738
|
for (const tab of tabs) {
|
|
3584
|
-
if (tab.uri && !tab.uri.startsWith(ExtensionDetailScheme$1) && !(tab.uri in fileIconCache)) {
|
|
3739
|
+
if (tab.uri && !tab.uri.startsWith(ExtensionDetailScheme$1) && !tab.uri.startsWith(RunningExtensionsScheme$1) && !(tab.uri in fileIconCache)) {
|
|
3585
3740
|
missingTabs.push(tab);
|
|
3586
3741
|
}
|
|
3587
3742
|
}
|
|
@@ -3651,7 +3806,7 @@ const getFileIconsForTabs = async (tabs, fileIconCache) => {
|
|
|
3651
3806
|
};
|
|
3652
3807
|
};
|
|
3653
3808
|
|
|
3654
|
-
const updateTabIcon = async (
|
|
3809
|
+
const updateTabIcon = async (context, readyState, tabId) => {
|
|
3655
3810
|
const newTab = findTabById(readyState, tabId);
|
|
3656
3811
|
if (!newTab || !newTab.tab.uri) {
|
|
3657
3812
|
return undefined;
|
|
@@ -3660,9 +3815,7 @@ const updateTabIcon = async (uid, state, readyState, tabId) => {
|
|
|
3660
3815
|
const {
|
|
3661
3816
|
newFileIconCache
|
|
3662
3817
|
} = await getFileIconsForTabs([newTab.tab], readyState.fileIconCache);
|
|
3663
|
-
const
|
|
3664
|
-
newState: stateBeforeIconUpdate
|
|
3665
|
-
} = get(uid);
|
|
3818
|
+
const stateBeforeIconUpdate = context.getState();
|
|
3666
3819
|
const icon = newFileIconCache[newTab.tab.uri] || '';
|
|
3667
3820
|
const stateWithIcon = {
|
|
3668
3821
|
...stateBeforeIconUpdate,
|
|
@@ -3678,19 +3831,16 @@ const updateTabIcon = async (uid, state, readyState, tabId) => {
|
|
|
3678
3831
|
}))
|
|
3679
3832
|
}
|
|
3680
3833
|
};
|
|
3681
|
-
|
|
3682
|
-
return stateWithIcon;
|
|
3834
|
+
return context.updateState(() => stateWithIcon);
|
|
3683
3835
|
} catch {
|
|
3684
3836
|
return undefined;
|
|
3685
3837
|
}
|
|
3686
3838
|
};
|
|
3687
3839
|
|
|
3688
|
-
const
|
|
3840
|
+
const openInputWithContext = async (context, options) => {
|
|
3841
|
+
const state = context.getState();
|
|
3689
3842
|
object(state);
|
|
3690
3843
|
object(options);
|
|
3691
|
-
const {
|
|
3692
|
-
uid
|
|
3693
|
-
} = state;
|
|
3694
3844
|
const {
|
|
3695
3845
|
editorInput
|
|
3696
3846
|
} = options;
|
|
@@ -3698,40 +3848,40 @@ const openInput = async (state, options) => {
|
|
|
3698
3848
|
const uri = getEditorInputUri(editorInput);
|
|
3699
3849
|
const title = getEditorInputTitle(editorInput);
|
|
3700
3850
|
const editorType = getEditorInputEditorType(editorInput);
|
|
3701
|
-
const currentState =
|
|
3851
|
+
const currentState = state;
|
|
3702
3852
|
const existingTab = findTabByUri(currentState, uri);
|
|
3703
3853
|
const shouldRetryExistingTab = !!existingTab && existingTab.tab.loadingState === 'error';
|
|
3704
3854
|
if (existingTab && !shouldRetryExistingTab) {
|
|
3705
3855
|
const focusedState = focusEditorGroup(currentState, existingTab.groupId);
|
|
3706
|
-
|
|
3856
|
+
const switchedState = switchTab(focusedState, existingTab.groupId, existingTab.tab.id);
|
|
3857
|
+
await context.updateState(() => switchedState);
|
|
3858
|
+
return;
|
|
3707
3859
|
}
|
|
3708
3860
|
const previousTabId = getActiveTabId(currentState);
|
|
3709
3861
|
const {
|
|
3710
3862
|
stateWithTab,
|
|
3711
3863
|
tabId
|
|
3712
3864
|
} = getStateWithTab(currentState, editorInput, existingTab, shouldRetryExistingTab, uri, preview, title, editorType);
|
|
3713
|
-
|
|
3865
|
+
await context.updateState(() => stateWithTab);
|
|
3714
3866
|
if (await isDirectoryEditorInput(editorInput)) {
|
|
3715
|
-
const
|
|
3716
|
-
newState: latestState
|
|
3717
|
-
} = get(uid);
|
|
3867
|
+
const latestState = context.getState();
|
|
3718
3868
|
const errorState = updateTab(latestState, tabId, {
|
|
3719
3869
|
errorMessage: 'Expected a file but received a folder',
|
|
3720
3870
|
loadingState: 'error'
|
|
3721
3871
|
});
|
|
3722
|
-
|
|
3723
|
-
return
|
|
3872
|
+
await context.updateState(() => errorState);
|
|
3873
|
+
return;
|
|
3724
3874
|
}
|
|
3725
3875
|
try {
|
|
3726
3876
|
const viewletModuleId = await getViewletModuleIdForEditorInput(editorInput);
|
|
3727
|
-
const
|
|
3728
|
-
newState: stateAfterModuleId
|
|
3729
|
-
} = get(uid);
|
|
3877
|
+
const stateAfterModuleId = context.getState();
|
|
3730
3878
|
if (!viewletModuleId) {
|
|
3731
|
-
|
|
3879
|
+
const unsupportedState = updateTab(stateAfterModuleId, tabId, {
|
|
3732
3880
|
errorMessage: 'Could not determine editor type for this URI',
|
|
3733
3881
|
loadingState: 'error'
|
|
3734
3882
|
});
|
|
3883
|
+
await context.updateState(() => unsupportedState);
|
|
3884
|
+
return;
|
|
3735
3885
|
}
|
|
3736
3886
|
const bounds = {
|
|
3737
3887
|
height: stateAfterModuleId.height - stateAfterModuleId.tabHeight,
|
|
@@ -3745,10 +3895,10 @@ const openInput = async (state, options) => {
|
|
|
3745
3895
|
newState: switchedState
|
|
3746
3896
|
} = switchViewlet(intermediateState, previousTabId, tabId);
|
|
3747
3897
|
intermediateState = switchedState;
|
|
3748
|
-
|
|
3898
|
+
await context.updateState(() => intermediateState);
|
|
3749
3899
|
const tabWithViewlet = findTabById(intermediateState, tabId);
|
|
3750
3900
|
if (!tabWithViewlet) {
|
|
3751
|
-
return
|
|
3901
|
+
return;
|
|
3752
3902
|
}
|
|
3753
3903
|
const {
|
|
3754
3904
|
editorUid
|
|
@@ -3756,33 +3906,42 @@ const openInput = async (state, options) => {
|
|
|
3756
3906
|
if (editorUid === -1) {
|
|
3757
3907
|
throw new Error('invalid editorUid');
|
|
3758
3908
|
}
|
|
3759
|
-
await createViewlet(viewletModuleId, editorUid, tabId, bounds, uri);
|
|
3760
|
-
const
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
const
|
|
3764
|
-
set(uid, state, readyState);
|
|
3765
|
-
const stateWithIcon = await updateTabIcon(uid, state, readyState, tabId);
|
|
3909
|
+
const renderedTitle = await createViewlet(viewletModuleId, editorUid, tabId, bounds, uri);
|
|
3910
|
+
const latestState = context.getState();
|
|
3911
|
+
const readyState = handleViewletReady(latestState, editorUid, renderedTitle);
|
|
3912
|
+
await context.updateState(() => readyState);
|
|
3913
|
+
const stateWithIcon = await updateTabIcon(context, readyState, tabId);
|
|
3766
3914
|
if (stateWithIcon) {
|
|
3767
|
-
return
|
|
3915
|
+
return;
|
|
3768
3916
|
}
|
|
3769
|
-
const {
|
|
3770
|
-
newState: finalState
|
|
3771
|
-
} = get(uid);
|
|
3772
|
-
return finalState;
|
|
3773
3917
|
} catch (error) {
|
|
3774
|
-
const
|
|
3775
|
-
newState: latestState
|
|
3776
|
-
} = get(uid);
|
|
3918
|
+
const latestState = context.getState();
|
|
3777
3919
|
const errorMessage = error instanceof Error ? error.message : 'Failed to open URI';
|
|
3778
3920
|
const errorState = updateTab(latestState, tabId, {
|
|
3779
3921
|
errorMessage,
|
|
3780
3922
|
loadingState: 'error'
|
|
3781
3923
|
});
|
|
3782
|
-
|
|
3783
|
-
return errorState;
|
|
3924
|
+
await context.updateState(() => errorState);
|
|
3784
3925
|
}
|
|
3785
3926
|
};
|
|
3927
|
+
const openInput = async (state, options) => {
|
|
3928
|
+
const {
|
|
3929
|
+
uid
|
|
3930
|
+
} = state;
|
|
3931
|
+
let currentState = getCurrentState(state);
|
|
3932
|
+
const context = {
|
|
3933
|
+
getState: () => get(uid)?.newState ?? currentState,
|
|
3934
|
+
updateState: updater => {
|
|
3935
|
+
const storedState = get(uid);
|
|
3936
|
+
const latestState = storedState?.newState ?? currentState;
|
|
3937
|
+
currentState = updater(latestState);
|
|
3938
|
+
set(uid, storedState?.oldState ?? state, currentState);
|
|
3939
|
+
return Promise.resolve(currentState);
|
|
3940
|
+
}
|
|
3941
|
+
};
|
|
3942
|
+
await openInputWithContext(context, options);
|
|
3943
|
+
return context.getState();
|
|
3944
|
+
};
|
|
3786
3945
|
|
|
3787
3946
|
const getOptionUriOptions = options => {
|
|
3788
3947
|
if (typeof options === 'string') {
|
|
@@ -3791,14 +3950,20 @@ const getOptionUriOptions = options => {
|
|
|
3791
3950
|
return options.uri;
|
|
3792
3951
|
};
|
|
3793
3952
|
|
|
3794
|
-
const
|
|
3953
|
+
const getOpenInputOptions = options => {
|
|
3795
3954
|
const uri = getOptionUriOptions(options);
|
|
3796
3955
|
const preview = typeof options === 'string' ? false : options.preview ?? false;
|
|
3797
|
-
return
|
|
3956
|
+
return {
|
|
3798
3957
|
editorInput: getNormalizedOpenEditorInput(uri),
|
|
3799
3958
|
focus: typeof options === 'string' ? false : options.focus,
|
|
3800
3959
|
preview
|
|
3801
|
-
}
|
|
3960
|
+
};
|
|
3961
|
+
};
|
|
3962
|
+
const openUri = async (state, options) => {
|
|
3963
|
+
return openInput(state, getOpenInputOptions(options));
|
|
3964
|
+
};
|
|
3965
|
+
const openUriWithContext = async (context, options) => {
|
|
3966
|
+
await openInputWithContext(context, getOpenInputOptions(options));
|
|
3802
3967
|
};
|
|
3803
3968
|
|
|
3804
3969
|
const retryOpen = async state => {
|
|
@@ -4129,6 +4294,7 @@ const MaskIconPreview = 'MaskIcon MaskIconPreview';
|
|
|
4129
4294
|
const MaskIconCircleFilled = 'MaskIcon MaskIconCircleFilled';
|
|
4130
4295
|
const MaskIconClose = 'MaskIcon MaskIconClose';
|
|
4131
4296
|
const MaskIconExtensions = 'MaskIcon MaskIconExtensions';
|
|
4297
|
+
const MaskIconRecordKey = 'MaskIcon MaskIconRecordKey';
|
|
4132
4298
|
const TextEditor = 'TextEditor';
|
|
4133
4299
|
const TextEditorLoading = 'TextEditor TextEditor--loading';
|
|
4134
4300
|
const EditorContentLoading = 'EditorContent EditorContent--loading';
|
|
@@ -4246,13 +4412,13 @@ const newFile = async state => {
|
|
|
4246
4412
|
if (actualEditorUid === -1) {
|
|
4247
4413
|
throw new Error(`invalid editorUid`);
|
|
4248
4414
|
}
|
|
4249
|
-
await createViewlet(viewletModuleId, actualEditorUid, tabId, bounds, newTab.uri || '');
|
|
4415
|
+
const title = await createViewlet(viewletModuleId, actualEditorUid, tabId, bounds, newTab.uri || '');
|
|
4250
4416
|
|
|
4251
4417
|
// After viewlet is created, get the latest state and mark it as ready
|
|
4252
4418
|
const {
|
|
4253
4419
|
newState: latestState
|
|
4254
4420
|
} = get(uid);
|
|
4255
|
-
const readyState = handleViewletReady(latestState, actualEditorUid);
|
|
4421
|
+
const readyState = handleViewletReady(latestState, actualEditorUid, title);
|
|
4256
4422
|
return readyState;
|
|
4257
4423
|
};
|
|
4258
4424
|
|
|
@@ -4347,6 +4513,9 @@ const handleModifiedStatusChange = (state, uri, newStatus) => {
|
|
|
4347
4513
|
}
|
|
4348
4514
|
};
|
|
4349
4515
|
};
|
|
4516
|
+
const handleModifiedStatusChangeWithContext = async (context, uri, newStatus) => {
|
|
4517
|
+
await context.updateState(state => handleModifiedStatusChange(state, uri, newStatus));
|
|
4518
|
+
};
|
|
4350
4519
|
|
|
4351
4520
|
const handleResize = async (state, dimensions) => {
|
|
4352
4521
|
const {
|
|
@@ -4445,13 +4614,11 @@ const clamp = (value, min, max) => {
|
|
|
4445
4614
|
return Math.min(max, Math.max(min, value));
|
|
4446
4615
|
};
|
|
4447
4616
|
|
|
4448
|
-
const getMinGroupSizePercent = (axisSize,
|
|
4617
|
+
const getMinGroupSizePercent = (axisSize, minGroupSizePx) => {
|
|
4449
4618
|
if (!axisSize) {
|
|
4450
|
-
return
|
|
4619
|
+
return 0;
|
|
4451
4620
|
}
|
|
4452
|
-
|
|
4453
|
-
// Ensure minimum is at least 10%, matching the CSS 250px constraint on typical widths
|
|
4454
|
-
return Math.max(minPercent, 10);
|
|
4621
|
+
return minGroupSizePx / axisSize * 100;
|
|
4455
4622
|
};
|
|
4456
4623
|
|
|
4457
4624
|
const round = value => {
|
|
@@ -4482,7 +4649,8 @@ const handleSashPointerMove = async (state, clientX, clientY) => {
|
|
|
4482
4649
|
const deltaPx = direction === Horizontal ? clientX - sashDrag.startClientX : clientY - sashDrag.startClientY;
|
|
4483
4650
|
const deltaPercent = deltaPx / axisSize * 100;
|
|
4484
4651
|
const totalResizableSize = sashDrag.beforeSize + sashDrag.afterSize;
|
|
4485
|
-
|
|
4652
|
+
const minGroupSizePx = direction === Horizontal ? state.minGroupWidthPx : state.minGroupHeightPx;
|
|
4653
|
+
let minGroupSize = getMinGroupSizePercent(axisSize, minGroupSizePx);
|
|
4486
4654
|
|
|
4487
4655
|
// If the minimum size makes it impossible to fit two groups, relax the constraint
|
|
4488
4656
|
if (2 * minGroupSize > totalResizableSize) {
|
|
@@ -4580,47 +4748,6 @@ const handleUriChange = async (state, oldUri, newUri) => {
|
|
|
4580
4748
|
};
|
|
4581
4749
|
};
|
|
4582
4750
|
|
|
4583
|
-
const handleWorkspaceChange = state => {
|
|
4584
|
-
const {
|
|
4585
|
-
layout
|
|
4586
|
-
} = state;
|
|
4587
|
-
return {
|
|
4588
|
-
...state,
|
|
4589
|
-
layout: {
|
|
4590
|
-
...layout,
|
|
4591
|
-
activeGroupId: undefined,
|
|
4592
|
-
groups: []
|
|
4593
|
-
}
|
|
4594
|
-
};
|
|
4595
|
-
};
|
|
4596
|
-
|
|
4597
|
-
const hasActiveTextEditor = state => {
|
|
4598
|
-
const activeTab = getActiveTab(state);
|
|
4599
|
-
return activeTab?.tab.editorInput?.type === 'editor';
|
|
4600
|
-
};
|
|
4601
|
-
|
|
4602
|
-
const id = 7201;
|
|
4603
|
-
const sendMessagePortToExtensionHostWorker = async port => {
|
|
4604
|
-
await sendMessagePortToExtensionHostWorker$1(port, id);
|
|
4605
|
-
};
|
|
4606
|
-
|
|
4607
|
-
const createExtensionHostRpc = async () => {
|
|
4608
|
-
try {
|
|
4609
|
-
const rpc = await create$8({
|
|
4610
|
-
commandMap: {},
|
|
4611
|
-
send: sendMessagePortToExtensionHostWorker
|
|
4612
|
-
});
|
|
4613
|
-
return rpc;
|
|
4614
|
-
} catch (error) {
|
|
4615
|
-
throw new VError(error, `Failed to create extension host rpc`);
|
|
4616
|
-
}
|
|
4617
|
-
};
|
|
4618
|
-
|
|
4619
|
-
const initialize = async () => {
|
|
4620
|
-
const rpc = await createExtensionHostRpc();
|
|
4621
|
-
set$3(rpc);
|
|
4622
|
-
};
|
|
4623
|
-
|
|
4624
4751
|
const toFileUri = path => {
|
|
4625
4752
|
if (!path) {
|
|
4626
4753
|
return '';
|
|
@@ -4730,15 +4857,22 @@ const tryRestoreLayout = savedState => {
|
|
|
4730
4857
|
|
|
4731
4858
|
const createViewlets = async (layout, viewletModuleIds, bounds) => {
|
|
4732
4859
|
const editorUids = {};
|
|
4860
|
+
const titles = {};
|
|
4733
4861
|
for (const group of layout.groups) {
|
|
4734
4862
|
const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
|
|
4735
4863
|
if (activeTab && viewletModuleIds[activeTab.id]) {
|
|
4736
4864
|
const editorUid = activeTab.editorUid === -1 ? create$1() : activeTab.editorUid;
|
|
4737
4865
|
editorUids[activeTab.id] = editorUid;
|
|
4738
|
-
await createViewlet(viewletModuleIds[activeTab.id], editorUid, activeTab.id, bounds, activeTab.uri);
|
|
4866
|
+
const title = await createViewlet(viewletModuleIds[activeTab.id], editorUid, activeTab.id, bounds, activeTab.uri);
|
|
4867
|
+
if (title) {
|
|
4868
|
+
titles[activeTab.id] = title;
|
|
4869
|
+
}
|
|
4739
4870
|
}
|
|
4740
4871
|
}
|
|
4741
|
-
return
|
|
4872
|
+
return {
|
|
4873
|
+
editorUids,
|
|
4874
|
+
titles
|
|
4875
|
+
};
|
|
4742
4876
|
};
|
|
4743
4877
|
|
|
4744
4878
|
const getViewletModuleIds = async layout => {
|
|
@@ -4815,7 +4949,10 @@ const restoreAndCreateEditors = async (state, restoredLayout) => {
|
|
|
4815
4949
|
const viewletModuleIds = await getViewletModuleIds(newState.layout);
|
|
4816
4950
|
|
|
4817
4951
|
// Create viewlets and get editor UIDs
|
|
4818
|
-
const
|
|
4952
|
+
const {
|
|
4953
|
+
editorUids,
|
|
4954
|
+
titles
|
|
4955
|
+
} = await createViewlets(newState.layout, viewletModuleIds, bounds);
|
|
4819
4956
|
|
|
4820
4957
|
// Update tabs with editor UIDs
|
|
4821
4958
|
newState = updateTabs(newState, editorUids);
|
|
@@ -4826,7 +4963,7 @@ const restoreAndCreateEditors = async (state, restoredLayout) => {
|
|
|
4826
4963
|
if (activeTab && viewletModuleIds[activeTab.id]) {
|
|
4827
4964
|
const editorUid = editorUids[activeTab.id];
|
|
4828
4965
|
newState = createViewletForTab(newState, activeTab.id);
|
|
4829
|
-
newState = handleViewletReady(newState, editorUid);
|
|
4966
|
+
newState = handleViewletReady(newState, editorUid, titles[activeTab.id]);
|
|
4830
4967
|
}
|
|
4831
4968
|
}
|
|
4832
4969
|
return newState;
|
|
@@ -4869,6 +5006,37 @@ const loadContent = async (state, savedState) => {
|
|
|
4869
5006
|
};
|
|
4870
5007
|
};
|
|
4871
5008
|
|
|
5009
|
+
const handleWorkspaceChange = async (state, _workspacePath, savedState) => {
|
|
5010
|
+
return loadContent(state, savedState);
|
|
5011
|
+
};
|
|
5012
|
+
|
|
5013
|
+
const hasActiveTextEditor = state => {
|
|
5014
|
+
const activeTab = getActiveTab(state);
|
|
5015
|
+
return activeTab?.tab.editorInput?.type === 'editor';
|
|
5016
|
+
};
|
|
5017
|
+
|
|
5018
|
+
const id = 7201;
|
|
5019
|
+
const sendMessagePortToExtensionHostWorker = async port => {
|
|
5020
|
+
await sendMessagePortToExtensionHostWorker$1(port, id);
|
|
5021
|
+
};
|
|
5022
|
+
|
|
5023
|
+
const createExtensionHostRpc = async () => {
|
|
5024
|
+
try {
|
|
5025
|
+
const rpc = await create$8({
|
|
5026
|
+
commandMap: {},
|
|
5027
|
+
send: sendMessagePortToExtensionHostWorker
|
|
5028
|
+
});
|
|
5029
|
+
return rpc;
|
|
5030
|
+
} catch (error) {
|
|
5031
|
+
throw new VError(error, `Failed to create extension host rpc`);
|
|
5032
|
+
}
|
|
5033
|
+
};
|
|
5034
|
+
|
|
5035
|
+
const initialize = async () => {
|
|
5036
|
+
const rpc = await createExtensionHostRpc();
|
|
5037
|
+
set$3(rpc);
|
|
5038
|
+
};
|
|
5039
|
+
|
|
4872
5040
|
const hasTargetGroup = groupId => {
|
|
4873
5041
|
return groupId !== undefined && groupId >= 0;
|
|
4874
5042
|
};
|
|
@@ -5242,26 +5410,26 @@ const newWindow = async state => {
|
|
|
5242
5410
|
return state;
|
|
5243
5411
|
};
|
|
5244
5412
|
|
|
5245
|
-
const
|
|
5413
|
+
const openUrisWithContext = async (context, uris) => {
|
|
5246
5414
|
if (uris.length === 0) {
|
|
5247
|
-
return
|
|
5415
|
+
return;
|
|
5248
5416
|
}
|
|
5417
|
+
await openUriWithContext(context, uris[0]);
|
|
5249
5418
|
if (uris.length === 1) {
|
|
5250
|
-
return
|
|
5419
|
+
return;
|
|
5251
5420
|
}
|
|
5252
|
-
let currentState =
|
|
5421
|
+
let currentState = context.getState();
|
|
5253
5422
|
const firstTab = findTabByUri(currentState, uris[0]);
|
|
5254
5423
|
for (const uri of uris.slice(1)) {
|
|
5255
5424
|
const existingTab = findTabByUri(currentState, uri);
|
|
5256
|
-
if (existingTab) {
|
|
5257
|
-
|
|
5425
|
+
if (!existingTab) {
|
|
5426
|
+
currentState = ensureActiveGroup(currentState, uri);
|
|
5258
5427
|
}
|
|
5259
|
-
currentState = ensureActiveGroup(currentState, uri);
|
|
5260
5428
|
}
|
|
5261
|
-
if (
|
|
5262
|
-
|
|
5429
|
+
if (firstTab) {
|
|
5430
|
+
currentState = switchTab(currentState, firstTab.groupId, firstTab.tab.id);
|
|
5263
5431
|
}
|
|
5264
|
-
|
|
5432
|
+
await context.updateState(() => currentState);
|
|
5265
5433
|
};
|
|
5266
5434
|
|
|
5267
5435
|
const refresh = state => {
|
|
@@ -5788,18 +5956,29 @@ const renderTabActions = (isDirty, tabIndex, groupIndex) => {
|
|
|
5788
5956
|
};
|
|
5789
5957
|
|
|
5790
5958
|
const ExtensionDetailScheme = 'extension-detail://';
|
|
5959
|
+
const KeyBindingsUri = 'app://keybindings';
|
|
5960
|
+
const RunningExtensionsScheme = 'running-extensions://';
|
|
5961
|
+
const renderMaskIcon = className => {
|
|
5962
|
+
return [{
|
|
5963
|
+
childCount: 1,
|
|
5964
|
+
className: TabIcon,
|
|
5965
|
+
role: None$1,
|
|
5966
|
+
type: Div
|
|
5967
|
+
}, {
|
|
5968
|
+
childCount: 0,
|
|
5969
|
+
className,
|
|
5970
|
+
type: Div
|
|
5971
|
+
}];
|
|
5972
|
+
};
|
|
5791
5973
|
const renderTabIcon = tab => {
|
|
5974
|
+
if (tab.uri === KeyBindingsUri) {
|
|
5975
|
+
return renderMaskIcon(MaskIconRecordKey);
|
|
5976
|
+
}
|
|
5792
5977
|
if (tab.uri?.startsWith(ExtensionDetailScheme)) {
|
|
5793
|
-
return
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
type: Div
|
|
5798
|
-
}, {
|
|
5799
|
-
childCount: 0,
|
|
5800
|
-
className: MaskIconExtensions,
|
|
5801
|
-
type: Div
|
|
5802
|
-
}];
|
|
5978
|
+
return renderMaskIcon(MaskIconExtensions);
|
|
5979
|
+
}
|
|
5980
|
+
if (tab.uri?.startsWith(RunningExtensionsScheme)) {
|
|
5981
|
+
return renderMaskIcon(MaskIconExtensions);
|
|
5803
5982
|
}
|
|
5804
5983
|
return [{
|
|
5805
5984
|
childCount: 0,
|
|
@@ -5948,25 +6127,26 @@ const renderWaterMark = groupId => {
|
|
|
5948
6127
|
}];
|
|
5949
6128
|
};
|
|
5950
6129
|
|
|
5951
|
-
const renderEmptyEditorGroup = (group, groupIndex, style) => {
|
|
6130
|
+
const renderEmptyEditorGroup = (group, groupIndex, style, closeButtonEnabled = true) => {
|
|
6131
|
+
const closeButtonDom = closeButtonEnabled ? renderEmptyGroupCloseButton(group) : [];
|
|
5952
6132
|
return [{
|
|
5953
|
-
childCount: 2,
|
|
6133
|
+
childCount: closeButtonEnabled ? 2 : 1,
|
|
5954
6134
|
className: EditorGroup,
|
|
5955
6135
|
'data-groupId': String(group.id),
|
|
5956
6136
|
onContextMenu: HandleContextMenu,
|
|
5957
6137
|
style,
|
|
5958
6138
|
tabIndex: 0,
|
|
5959
6139
|
type: Div
|
|
5960
|
-
}, ...
|
|
6140
|
+
}, ...closeButtonDom, ...renderWaterMark(group.id)];
|
|
5961
6141
|
};
|
|
5962
6142
|
|
|
5963
|
-
const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizeProperty = 'width') => {
|
|
6143
|
+
const renderEditorGroup = (group, groupIndex, splitButtonEnabled = false, sizeProperty = 'width', closeButtonEnabled = true) => {
|
|
5964
6144
|
const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
|
|
5965
6145
|
const style = `${sizeProperty}:${group.size}%;`;
|
|
5966
6146
|
const hasTabs = group.tabs.length > 0;
|
|
5967
6147
|
const hasEmptyGroupCloseButton = !hasTabs;
|
|
5968
6148
|
if (hasEmptyGroupCloseButton) {
|
|
5969
|
-
return renderEmptyEditorGroup(group, groupIndex, style);
|
|
6149
|
+
return renderEmptyEditorGroup(group, groupIndex, style, closeButtonEnabled);
|
|
5970
6150
|
}
|
|
5971
6151
|
return [{
|
|
5972
6152
|
childCount: 2,
|
|
@@ -6008,7 +6188,7 @@ const renderSingleEditorGroup = (layout, splitButtonEnabled, sizeProperty = 'wid
|
|
|
6008
6188
|
childCount: 1,
|
|
6009
6189
|
className: Main,
|
|
6010
6190
|
type: Div
|
|
6011
|
-
}, ...renderEditorGroup(layout.groups[0], 0, splitButtonEnabled, sizeProperty)];
|
|
6191
|
+
}, ...renderEditorGroup(layout.groups[0], 0, splitButtonEnabled, sizeProperty, false)];
|
|
6012
6192
|
};
|
|
6013
6193
|
|
|
6014
6194
|
const getDirectionClassName = (direction, isSplit) => {
|
|
@@ -6268,9 +6448,21 @@ const save = async state => {
|
|
|
6268
6448
|
});
|
|
6269
6449
|
};
|
|
6270
6450
|
|
|
6451
|
+
const getSavedTab = tab => {
|
|
6452
|
+
const normalizedTab = normalizeTabEditorInput(tab);
|
|
6453
|
+
const {
|
|
6454
|
+
errorMessage: _errorMessage,
|
|
6455
|
+
loadingState: _loadingState,
|
|
6456
|
+
...rest
|
|
6457
|
+
} = normalizedTab;
|
|
6458
|
+
return {
|
|
6459
|
+
...rest,
|
|
6460
|
+
editorUid: -1
|
|
6461
|
+
};
|
|
6462
|
+
};
|
|
6271
6463
|
const getFilteredGroups = groups => {
|
|
6272
6464
|
return groups.map(group => {
|
|
6273
|
-
const tabs = group.tabs.filter(tab => !tab.uri?.startsWith('untitled://')).map(
|
|
6465
|
+
const tabs = group.tabs.filter(tab => !tab.uri?.startsWith('untitled://')).map(getSavedTab);
|
|
6274
6466
|
const activeTabId = tabs.some(tab => tab.id === group.activeTabId) ? group.activeTabId : tabs[0]?.id;
|
|
6275
6467
|
return {
|
|
6276
6468
|
...group,
|
|
@@ -6610,99 +6802,99 @@ const splitUp = (state, groupId) => {
|
|
|
6610
6802
|
};
|
|
6611
6803
|
|
|
6612
6804
|
const commandMap = {
|
|
6613
|
-
'Main.closeActiveEditor':
|
|
6614
|
-
'Main.closeAll':
|
|
6615
|
-
'Main.closeAllEditors':
|
|
6616
|
-
'Main.closeFocusedTab':
|
|
6617
|
-
'Main.closeOthers':
|
|
6618
|
-
'Main.closeSaved':
|
|
6619
|
-
'Main.closeTabsByUris':
|
|
6620
|
-
'Main.closeTabsRight':
|
|
6621
|
-
'Main.copyPath':
|
|
6622
|
-
'Main.copyRelativePath':
|
|
6623
|
-
'Main.focusNext':
|
|
6624
|
-
'Main.focusNextTab':
|
|
6625
|
-
'Main.focusPrevious':
|
|
6626
|
-
'Main.focusPreviousTab':
|
|
6627
|
-
'Main.handleModifiedStatusChange':
|
|
6628
|
-
'Main.handleTabContextMenu':
|
|
6805
|
+
'Main.closeActiveEditor': wrapSerialCommand(closeActiveEditor),
|
|
6806
|
+
'Main.closeAll': wrapSerialCommand(closeAll$1),
|
|
6807
|
+
'Main.closeAllEditors': wrapSerialCommand(closeAll$1),
|
|
6808
|
+
'Main.closeFocusedTab': wrapSerialCommand(closeFocusedTab),
|
|
6809
|
+
'Main.closeOthers': wrapSerialCommand(closeOtherTabs),
|
|
6810
|
+
'Main.closeSaved': wrapSerialCommand(closeSaved$1),
|
|
6811
|
+
'Main.closeTabsByUris': wrapSerialCommand(closeTabsByUris),
|
|
6812
|
+
'Main.closeTabsRight': wrapSerialCommand(closeTabsRight),
|
|
6813
|
+
'Main.copyPath': wrapSerialCommand(copyPath$1),
|
|
6814
|
+
'Main.copyRelativePath': wrapSerialCommand(copyRelativePath$1),
|
|
6815
|
+
'Main.focusNext': wrapSerialCommand(focusNextTab),
|
|
6816
|
+
'Main.focusNextTab': wrapSerialCommand(focusNextTab),
|
|
6817
|
+
'Main.focusPrevious': wrapSerialCommand(focusPreviousTab),
|
|
6818
|
+
'Main.focusPreviousTab': wrapSerialCommand(focusPreviousTab),
|
|
6819
|
+
'Main.handleModifiedStatusChange': wrapAsyncCommand(handleModifiedStatusChangeWithContext),
|
|
6820
|
+
'Main.handleTabContextMenu': wrapSerialCommand(handleTabContextMenu),
|
|
6629
6821
|
'Main.hasActiveTextEditor': wrapGetter(hasActiveTextEditor),
|
|
6630
|
-
'Main.openInput':
|
|
6631
|
-
'Main.openUri':
|
|
6632
|
-
'Main.openUris':
|
|
6633
|
-
'Main.restoreClosedTab':
|
|
6634
|
-
'Main.save':
|
|
6822
|
+
'Main.openInput': wrapSerialAsyncCommand(openInputWithContext),
|
|
6823
|
+
'Main.openUri': wrapSerialAsyncCommand(openUriWithContext),
|
|
6824
|
+
'Main.openUris': wrapSerialAsyncCommand(openUrisWithContext),
|
|
6825
|
+
'Main.restoreClosedTab': wrapSerialCommand(restoreClosedTab),
|
|
6826
|
+
'Main.save': wrapSerialCommand(save),
|
|
6635
6827
|
'Main.saveState': wrapGetter(saveState),
|
|
6636
|
-
'Main.splitRight':
|
|
6637
|
-
'MainArea.closeActiveEditor':
|
|
6638
|
-
'MainArea.closeAll':
|
|
6639
|
-
'MainArea.closeAllEditors':
|
|
6640
|
-
'MainArea.closeEditorGroup':
|
|
6641
|
-
'MainArea.closeFocusedTab':
|
|
6642
|
-
'MainArea.closeOthers':
|
|
6643
|
-
'MainArea.closeSaved':
|
|
6644
|
-
'MainArea.closeTabsByUris':
|
|
6645
|
-
'MainArea.closeTabsRight':
|
|
6646
|
-
'MainArea.copyIntoNewWindow':
|
|
6647
|
-
'MainArea.copyPath':
|
|
6648
|
-
'MainArea.copyRelativePath':
|
|
6828
|
+
'Main.splitRight': wrapSerialCommand(splitRight),
|
|
6829
|
+
'MainArea.closeActiveEditor': wrapSerialCommand(closeActiveEditor),
|
|
6830
|
+
'MainArea.closeAll': wrapSerialCommand(closeAll$1),
|
|
6831
|
+
'MainArea.closeAllEditors': wrapSerialCommand(closeAll$1),
|
|
6832
|
+
'MainArea.closeEditorGroup': wrapSerialCommand(closeEditorGroup$1),
|
|
6833
|
+
'MainArea.closeFocusedTab': wrapSerialCommand(closeFocusedTab),
|
|
6834
|
+
'MainArea.closeOthers': wrapSerialCommand(closeOtherTabs),
|
|
6835
|
+
'MainArea.closeSaved': wrapSerialCommand(closeSaved$1),
|
|
6836
|
+
'MainArea.closeTabsByUris': wrapSerialCommand(closeTabsByUris),
|
|
6837
|
+
'MainArea.closeTabsRight': wrapSerialCommand(closeTabsRight),
|
|
6838
|
+
'MainArea.copyIntoNewWindow': wrapSerialCommand(copyIntoNewWindow$1),
|
|
6839
|
+
'MainArea.copyPath': wrapSerialCommand(copyPath$1),
|
|
6840
|
+
'MainArea.copyRelativePath': wrapSerialCommand(copyRelativePath$1),
|
|
6649
6841
|
'MainArea.create': create$2,
|
|
6650
6842
|
'MainArea.diff2': diff2,
|
|
6651
|
-
'MainArea.flipEditorLayout':
|
|
6652
|
-
'MainArea.focusNext':
|
|
6653
|
-
'MainArea.focusNextTab':
|
|
6654
|
-
'MainArea.focusPrevious':
|
|
6655
|
-
'MainArea.focusPreviousTab':
|
|
6843
|
+
'MainArea.flipEditorLayout': wrapSerialCommand(flipLayout),
|
|
6844
|
+
'MainArea.focusNext': wrapSerialCommand(focusNextTab),
|
|
6845
|
+
'MainArea.focusNextTab': wrapSerialCommand(focusNextTab),
|
|
6846
|
+
'MainArea.focusPrevious': wrapSerialCommand(focusPreviousTab),
|
|
6847
|
+
'MainArea.focusPreviousTab': wrapSerialCommand(focusPreviousTab),
|
|
6656
6848
|
'MainArea.getCommandIds': getCommandIds,
|
|
6657
6849
|
'MainArea.getMenuEntries': wrapGetter(getMenuEntries),
|
|
6658
6850
|
'MainArea.getMenuIds': getMenuIds,
|
|
6659
|
-
'MainArea.handleClick':
|
|
6660
|
-
'MainArea.handleClickAction':
|
|
6661
|
-
'MainArea.handleClickCloseTab':
|
|
6662
|
-
'MainArea.handleClickTab':
|
|
6663
|
-
'MainArea.handleClickTogglePreview':
|
|
6664
|
-
'MainArea.handleContextMenu':
|
|
6665
|
-
'MainArea.handleDoubleClick':
|
|
6666
|
-
'MainArea.handleHeaderDoubleClick':
|
|
6667
|
-
'MainArea.handleIconThemeChange':
|
|
6668
|
-
'MainArea.handleModifiedStatusChange':
|
|
6851
|
+
'MainArea.handleClick': wrapSerialCommand(handleClick),
|
|
6852
|
+
'MainArea.handleClickAction': wrapSerialCommand(handleClickAction),
|
|
6853
|
+
'MainArea.handleClickCloseTab': wrapSerialCommand(handleClickCloseTab),
|
|
6854
|
+
'MainArea.handleClickTab': wrapSerialCommand(handleClickTab),
|
|
6855
|
+
'MainArea.handleClickTogglePreview': wrapSerialCommand(handleClickTogglePreview),
|
|
6856
|
+
'MainArea.handleContextMenu': wrapSerialCommand(handleContextMenu),
|
|
6857
|
+
'MainArea.handleDoubleClick': wrapSerialCommand(handleDoubleClick),
|
|
6858
|
+
'MainArea.handleHeaderDoubleClick': wrapSerialCommand(handleHeaderDoubleClick),
|
|
6859
|
+
'MainArea.handleIconThemeChange': wrapSerialCommand(handleIconThemeChange),
|
|
6860
|
+
'MainArea.handleModifiedStatusChange': wrapAsyncCommand(handleModifiedStatusChangeWithContext),
|
|
6669
6861
|
'MainArea.handleResize': wrapGetter(handleResize),
|
|
6670
6862
|
// TODO would need to have a function that returns newstate as well as commands
|
|
6671
|
-
'MainArea.handleSashPointerDown':
|
|
6672
|
-
'MainArea.handleSashPointerMove':
|
|
6673
|
-
'MainArea.handleSashPointerUp':
|
|
6674
|
-
'MainArea.handleTabContextMenu':
|
|
6675
|
-
'MainArea.handleUriChange':
|
|
6676
|
-
'MainArea.handleWorkspaceChange':
|
|
6863
|
+
'MainArea.handleSashPointerDown': wrapSerialCommand(handleSashPointerDown),
|
|
6864
|
+
'MainArea.handleSashPointerMove': wrapSerialCommand(handleSashPointerMove),
|
|
6865
|
+
'MainArea.handleSashPointerUp': wrapSerialCommand(handleSashPointerUp),
|
|
6866
|
+
'MainArea.handleTabContextMenu': wrapSerialCommand(handleTabContextMenu),
|
|
6867
|
+
'MainArea.handleUriChange': wrapSerialCommand(handleUriChange),
|
|
6868
|
+
'MainArea.handleWorkspaceChange': wrapSerialCommand(handleWorkspaceChange),
|
|
6677
6869
|
'MainArea.hasActiveTextEditor': wrapGetter(hasActiveTextEditor),
|
|
6678
6870
|
'MainArea.initialize': initialize,
|
|
6679
|
-
'MainArea.loadContent':
|
|
6680
|
-
'MainArea.moveIntoNewWindow':
|
|
6681
|
-
'MainArea.newFile':
|
|
6682
|
-
'MainArea.newWindow':
|
|
6683
|
-
'MainArea.openInput':
|
|
6684
|
-
'MainArea.openUri':
|
|
6685
|
-
'MainArea.openUris':
|
|
6686
|
-
'MainArea.refresh':
|
|
6871
|
+
'MainArea.loadContent': wrapSerialCommand(loadContent),
|
|
6872
|
+
'MainArea.moveIntoNewWindow': wrapSerialCommand(moveIntoNewWindow),
|
|
6873
|
+
'MainArea.newFile': wrapSerialCommand(newFile),
|
|
6874
|
+
'MainArea.newWindow': wrapSerialCommand(newWindow),
|
|
6875
|
+
'MainArea.openInput': wrapSerialAsyncCommand(openInputWithContext),
|
|
6876
|
+
'MainArea.openUri': wrapSerialAsyncCommand(openUriWithContext),
|
|
6877
|
+
'MainArea.openUris': wrapSerialAsyncCommand(openUrisWithContext),
|
|
6878
|
+
'MainArea.refresh': wrapSerialCommand(refresh),
|
|
6687
6879
|
'MainArea.render2': render2,
|
|
6688
6880
|
'MainArea.renderEventListeners': renderEventListeners,
|
|
6689
6881
|
'MainArea.resize': wrapGetter(handleResize),
|
|
6690
|
-
'MainArea.restoreClosedTab':
|
|
6691
|
-
'MainArea.save':
|
|
6882
|
+
'MainArea.restoreClosedTab': wrapSerialCommand(restoreClosedTab),
|
|
6883
|
+
'MainArea.save': wrapSerialCommand(save),
|
|
6692
6884
|
'MainArea.saveState': wrapGetter(saveState),
|
|
6693
|
-
'MainArea.selectTab':
|
|
6694
|
-
'MainArea.setEditorLayoutGrid':
|
|
6695
|
-
'MainArea.setEditorLayoutSingle':
|
|
6696
|
-
'MainArea.setEditorLayoutThreeColumns':
|
|
6697
|
-
'MainArea.setEditorLayoutThreeRows':
|
|
6698
|
-
'MainArea.setEditorLayoutTwoColumns':
|
|
6699
|
-
'MainArea.setEditorLayoutTwoColumnsBottom':
|
|
6700
|
-
'MainArea.setEditorLayoutTwoRows':
|
|
6701
|
-
'MainArea.setEditorLayoutTwoRowsRight':
|
|
6702
|
-
'MainArea.splitDown':
|
|
6703
|
-
'MainArea.splitLeft':
|
|
6704
|
-
'MainArea.splitRight':
|
|
6705
|
-
'MainArea.splitUp':
|
|
6885
|
+
'MainArea.selectTab': wrapSerialCommand(selectTab),
|
|
6886
|
+
'MainArea.setEditorLayoutGrid': wrapSerialCommand(setEditorLayoutGrid),
|
|
6887
|
+
'MainArea.setEditorLayoutSingle': wrapSerialCommand(setEditorLayoutSingle),
|
|
6888
|
+
'MainArea.setEditorLayoutThreeColumns': wrapSerialCommand(setEditorLayoutThreeColumns),
|
|
6889
|
+
'MainArea.setEditorLayoutThreeRows': wrapSerialCommand(setEditorLayoutThreeRows),
|
|
6890
|
+
'MainArea.setEditorLayoutTwoColumns': wrapSerialCommand(setEditorLayoutTwoColumns),
|
|
6891
|
+
'MainArea.setEditorLayoutTwoColumnsBottom': wrapSerialCommand(setEditorLayoutTwoColumnsBottom),
|
|
6892
|
+
'MainArea.setEditorLayoutTwoRows': wrapSerialCommand(setEditorLayoutTwoRows),
|
|
6893
|
+
'MainArea.setEditorLayoutTwoRowsRight': wrapSerialCommand(setEditorLayoutTwoRowsRight),
|
|
6894
|
+
'MainArea.splitDown': wrapSerialCommand(splitDown),
|
|
6895
|
+
'MainArea.splitLeft': wrapSerialCommand(splitLeft),
|
|
6896
|
+
'MainArea.splitRight': wrapSerialCommand(splitRight),
|
|
6897
|
+
'MainArea.splitUp': wrapSerialCommand(splitUp),
|
|
6706
6898
|
'MainArea.terminate': terminate
|
|
6707
6899
|
};
|
|
6708
6900
|
|