@lvce-editor/main-area-worker 9.61.0 → 9.63.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 +19 -3
- package/package.json +1 -1
|
@@ -4746,6 +4746,17 @@ const handleClickTogglePreview = async state => {
|
|
|
4746
4746
|
return state;
|
|
4747
4747
|
};
|
|
4748
4748
|
|
|
4749
|
+
const applyInitialCursorPosition = async (state, tabId, position) => {
|
|
4750
|
+
if (!position) {
|
|
4751
|
+
return;
|
|
4752
|
+
}
|
|
4753
|
+
const tab = findTabById(state, tabId)?.tab;
|
|
4754
|
+
if (!tab || tab.editorUid < 0 || tab.loadingState !== 'loaded' || tab.editorInput?.type !== 'editor') {
|
|
4755
|
+
return;
|
|
4756
|
+
}
|
|
4757
|
+
await invoke$1(state.applicationId, 'Viewlet.executeViewletCommand', tab.editorUid, position.highlightProblem ? 'revealProblem' : 'cursorSet', position.rowIndex, position.columnIndex);
|
|
4758
|
+
};
|
|
4759
|
+
|
|
4749
4760
|
const findTabByUri = (state, uri) => {
|
|
4750
4761
|
const {
|
|
4751
4762
|
layout
|
|
@@ -5429,7 +5440,8 @@ const openInputWithContext = async (context, options) => {
|
|
|
5429
5440
|
if (existingTab && !shouldRetry) {
|
|
5430
5441
|
const switchedState = getExistingTabState(currentState, existingTab, preview);
|
|
5431
5442
|
await context.updateState(() => switchedState);
|
|
5432
|
-
await
|
|
5443
|
+
await applyInitialCursorPosition(switchedState, existingTab.tab.id, options.initialCursorPosition);
|
|
5444
|
+
await focusIfRequested(context.getState(), options.focus);
|
|
5433
5445
|
return;
|
|
5434
5446
|
}
|
|
5435
5447
|
const replacedEditorUid = getActivePreviewEditorUid(currentState);
|
|
@@ -5506,6 +5518,7 @@ const openInputWithContext = async (context, options) => {
|
|
|
5506
5518
|
let readyState = handleViewletReady(latestState, editorUid);
|
|
5507
5519
|
await context.updateState(() => readyState);
|
|
5508
5520
|
await renderMainAreaPending(state.uid, state.applicationId);
|
|
5521
|
+
await applyInitialCursorPosition(context.getState(), tabId, options.initialCursorPosition);
|
|
5509
5522
|
await focusIfRequested(context.getState(), options.focus);
|
|
5510
5523
|
const renderedTitle = await getViewletTitle(editorUid);
|
|
5511
5524
|
if (renderedTitle) {
|
|
@@ -5590,7 +5603,7 @@ const getViewletContext = (options, viewletContext) => {
|
|
|
5590
5603
|
if (viewletContext !== undefined || typeof options === 'string') {
|
|
5591
5604
|
return viewletContext;
|
|
5592
5605
|
}
|
|
5593
|
-
const context = Object.fromEntries(Object.entries(options).filter(([key]) => key !== 'focus' && key !== 'preview' && key !== 'reuseExisting' && key !== 'uri'));
|
|
5606
|
+
const context = Object.fromEntries(Object.entries(options).filter(([key]) => key !== 'focus' && key !== 'initialCursorPosition' && key !== 'shouldFocus' && key !== 'preview' && key !== 'reuseExisting' && key !== 'uri'));
|
|
5594
5607
|
return Object.keys(context).length === 0 ? undefined : context;
|
|
5595
5608
|
};
|
|
5596
5609
|
const getOpenInputOptions = (options, focus = true, viewletContext) => {
|
|
@@ -5603,7 +5616,10 @@ const getOpenInputOptions = (options, focus = true, viewletContext) => {
|
|
|
5603
5616
|
args: [context]
|
|
5604
5617
|
}),
|
|
5605
5618
|
editorInput: getNormalizedOpenEditorInput(uri),
|
|
5606
|
-
focus: typeof options === 'string' ? focus : options.focus,
|
|
5619
|
+
focus: typeof options === 'string' ? focus : options.shouldFocus ?? options.focus ?? true,
|
|
5620
|
+
...(typeof options !== 'string' && options.initialCursorPosition && {
|
|
5621
|
+
initialCursorPosition: options.initialCursorPosition
|
|
5622
|
+
}),
|
|
5607
5623
|
preview,
|
|
5608
5624
|
reuseExisting
|
|
5609
5625
|
};
|