@lvce-editor/main-area-worker 9.29.1 → 9.30.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 +36 -19
- package/package.json +1 -1
|
@@ -4839,32 +4839,39 @@ const handleUriChange = async (state, oldUri, newUri) => {
|
|
|
4839
4839
|
const {
|
|
4840
4840
|
groups
|
|
4841
4841
|
} = layout;
|
|
4842
|
-
const newTitle = getLabel(newUri);
|
|
4843
4842
|
const editorUriUpdates = [];
|
|
4844
|
-
for (const group of groups) {
|
|
4845
|
-
for (const tab of group.tabs) {
|
|
4846
|
-
if (tab.uri === oldUri && tab.editorType === 'text' && tab.editorUid !== -1) {
|
|
4847
|
-
editorUriUpdates.push(invoke('Editor.handleUriChange', tab.editorUid, newUri));
|
|
4848
|
-
}
|
|
4849
|
-
}
|
|
4850
|
-
}
|
|
4851
|
-
await Promise.all(editorUriUpdates);
|
|
4852
4843
|
const updatedGroups = groups.map(group => {
|
|
4853
4844
|
return {
|
|
4854
4845
|
...group,
|
|
4855
4846
|
tabs: group.tabs.map(tab => {
|
|
4856
|
-
|
|
4847
|
+
const uri = tab.uri || '';
|
|
4848
|
+
let renamedUri = '';
|
|
4849
|
+
if (uri === oldUri) {
|
|
4850
|
+
renamedUri = newUri;
|
|
4851
|
+
} else if (uri.startsWith(`${oldUri}/`) || uri.startsWith(`${oldUri}\\`)) {
|
|
4852
|
+
renamedUri = `${newUri}${uri.slice(oldUri.length)}`;
|
|
4853
|
+
}
|
|
4854
|
+
if (renamedUri) {
|
|
4855
|
+
if (tab.editorType === 'text' && tab.editorUid !== -1) {
|
|
4856
|
+
editorUriUpdates.push(invoke('Editor.handleUriChange', tab.editorUid, renamedUri));
|
|
4857
|
+
}
|
|
4858
|
+
const editorInput = tab.editorInput && 'uri' in tab.editorInput ? {
|
|
4859
|
+
...tab.editorInput,
|
|
4860
|
+
uri: renamedUri
|
|
4861
|
+
} : tab.editorInput;
|
|
4857
4862
|
return {
|
|
4858
4863
|
...tab,
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4864
|
+
editorInput,
|
|
4865
|
+
title: getLabel(renamedUri),
|
|
4866
|
+
uri: renamedUri,
|
|
4867
|
+
uriTitle: getUriTitle(renamedUri, state.homeDirUri || '')
|
|
4862
4868
|
};
|
|
4863
4869
|
}
|
|
4864
4870
|
return tab;
|
|
4865
4871
|
})
|
|
4866
4872
|
};
|
|
4867
4873
|
});
|
|
4874
|
+
await Promise.all(editorUriUpdates);
|
|
4868
4875
|
const stateWithUpdatedUri = {
|
|
4869
4876
|
...state,
|
|
4870
4877
|
layout: {
|
|
@@ -5144,21 +5151,31 @@ const handleWorkspaceChange = async (state, _workspacePath, savedState) => {
|
|
|
5144
5151
|
return loadContent(state, savedState);
|
|
5145
5152
|
};
|
|
5146
5153
|
|
|
5147
|
-
const handleWorkspaceRefresh = async (state,
|
|
5148
|
-
const
|
|
5154
|
+
const handleWorkspaceRefresh = async (state, refresh = {}) => {
|
|
5155
|
+
const changes = Array.isArray(refresh) ? {
|
|
5156
|
+
deleted: refresh
|
|
5157
|
+
} : refresh;
|
|
5158
|
+
const {
|
|
5159
|
+
deleted = [],
|
|
5160
|
+
renamed = []
|
|
5161
|
+
} = changes;
|
|
5149
5162
|
let newState = state;
|
|
5150
|
-
for (const
|
|
5163
|
+
for (const [oldUri, newUri] of renamed) {
|
|
5164
|
+
newState = await handleUriChange(newState, oldUri, newUri);
|
|
5165
|
+
}
|
|
5166
|
+
const deletedUris = new Set(deleted);
|
|
5167
|
+
for (const group of newState.layout.groups) {
|
|
5151
5168
|
for (const tab of group.tabs) {
|
|
5152
|
-
if (tab.editorInput?.type === 'editor' &&
|
|
5169
|
+
if (tab.editorInput?.type === 'editor' && deletedUris.has(tab.editorInput.uri)) {
|
|
5153
5170
|
newState = await closeTabWithViewlet(newState, group.id, tab.id);
|
|
5154
5171
|
}
|
|
5155
5172
|
}
|
|
5156
5173
|
}
|
|
5157
5174
|
return newState;
|
|
5158
5175
|
};
|
|
5159
|
-
const handleWorkspaceRefreshWithContext = async (context,
|
|
5176
|
+
const handleWorkspaceRefreshWithContext = async (context, refresh = {}) => {
|
|
5160
5177
|
const state = context.getState();
|
|
5161
|
-
const newState = await handleWorkspaceRefresh(state,
|
|
5178
|
+
const newState = await handleWorkspaceRefresh(state, refresh);
|
|
5162
5179
|
await context.updateState(() => newState);
|
|
5163
5180
|
};
|
|
5164
5181
|
|