@lvce-editor/main-area-worker 9.38.1 → 9.39.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.
@@ -6061,11 +6061,51 @@ const handleWorkspaceChange = async (state, _workspacePath, savedState) => {
6061
6061
  };
6062
6062
  };
6063
6063
 
6064
+ const getEditorInputUris = editorInput => {
6065
+ switch (editorInput?.type) {
6066
+ case 'diff-editor':
6067
+ return [editorInput.uriLeft, editorInput.uriRight];
6068
+ case 'editor':
6069
+ case 'image':
6070
+ case 'video':
6071
+ case 'webview':
6072
+ return [editorInput.uri];
6073
+ default:
6074
+ return [];
6075
+ }
6076
+ };
6077
+ const getChangedEditorUid = (editorUid, editorInput, uri, changedUris) => {
6078
+ if (editorUid === -1) {
6079
+ return undefined;
6080
+ }
6081
+ const uris = getEditorInputUris(editorInput);
6082
+ if (uris.some(editorUri => changedUris.has(editorUri)) || uris.length === 0 && uri && changedUris.has(uri)) {
6083
+ return editorUid;
6084
+ }
6085
+ return undefined;
6086
+ };
6087
+ const reloadChangedEditors = async (state, changed) => {
6088
+ if (changed.length === 0) {
6089
+ return;
6090
+ }
6091
+ const changedUris = new Set(changed);
6092
+ const editorUids = new Set();
6093
+ for (const group of state.layout.groups) {
6094
+ for (const tab of group.tabs) {
6095
+ const editorUid = getChangedEditorUid(tab.editorUid, tab.editorInput, tab.uri, changedUris);
6096
+ if (editorUid !== undefined) {
6097
+ editorUids.add(editorUid);
6098
+ }
6099
+ }
6100
+ }
6101
+ await Promise.allSettled(Array.from(editorUids, editorUid => invoke('Viewlet.reload', editorUid)));
6102
+ };
6064
6103
  const handleWorkspaceRefresh = async (state, refresh = {}) => {
6065
6104
  const changes = Array.isArray(refresh) ? {
6066
6105
  deleted: refresh
6067
6106
  } : refresh;
6068
6107
  const {
6108
+ changed = [],
6069
6109
  deleted = [],
6070
6110
  renamed = []
6071
6111
  } = changes;
@@ -6081,6 +6121,7 @@ const handleWorkspaceRefresh = async (state, refresh = {}) => {
6081
6121
  }
6082
6122
  }
6083
6123
  }
6124
+ await reloadChangedEditors(newState, changed);
6084
6125
  return newState;
6085
6126
  };
6086
6127
  const handleWorkspaceRefreshWithContext = async (context, refresh = {}) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.38.1",
3
+ "version": "9.39.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",