@lvce-editor/main-area-worker 9.68.0 → 9.68.2

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.
@@ -1926,7 +1926,15 @@ const wrapSerialCommand = fn => {
1926
1926
  const state$1 = {
1927
1927
  configured: false,
1928
1928
  lastId: -1,
1929
- nextId: 0
1929
+ nextId: 0,
1930
+ reservedIds: new Set()
1931
+ };
1932
+ const reserve = ids => {
1933
+ for (const id of ids) {
1934
+ if (id >= state$1.nextId && id <= state$1.lastId) {
1935
+ state$1.reservedIds.add(id);
1936
+ }
1937
+ }
1930
1938
  };
1931
1939
  const configure = (start, end) => {
1932
1940
  const {
@@ -1946,13 +1954,16 @@ const create$2 = () => {
1946
1954
  const {
1947
1955
  configured,
1948
1956
  lastId,
1949
- nextId
1957
+ reservedIds
1950
1958
  } = state$1;
1951
1959
  if (!configured) {
1952
1960
  // Compatibility with renderer versions that do not assign worker id ranges.
1953
1961
  return Math.random();
1954
1962
  }
1955
- if (nextId > lastId) {
1963
+ while (reservedIds.delete(state$1.nextId)) {
1964
+ state$1.nextId++;
1965
+ }
1966
+ if (state$1.nextId > lastId) {
1956
1967
  throw new Error('Component id range exhausted');
1957
1968
  }
1958
1969
  return state$1.nextId++;
@@ -2895,6 +2906,15 @@ const focus = async state => {
2895
2906
  if (typeof editorUid !== 'number' || editorUid < 0) {
2896
2907
  return state;
2897
2908
  }
2909
+ if (activeTab?.tab.uri?.startsWith('search-editor://')) {
2910
+ if (isConnected()) {
2911
+ await invoke$1(state.applicationId, 'Layout.renderMainAreaPending', state.uid);
2912
+ await invoke('Viewlet.focus', editorUid);
2913
+ } else {
2914
+ await invoke$2('Viewlet.focus', editorUid);
2915
+ }
2916
+ return state;
2917
+ }
2898
2918
  const selector = activeTab?.tab.terminal ? '.xterm-helper-textarea' : '[name="editor"]';
2899
2919
  if (isConnected()) {
2900
2920
  await invoke$1(state.applicationId, 'Layout.renderMainAreaPending', state.uid);
@@ -7864,6 +7884,9 @@ const updateTabs = (state, editorUids) => {
7864
7884
  };
7865
7885
 
7866
7886
  const restoreAndCreateEditors = async (state, restoredLayout) => {
7887
+ // Saved tab/group IDs can overlap the range assigned to a fresh renderer.
7888
+ // Reserve them before creating editors or opening any additional tabs.
7889
+ reserve(restoredLayout.groups.flatMap(group => [group.id, ...group.tabs.map(tab => tab.id)]));
7867
7890
  let newState = {
7868
7891
  ...state,
7869
7892
  layout: restoredLayout
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.68.0",
3
+ "version": "9.68.2",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",