@lvce-editor/main-area-worker 9.6.0 → 9.7.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 +60 -6
- package/package.json +1 -1
|
@@ -3041,14 +3041,67 @@ const getOptionUriOptions = options => {
|
|
|
3041
3041
|
return options.uri;
|
|
3042
3042
|
};
|
|
3043
3043
|
|
|
3044
|
+
const getEditorInputFromUri = uri => {
|
|
3045
|
+
if (uri.startsWith('diff://?')) {
|
|
3046
|
+
try {
|
|
3047
|
+
const parsed = new URL(uri);
|
|
3048
|
+
const uriLeft = parsed.searchParams.get('left');
|
|
3049
|
+
const uriRight = parsed.searchParams.get('right');
|
|
3050
|
+
if (uriLeft && uriRight) {
|
|
3051
|
+
return {
|
|
3052
|
+
type: 'diff-editor',
|
|
3053
|
+
uriLeft,
|
|
3054
|
+
uriRight
|
|
3055
|
+
};
|
|
3056
|
+
}
|
|
3057
|
+
} catch {
|
|
3058
|
+
// Ignore malformed legacy URIs and fall back to a text editor input.
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
if (uri.startsWith('extension-detail://')) {
|
|
3062
|
+
const extensionIdWithPath = uri.slice('extension-detail://'.length);
|
|
3063
|
+
const extensionId = extensionIdWithPath.split('/')[0];
|
|
3064
|
+
if (extensionId) {
|
|
3065
|
+
return {
|
|
3066
|
+
extensionId,
|
|
3067
|
+
type: 'extension-detail-view'
|
|
3068
|
+
};
|
|
3069
|
+
}
|
|
3070
|
+
}
|
|
3071
|
+
return {
|
|
3072
|
+
type: 'editor',
|
|
3073
|
+
uri
|
|
3074
|
+
};
|
|
3075
|
+
};
|
|
3076
|
+
const getNormalizedEditorInput = tab => {
|
|
3077
|
+
if (typeof tab?.uri === 'string') {
|
|
3078
|
+
const inferredEditorInput = getEditorInputFromUri(tab.uri);
|
|
3079
|
+
if (inferredEditorInput.type !== 'editor') {
|
|
3080
|
+
return inferredEditorInput;
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3083
|
+
return tab?.editorInput;
|
|
3084
|
+
};
|
|
3085
|
+
const normalizeTabEditorInput = tab => {
|
|
3086
|
+
const editorInput = getNormalizedEditorInput(tab);
|
|
3087
|
+
if (!editorInput) {
|
|
3088
|
+
return tab;
|
|
3089
|
+
}
|
|
3090
|
+
return {
|
|
3091
|
+
...tab,
|
|
3092
|
+
editorInput,
|
|
3093
|
+
editorType: getEditorInputEditorType(editorInput)
|
|
3094
|
+
};
|
|
3095
|
+
};
|
|
3096
|
+
const getNormalizedOpenEditorInput = uri => {
|
|
3097
|
+
return getEditorInputFromUri(uri);
|
|
3098
|
+
};
|
|
3099
|
+
|
|
3044
3100
|
const openUri = async (state, options) => {
|
|
3045
3101
|
const uri = getOptionUriOptions(options);
|
|
3046
3102
|
const preview = typeof options === 'string' ? false : options.preview ?? false;
|
|
3047
3103
|
return openInput(state, {
|
|
3048
|
-
editorInput:
|
|
3049
|
-
type: 'editor',
|
|
3050
|
-
uri
|
|
3051
|
-
},
|
|
3104
|
+
editorInput: getNormalizedOpenEditorInput(uri),
|
|
3052
3105
|
focu: typeof options === 'string' ? false : options.focu,
|
|
3053
3106
|
preview
|
|
3054
3107
|
});
|
|
@@ -3769,8 +3822,9 @@ const normalizeRestoredTab = tab => {
|
|
|
3769
3822
|
loadingState: _loadingState,
|
|
3770
3823
|
...rest
|
|
3771
3824
|
} = tab ?? {};
|
|
3825
|
+
const normalizedTab = normalizeTabEditorInput(rest);
|
|
3772
3826
|
return {
|
|
3773
|
-
...
|
|
3827
|
+
...normalizedTab,
|
|
3774
3828
|
editorUid: -1,
|
|
3775
3829
|
isDirty: false,
|
|
3776
3830
|
isPreview: typeof tab?.isPreview === 'boolean' ? tab.isPreview : false
|
|
@@ -5205,7 +5259,7 @@ const save = async state => {
|
|
|
5205
5259
|
const getFilteredGroups = groups => {
|
|
5206
5260
|
return groups.map(group => ({
|
|
5207
5261
|
...group,
|
|
5208
|
-
tabs: group.tabs.filter(tab => !tab.uri?.startsWith('untitled://'))
|
|
5262
|
+
tabs: group.tabs.filter(tab => !tab.uri?.startsWith('untitled://')).map(normalizeTabEditorInput)
|
|
5209
5263
|
})).filter(group => group.tabs.length > 0);
|
|
5210
5264
|
};
|
|
5211
5265
|
|