@lvce-editor/editor-worker 19.74.2 → 19.74.4
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 +66 -42
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1478,7 +1478,7 @@ const sendMessagePortToExtensionManagementWorker$1 = async (port, rpcId) => {
|
|
|
1478
1478
|
const command = 'Extensions.handleMessagePort';
|
|
1479
1479
|
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
1480
1480
|
};
|
|
1481
|
-
const getPreference = async key => {
|
|
1481
|
+
const getPreference$1 = async key => {
|
|
1482
1482
|
return await invoke$d('Preferences.get', key);
|
|
1483
1483
|
};
|
|
1484
1484
|
const openUri = async (uri, focus, options) => {
|
|
@@ -6630,8 +6630,8 @@ const applyLineEndings = (content, endOfLine) => {
|
|
|
6630
6630
|
return endOfLine === Crlf ? normalizeLineEndings(content).replaceAll('\n', '\r\n') : normalizeLineEndings(content);
|
|
6631
6631
|
};
|
|
6632
6632
|
|
|
6633
|
-
const get$3 = async key => {
|
|
6634
|
-
const value = await getPreference(key);
|
|
6633
|
+
const get$3 = async (key, applicationId) => {
|
|
6634
|
+
const value = applicationId === undefined ? await getPreference$1(key) : await invoke$9(applicationId, 'Preferences.get', key);
|
|
6635
6635
|
return value;
|
|
6636
6636
|
};
|
|
6637
6637
|
const update = async settings => {
|
|
@@ -16863,6 +16863,7 @@ const getBreadcrumbFileIcon = async (uri, applicationId) => {
|
|
|
16863
16863
|
}
|
|
16864
16864
|
};
|
|
16865
16865
|
|
|
16866
|
+
const getPreference = (key, applicationId) => applicationId === undefined ? get$3(key) : get$3(key, applicationId);
|
|
16866
16867
|
const kLineHeight = 'editor.lineHeight';
|
|
16867
16868
|
const kFontSize = 'editor.fontSize';
|
|
16868
16869
|
const kFontFamily = 'editor.fontFamily';
|
|
@@ -16887,20 +16888,20 @@ const warnIfChanged = (setting, value, bound, direction) => {
|
|
|
16887
16888
|
lastWarnings.set(setting, value);
|
|
16888
16889
|
warn(`[editor-worker] ${setting} value ${value} is too ${direction}; using ${bound}`);
|
|
16889
16890
|
};
|
|
16890
|
-
const isAutoClosingBracketsEnabled = async
|
|
16891
|
-
return Boolean(await
|
|
16891
|
+
const isAutoClosingBracketsEnabled = async applicationId => {
|
|
16892
|
+
return Boolean(await getPreference(kAutoClosingBrackets, applicationId));
|
|
16892
16893
|
};
|
|
16893
|
-
const isAutoClosingQuotesEnabled = async
|
|
16894
|
-
return Boolean(await
|
|
16894
|
+
const isAutoClosingQuotesEnabled = async applicationId => {
|
|
16895
|
+
return Boolean(await getPreference(kAutoClosingQuotes, applicationId));
|
|
16895
16896
|
};
|
|
16896
|
-
const isQuickSuggestionsEnabled = async
|
|
16897
|
-
return Boolean(await
|
|
16897
|
+
const isQuickSuggestionsEnabled = async applicationId => {
|
|
16898
|
+
return Boolean(await getPreference(kQuickSuggestions, applicationId));
|
|
16898
16899
|
};
|
|
16899
16900
|
const isAutoClosingTagsEnabled = async () => {
|
|
16900
16901
|
return true;
|
|
16901
16902
|
};
|
|
16902
|
-
const getRowHeight = async
|
|
16903
|
-
const [lineHeight, fontSize] = await Promise.all([
|
|
16903
|
+
const getRowHeight = async applicationId => {
|
|
16904
|
+
const [lineHeight, fontSize] = await Promise.all([getPreference(kLineHeight, applicationId), getFontSize(applicationId)]);
|
|
16904
16905
|
if (typeof lineHeight !== 'number' || !Number.isFinite(lineHeight) || lineHeight === 0) {
|
|
16905
16906
|
lastWarnings.delete(kLineHeight);
|
|
16906
16907
|
return fontSize;
|
|
@@ -16916,8 +16917,8 @@ const getRowHeight = async () => {
|
|
|
16916
16917
|
lastWarnings.delete(kLineHeight);
|
|
16917
16918
|
return lineHeight;
|
|
16918
16919
|
};
|
|
16919
|
-
const getFontSize = async
|
|
16920
|
-
const fontSize = await
|
|
16920
|
+
const getFontSize = async applicationId => {
|
|
16921
|
+
const fontSize = await getPreference(kFontSize, applicationId);
|
|
16921
16922
|
if (typeof fontSize !== 'number' || !Number.isFinite(fontSize)) {
|
|
16922
16923
|
lastWarnings.delete(kFontSize);
|
|
16923
16924
|
return 15;
|
|
@@ -16933,35 +16934,35 @@ const getFontSize = async () => {
|
|
|
16933
16934
|
lastWarnings.delete(kFontSize);
|
|
16934
16935
|
return fontSize;
|
|
16935
16936
|
};
|
|
16936
|
-
const getFontFamily = async
|
|
16937
|
-
return (await
|
|
16937
|
+
const getFontFamily = async applicationId => {
|
|
16938
|
+
return (await getPreference(kFontFamily, applicationId)) || 'Fira Code';
|
|
16938
16939
|
};
|
|
16939
|
-
const getLetterSpacing = async
|
|
16940
|
+
const getLetterSpacing = async applicationId => {
|
|
16940
16941
|
// if (!false) {
|
|
16941
16942
|
// return 0
|
|
16942
16943
|
// }
|
|
16943
|
-
return (await
|
|
16944
|
+
return (await getPreference(kLetterSpacing, applicationId)) ?? 0.5;
|
|
16944
16945
|
};
|
|
16945
|
-
const getTabSize = async
|
|
16946
|
-
return (await
|
|
16946
|
+
const getTabSize = async applicationId => {
|
|
16947
|
+
return (await getPreference(kTabSize, applicationId)) || 2;
|
|
16947
16948
|
};
|
|
16948
|
-
const getLineNumbers = async
|
|
16949
|
-
return (await
|
|
16949
|
+
const getLineNumbers = async applicationId => {
|
|
16950
|
+
return (await getPreference(kLineNumbers, applicationId)) ?? false;
|
|
16950
16951
|
};
|
|
16951
|
-
const getHighlightActiveLineNumber = async
|
|
16952
|
-
return (await
|
|
16952
|
+
const getHighlightActiveLineNumber = async applicationId => {
|
|
16953
|
+
return (await getPreference(kHighlightActiveLineNumber, applicationId)) ?? true;
|
|
16953
16954
|
};
|
|
16954
16955
|
const getCompletionTriggerCharacters = async () => {
|
|
16955
16956
|
return ['.', '/'];
|
|
16956
16957
|
};
|
|
16957
|
-
const getFontWeight = async
|
|
16958
|
-
return (await
|
|
16958
|
+
const getFontWeight = async applicationId => {
|
|
16959
|
+
return (await getPreference(kFontWeight, applicationId)) ?? 400;
|
|
16959
16960
|
};
|
|
16960
|
-
const getMinimapEnabled = async
|
|
16961
|
-
return (await
|
|
16961
|
+
const getMinimapEnabled = async applicationId => {
|
|
16962
|
+
return (await getPreference(kMinimapEnabled, applicationId)) ?? false;
|
|
16962
16963
|
};
|
|
16963
|
-
const getMergeConflictActionsEnabled = async
|
|
16964
|
-
return (await
|
|
16964
|
+
const getMergeConflictActionsEnabled = async applicationId => {
|
|
16965
|
+
return (await getPreference(kMergeConflictActions, applicationId)) ?? false;
|
|
16965
16966
|
};
|
|
16966
16967
|
|
|
16967
16968
|
const DEFAULT_HOVER_DELAY = 200;
|
|
@@ -16993,8 +16994,8 @@ const getHorizontalVirtualizationThreshold = value => {
|
|
|
16993
16994
|
}
|
|
16994
16995
|
return Math.floor(threshold);
|
|
16995
16996
|
};
|
|
16996
|
-
const getEditorPreferences = async
|
|
16997
|
-
const [diagnosticsEnabled, fontFamily, fontSize, fontWeight, formatOnSave, hoverEnabled, hoverDelay, horizontalVirtualizationThreshold, messageDelay, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, highlightActiveLineNumber, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, mergeConflictActionsEnabled, breadcrumbsEnabled, insertSpaces, dragAndDropEnabled, roundedSelection, combineWhitespaceTokens, selectedTextOccurrenceMatching] = await Promise.all([get$3('editor.diagnostics'), getFontFamily(), getFontSize(), getFontWeight(), get$3('editor.formatOnSave'), get$3('editor.hover'), get$3('editor.hoverDelay'), get$3('editor.horizontalVirtualizationThreshold'), get$3('editor.messageDelay'), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getHighlightActiveLineNumber(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled(), getMergeConflictActionsEnabled(), get$3('breadcrumbs.enabled'), get$3('editor.insertSpaces'), get$3('editor.dragAndDrop'), get$3('editor.roundedSelection'), get$3('editor.combineWhitespaceTokens'), get$3('editor.selectedTextOccurrenceMatching')]);
|
|
16997
|
+
const getEditorPreferences = async applicationId => {
|
|
16998
|
+
const [diagnosticsEnabled, fontFamily, fontSize, fontWeight, formatOnSave, hoverEnabled, hoverDelay, horizontalVirtualizationThreshold, messageDelay, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, highlightActiveLineNumber, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, mergeConflictActionsEnabled, breadcrumbsEnabled, insertSpaces, dragAndDropEnabled, roundedSelection, combineWhitespaceTokens, selectedTextOccurrenceMatching] = await Promise.all([get$3('editor.diagnostics', applicationId), getFontFamily(applicationId), getFontSize(applicationId), getFontWeight(applicationId), get$3('editor.formatOnSave', applicationId), get$3('editor.hover', applicationId), get$3('editor.hoverDelay', applicationId), get$3('editor.horizontalVirtualizationThreshold', applicationId), get$3('editor.messageDelay', applicationId), isAutoClosingBracketsEnabled(applicationId), isAutoClosingQuotesEnabled(applicationId), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(applicationId), getLineNumbers(applicationId), getHighlightActiveLineNumber(applicationId), getRowHeight(applicationId), getTabSize(applicationId), getLetterSpacing(applicationId), getCompletionTriggerCharacters(), getMinimapEnabled(applicationId), getMergeConflictActionsEnabled(applicationId), get$3('breadcrumbs.enabled', applicationId), get$3('editor.insertSpaces', applicationId), get$3('editor.dragAndDrop', applicationId), get$3('editor.roundedSelection', applicationId), get$3('editor.combineWhitespaceTokens', applicationId), get$3('editor.selectedTextOccurrenceMatching', applicationId)]);
|
|
16998
16999
|
return {
|
|
16999
17000
|
breadcrumbsEnabled: breadcrumbsEnabled ?? false,
|
|
17000
17001
|
combineWhitespaceTokens: combineWhitespaceTokens ?? true,
|
|
@@ -17066,7 +17067,7 @@ const updateFindWidget = async state => {
|
|
|
17066
17067
|
};
|
|
17067
17068
|
const handleSettingsChanged = async state => {
|
|
17068
17069
|
const editorPreferences = {
|
|
17069
|
-
...(await getEditorPreferences()),
|
|
17070
|
+
...(await getEditorPreferences(state.applicationId)),
|
|
17070
17071
|
...(state.largeFile && getLargeFilePreferences())
|
|
17071
17072
|
};
|
|
17072
17073
|
const {
|
|
@@ -17079,7 +17080,7 @@ const handleSettingsChanged = async state => {
|
|
|
17079
17080
|
minimapEnabled,
|
|
17080
17081
|
rowHeight
|
|
17081
17082
|
} = editorPreferences;
|
|
17082
|
-
const [charWidth, completionsOnTypeRaw] = await Promise.all([measureCharacterWidth(fontWeight, fontSize, fontFamily, letterSpacing), get$3('editor.completionsOnType')]);
|
|
17083
|
+
const [charWidth, completionsOnTypeRaw] = await Promise.all([measureCharacterWidth(fontWeight, fontSize, fontFamily, letterSpacing), state.applicationId === undefined ? get$3('editor.completionsOnType') : get$3('editor.completionsOnType', state.applicationId)]);
|
|
17083
17084
|
const isMonospaceFont = fontFamily === 'Fira Code' || fontFamily === "'Fira Code'";
|
|
17084
17085
|
const editorWithUpdatedSettings = {
|
|
17085
17086
|
...state,
|
|
@@ -17532,7 +17533,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
17532
17533
|
rowHeight,
|
|
17533
17534
|
selectedTextOccurrenceMatching,
|
|
17534
17535
|
tabSize
|
|
17535
|
-
} = await getEditorPreferences();
|
|
17536
|
+
} = await getEditorPreferences(state.applicationId);
|
|
17536
17537
|
// TODO support overwriting language id by setting it explicitly or via settings
|
|
17537
17538
|
const charWidth = await measureCharacterWidth(fontWeight, fontSize, fontFamily, letterSpacing);
|
|
17538
17539
|
const languages = await getLanguages(platform, assetDir);
|
|
@@ -17666,7 +17667,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
17666
17667
|
horizontalVisibleRanges,
|
|
17667
17668
|
textInfos
|
|
17668
17669
|
};
|
|
17669
|
-
const completionsOnTypeRaw = await get$3('editor.completionsOnType');
|
|
17670
|
+
const completionsOnTypeRaw = state.applicationId === undefined ? await get$3('editor.completionsOnType') : await get$3('editor.completionsOnType', state.applicationId);
|
|
17670
17671
|
const completionsOnType = Boolean(completionsOnTypeRaw);
|
|
17671
17672
|
const newEditor5 = {
|
|
17672
17673
|
...newEditor4,
|
|
@@ -19495,9 +19496,31 @@ const resize = async (editor, dimensions) => {
|
|
|
19495
19496
|
};
|
|
19496
19497
|
const openCompletionDeferred = wrapDeferredCommand(openCompletion);
|
|
19497
19498
|
const updateAutomaticCompletionDeferred = wrapDeferredCommand(updateAutomaticCompletion);
|
|
19498
|
-
const
|
|
19499
|
-
|
|
19499
|
+
const removeHoverFromEditor = editor => {
|
|
19500
|
+
if (!editor.widgets?.some(widget => widget.id === Hover)) {
|
|
19501
|
+
return editor;
|
|
19502
|
+
}
|
|
19503
|
+
const newEditor = {
|
|
19504
|
+
...editor,
|
|
19505
|
+
additionalFocus: 0,
|
|
19506
|
+
focus: FocusEditorText$1,
|
|
19507
|
+
focused: true,
|
|
19508
|
+
widgetRevision: next(editor.uid),
|
|
19509
|
+
widgets: removeEditorWidget(editor.widgets, Hover)
|
|
19510
|
+
};
|
|
19511
|
+
return newEditor;
|
|
19512
|
+
};
|
|
19513
|
+
const wrapTypingCommand = (fn, shouldOpenCompletion, shouldDismissHover, preservesTypingCoalescing = true) => {
|
|
19514
|
+
const command = wrapCommand(async (editor, ...args) => {
|
|
19515
|
+
const newEditor = await fn(editor, ...args);
|
|
19516
|
+
return shouldDismissHover(...args) ? removeHoverFromEditor(newEditor) : newEditor;
|
|
19517
|
+
}, preservesTypingCoalescing);
|
|
19500
19518
|
return async (uid, ...args) => {
|
|
19519
|
+
const dismissHover = shouldDismissHover(...args);
|
|
19520
|
+
if (dismissHover) {
|
|
19521
|
+
clear$2(uid);
|
|
19522
|
+
clear$3(uid);
|
|
19523
|
+
}
|
|
19501
19524
|
await command(uid, ...args);
|
|
19502
19525
|
const editor = get$8(uid)?.newState;
|
|
19503
19526
|
if (editor && (shouldOpenCompletion(...args) && shouldOpenAutomaticCompletion(editor) || editor.widgets?.some(widget => widget.id === Completion && widget.newState.automatic))) {
|
|
@@ -19505,10 +19528,11 @@ const wrapTypingCommand = (fn, shouldOpenCompletion) => {
|
|
|
19505
19528
|
}
|
|
19506
19529
|
};
|
|
19507
19530
|
};
|
|
19508
|
-
const deleteLeftCommand = wrapTypingCommand(deleteCharacterLeft, () => false);
|
|
19509
|
-
const typeCommand = wrapTypingCommand(type, () => true);
|
|
19510
|
-
const typeWithAutoClosingCommand = wrapTypingCommand(typeWithAutoClosing, () => true);
|
|
19511
|
-
const handleBeforeInputCommand = wrapTypingCommand(handleBeforeInput, inputType => inputType === InsertText);
|
|
19531
|
+
const deleteLeftCommand = wrapTypingCommand(deleteCharacterLeft, () => false, () => false);
|
|
19532
|
+
const typeCommand = wrapTypingCommand(type, () => true, Boolean);
|
|
19533
|
+
const typeWithAutoClosingCommand = wrapTypingCommand(typeWithAutoClosing, () => true, Boolean);
|
|
19534
|
+
const handleBeforeInputCommand = wrapTypingCommand(handleBeforeInput, inputType => inputType === InsertText, (inputType, data) => inputType === InsertText && Boolean(data));
|
|
19535
|
+
const handleBeforeInputFromContentEditableCommand = wrapTypingCommand(handleBeforeInputFromContentEditable, () => false, (data, range) => Boolean(data) && Boolean(range), false);
|
|
19512
19536
|
const commandMap = {
|
|
19513
19537
|
'ActivateByEvent.activateByEvent': activateByEvent,
|
|
19514
19538
|
'CodeGenerator.accept': codeGeneratorAccept,
|
|
@@ -19609,7 +19633,7 @@ const commandMap = {
|
|
|
19609
19633
|
'Editor.goToDefinition': wrapCommand(goToDefinition),
|
|
19610
19634
|
'Editor.goToTypeDefinition': wrapCommand(goToTypeDefinition),
|
|
19611
19635
|
'Editor.handleBeforeInput': handleBeforeInputCommand,
|
|
19612
|
-
'Editor.handleBeforeInputFromContentEditable':
|
|
19636
|
+
'Editor.handleBeforeInputFromContentEditable': handleBeforeInputFromContentEditableCommand,
|
|
19613
19637
|
'Editor.handleBlur': wrapCommand(handleBlur$1),
|
|
19614
19638
|
'Editor.handleClickAtPosition': wrapCommand(handleClickAtPosition),
|
|
19615
19639
|
'Editor.handleContextMenu': wrapCommand(handleContextMenu),
|