@lvce-editor/main-area-worker 9.29.0 → 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 +37 -11
- package/package.json +1 -1
|
@@ -4839,23 +4839,39 @@ const handleUriChange = async (state, oldUri, newUri) => {
|
|
|
4839
4839
|
const {
|
|
4840
4840
|
groups
|
|
4841
4841
|
} = layout;
|
|
4842
|
-
const
|
|
4842
|
+
const editorUriUpdates = [];
|
|
4843
4843
|
const updatedGroups = groups.map(group => {
|
|
4844
4844
|
return {
|
|
4845
4845
|
...group,
|
|
4846
4846
|
tabs: group.tabs.map(tab => {
|
|
4847
|
-
|
|
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;
|
|
4848
4862
|
return {
|
|
4849
4863
|
...tab,
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4864
|
+
editorInput,
|
|
4865
|
+
title: getLabel(renamedUri),
|
|
4866
|
+
uri: renamedUri,
|
|
4867
|
+
uriTitle: getUriTitle(renamedUri, state.homeDirUri || '')
|
|
4853
4868
|
};
|
|
4854
4869
|
}
|
|
4855
4870
|
return tab;
|
|
4856
4871
|
})
|
|
4857
4872
|
};
|
|
4858
4873
|
});
|
|
4874
|
+
await Promise.all(editorUriUpdates);
|
|
4859
4875
|
const stateWithUpdatedUri = {
|
|
4860
4876
|
...state,
|
|
4861
4877
|
layout: {
|
|
@@ -5135,21 +5151,31 @@ const handleWorkspaceChange = async (state, _workspacePath, savedState) => {
|
|
|
5135
5151
|
return loadContent(state, savedState);
|
|
5136
5152
|
};
|
|
5137
5153
|
|
|
5138
|
-
const handleWorkspaceRefresh = async (state,
|
|
5139
|
-
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;
|
|
5140
5162
|
let newState = state;
|
|
5141
|
-
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) {
|
|
5142
5168
|
for (const tab of group.tabs) {
|
|
5143
|
-
if (tab.editorInput?.type === 'editor' &&
|
|
5169
|
+
if (tab.editorInput?.type === 'editor' && deletedUris.has(tab.editorInput.uri)) {
|
|
5144
5170
|
newState = await closeTabWithViewlet(newState, group.id, tab.id);
|
|
5145
5171
|
}
|
|
5146
5172
|
}
|
|
5147
5173
|
}
|
|
5148
5174
|
return newState;
|
|
5149
5175
|
};
|
|
5150
|
-
const handleWorkspaceRefreshWithContext = async (context,
|
|
5176
|
+
const handleWorkspaceRefreshWithContext = async (context, refresh = {}) => {
|
|
5151
5177
|
const state = context.getState();
|
|
5152
|
-
const newState = await handleWorkspaceRefresh(state,
|
|
5178
|
+
const newState = await handleWorkspaceRefresh(state, refresh);
|
|
5153
5179
|
await context.updateState(() => newState);
|
|
5154
5180
|
};
|
|
5155
5181
|
|