@lvce-editor/editor-worker 19.67.4 → 19.67.5
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/editorWorkerMain.js +35 -3
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -10379,8 +10379,15 @@ const handleTouchMove = (editor, touchEvent) => {
|
|
|
10379
10379
|
};
|
|
10380
10380
|
|
|
10381
10381
|
const handleUriChange = async (editor, newUri) => {
|
|
10382
|
+
const {
|
|
10383
|
+
explicitLanguageId,
|
|
10384
|
+
...state
|
|
10385
|
+
} = editor;
|
|
10382
10386
|
return {
|
|
10383
|
-
...
|
|
10387
|
+
...state,
|
|
10388
|
+
...(editor.uri === newUri && explicitLanguageId && {
|
|
10389
|
+
explicitLanguageId
|
|
10390
|
+
}),
|
|
10384
10391
|
uri: newUri
|
|
10385
10392
|
};
|
|
10386
10393
|
};
|
|
@@ -11927,10 +11934,11 @@ const setIndentation = (editor, insertSpaces) => {
|
|
|
11927
11934
|
};
|
|
11928
11935
|
};
|
|
11929
11936
|
|
|
11930
|
-
const setLanguageId = async (editor, languageId, tokenizePath) => {
|
|
11937
|
+
const setLanguageId = async (editor, languageId, tokenizePath, isExplicit = false) => {
|
|
11931
11938
|
if (editor.largeFile) {
|
|
11932
11939
|
return {
|
|
11933
11940
|
...editor,
|
|
11941
|
+
explicitLanguageId: isExplicit ? languageId : editor.explicitLanguageId,
|
|
11934
11942
|
languageId
|
|
11935
11943
|
};
|
|
11936
11944
|
}
|
|
@@ -11943,6 +11951,7 @@ const setLanguageId = async (editor, languageId, tokenizePath) => {
|
|
|
11943
11951
|
set$3(newTokenizerId, tokenizer);
|
|
11944
11952
|
return {
|
|
11945
11953
|
...editor,
|
|
11954
|
+
explicitLanguageId: isExplicit ? languageId : editor.explicitLanguageId,
|
|
11946
11955
|
focused: true,
|
|
11947
11956
|
invalidStartIndex: 0,
|
|
11948
11957
|
languageId,
|
|
@@ -15087,6 +15096,21 @@ const getSavedHistory = (savedState, content) => {
|
|
|
15087
15096
|
undoStack
|
|
15088
15097
|
};
|
|
15089
15098
|
};
|
|
15099
|
+
const getSavedLanguageId = (savedState, languages) => {
|
|
15100
|
+
if (!savedState || typeof savedState !== 'object') {
|
|
15101
|
+
return undefined;
|
|
15102
|
+
}
|
|
15103
|
+
const {
|
|
15104
|
+
explicitLanguageId
|
|
15105
|
+
} = savedState;
|
|
15106
|
+
if (typeof explicitLanguageId !== 'string' || !explicitLanguageId) {
|
|
15107
|
+
return undefined;
|
|
15108
|
+
}
|
|
15109
|
+
if (languages.every(language => language?.id !== explicitLanguageId)) {
|
|
15110
|
+
return undefined;
|
|
15111
|
+
}
|
|
15112
|
+
return explicitLanguageId;
|
|
15113
|
+
};
|
|
15090
15114
|
const loadContent = async (state, savedState, largeFile = false) => {
|
|
15091
15115
|
const {
|
|
15092
15116
|
assetDir,
|
|
@@ -15128,7 +15152,8 @@ const loadContent = async (state, savedState, largeFile = false) => {
|
|
|
15128
15152
|
const charWidth = await measureCharacterWidth(fontWeight, fontSize, fontFamily, letterSpacing);
|
|
15129
15153
|
const languages = await getLanguages(platform, assetDir);
|
|
15130
15154
|
setTokenizePaths(languages);
|
|
15131
|
-
const
|
|
15155
|
+
const explicitLanguageId = getSavedLanguageId(savedState, languages);
|
|
15156
|
+
const computedLanguageId = explicitLanguageId || getLanguageId$1(uri, languages);
|
|
15132
15157
|
const newEditor0 = {
|
|
15133
15158
|
...state,
|
|
15134
15159
|
breadcrumbsEnabled,
|
|
@@ -15137,6 +15162,9 @@ const loadContent = async (state, savedState, largeFile = false) => {
|
|
|
15137
15162
|
completionTriggerCharacters,
|
|
15138
15163
|
diagnosticsEnabled,
|
|
15139
15164
|
dragAndDropEnabled,
|
|
15165
|
+
...(explicitLanguageId && {
|
|
15166
|
+
explicitLanguageId
|
|
15167
|
+
}),
|
|
15140
15168
|
fontFamily,
|
|
15141
15169
|
fontSize,
|
|
15142
15170
|
fontWeight,
|
|
@@ -16629,12 +16657,16 @@ const revealProblem = (editor, rowIndex, columnIndex) => {
|
|
|
16629
16657
|
|
|
16630
16658
|
const saveState = (state, savedState) => {
|
|
16631
16659
|
const {
|
|
16660
|
+
explicitLanguageId,
|
|
16632
16661
|
largeFile,
|
|
16633
16662
|
lines,
|
|
16634
16663
|
redoStack,
|
|
16635
16664
|
undoStack
|
|
16636
16665
|
} = state;
|
|
16637
16666
|
return {
|
|
16667
|
+
...(explicitLanguageId && {
|
|
16668
|
+
explicitLanguageId
|
|
16669
|
+
}),
|
|
16638
16670
|
...(largeFile && {
|
|
16639
16671
|
largeFile: true
|
|
16640
16672
|
}),
|