@lvce-editor/editor-worker 4.5.0 → 4.6.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/editorWorkerMain.js +71 -13
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1736,6 +1736,7 @@ const {
|
|
|
1736
1736
|
const CompletionExecute = 'ExtensionHostCompletion.execute';
|
|
1737
1737
|
const CompletionResolveExecute = 'ExtensionHostCompletion.executeResolve';
|
|
1738
1738
|
const HoverExecute = 'ExtensionHostHover.execute';
|
|
1739
|
+
const RenameExecuteRename = 'ExtensionHostRename.executeRenameProvider';
|
|
1739
1740
|
const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompletionProvider';
|
|
1740
1741
|
const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
|
|
1741
1742
|
|
|
@@ -2273,6 +2274,21 @@ const cancelSelection = editor => {
|
|
|
2273
2274
|
return scheduleSelections(editor, newSelections);
|
|
2274
2275
|
};
|
|
2275
2276
|
|
|
2277
|
+
const getIndex = (widgets, id) => {
|
|
2278
|
+
for (let i = 0; i < widgets.length; i++) {
|
|
2279
|
+
const widget = widgets[i];
|
|
2280
|
+
if (widget.id === id) {
|
|
2281
|
+
return i;
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
return -1;
|
|
2285
|
+
};
|
|
2286
|
+
const removeEditorWidget = (widgets, id) => {
|
|
2287
|
+
const index = getIndex(widgets, id);
|
|
2288
|
+
const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
|
|
2289
|
+
return newWidgets;
|
|
2290
|
+
};
|
|
2291
|
+
|
|
2276
2292
|
// TODO use numeric widget id
|
|
2277
2293
|
const ColorPicker$1 = 'colorPicker';
|
|
2278
2294
|
const Completion = 'completion';
|
|
@@ -2293,7 +2309,7 @@ const closeCompletion = editor => {
|
|
|
2293
2309
|
if (completionWidgetIndex === -1) {
|
|
2294
2310
|
return editor;
|
|
2295
2311
|
}
|
|
2296
|
-
const newWidgets =
|
|
2312
|
+
const newWidgets = removeEditorWidget(widgets, Completion);
|
|
2297
2313
|
return {
|
|
2298
2314
|
...editor,
|
|
2299
2315
|
widgets: newWidgets
|
|
@@ -2311,7 +2327,7 @@ const closeFind = editor => {
|
|
|
2311
2327
|
if (index === -1) {
|
|
2312
2328
|
return editor;
|
|
2313
2329
|
}
|
|
2314
|
-
const newWidgets =
|
|
2330
|
+
const newWidgets = removeEditorWidget(widgets, Find);
|
|
2315
2331
|
return {
|
|
2316
2332
|
...editor,
|
|
2317
2333
|
widgets: newWidgets
|
|
@@ -2330,7 +2346,7 @@ const closeRename = editor => {
|
|
|
2330
2346
|
if (renameWidgetIndex === -1) {
|
|
2331
2347
|
return editor;
|
|
2332
2348
|
}
|
|
2333
|
-
const newWidgets =
|
|
2349
|
+
const newWidgets = removeEditorWidget(widgets, Rename);
|
|
2334
2350
|
return {
|
|
2335
2351
|
...editor,
|
|
2336
2352
|
focused: true,
|
|
@@ -2349,7 +2365,7 @@ const closeSourceAction = editor => {
|
|
|
2349
2365
|
if (index === -1) {
|
|
2350
2366
|
return editor;
|
|
2351
2367
|
}
|
|
2352
|
-
const newWidgets =
|
|
2368
|
+
const newWidgets = removeEditorWidget(widgets, SourceAction);
|
|
2353
2369
|
return {
|
|
2354
2370
|
...editor,
|
|
2355
2371
|
widgets: newWidgets
|
|
@@ -4546,6 +4562,7 @@ const create$5 = () => {
|
|
|
4546
4562
|
return completionWidget;
|
|
4547
4563
|
};
|
|
4548
4564
|
|
|
4565
|
+
const OnRename = 'onRename';
|
|
4549
4566
|
const OnCompletion = 'onCompletion';
|
|
4550
4567
|
const OnHover = 'onHover';
|
|
4551
4568
|
const OnTabCompletion = 'onTabCompletion';
|
|
@@ -4569,7 +4586,7 @@ const execute = async ({
|
|
|
4569
4586
|
return result;
|
|
4570
4587
|
};
|
|
4571
4588
|
|
|
4572
|
-
const combineResults$
|
|
4589
|
+
const combineResults$2 = results => {
|
|
4573
4590
|
return results[0] ?? [];
|
|
4574
4591
|
};
|
|
4575
4592
|
const executeCompletionProvider = (editor, offset) => {
|
|
@@ -4580,7 +4597,7 @@ const executeCompletionProvider = (editor, offset) => {
|
|
|
4580
4597
|
args: [offset],
|
|
4581
4598
|
noProviderFoundMessage: 'no completion provider found',
|
|
4582
4599
|
noProviderFoundResult: [],
|
|
4583
|
-
combineResults: combineResults$
|
|
4600
|
+
combineResults: combineResults$2
|
|
4584
4601
|
});
|
|
4585
4602
|
};
|
|
4586
4603
|
const combineResultsResolve = items => {
|
|
@@ -6835,7 +6852,7 @@ const sortLinesAscending = editor => {
|
|
|
6835
6852
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
6836
6853
|
};
|
|
6837
6854
|
|
|
6838
|
-
const combineResults = results => {
|
|
6855
|
+
const combineResults$1 = results => {
|
|
6839
6856
|
return results[0];
|
|
6840
6857
|
};
|
|
6841
6858
|
const executeTabCompletionProvider = (editor, offset) => {
|
|
@@ -6845,7 +6862,7 @@ const executeTabCompletionProvider = (editor, offset) => {
|
|
|
6845
6862
|
method: TabCompletionExecuteTabCompletionProvider,
|
|
6846
6863
|
args: [offset],
|
|
6847
6864
|
noProviderFoundMessage: 'No tab completion provider found',
|
|
6848
|
-
combineResults,
|
|
6865
|
+
combineResults: combineResults$1,
|
|
6849
6866
|
noProviderFoundResult: undefined
|
|
6850
6867
|
});
|
|
6851
6868
|
};
|
|
@@ -7727,9 +7744,6 @@ const getEdits = async (editor, completionItem) => {
|
|
|
7727
7744
|
const changes = replaceRange(editor, replaceRange$1, [inserted], '');
|
|
7728
7745
|
return changes;
|
|
7729
7746
|
};
|
|
7730
|
-
const isCompletion = widget => {
|
|
7731
|
-
return widget.id === Completion;
|
|
7732
|
-
};
|
|
7733
7747
|
const select = async (editor, completionItem) => {
|
|
7734
7748
|
const changes = await getEdits(editor, completionItem);
|
|
7735
7749
|
const index = editor.widgets.indexOf
|
|
@@ -7746,8 +7760,7 @@ const select = async (editor, completionItem) => {
|
|
|
7746
7760
|
const {
|
|
7747
7761
|
widgets
|
|
7748
7762
|
} = editor;
|
|
7749
|
-
const
|
|
7750
|
-
const newWidgets = [...widgets.slice(0, completionWidgetIndex), ...widgets.slice(completionWidgetIndex + 1)];
|
|
7763
|
+
const newWidgets = removeEditorWidget(widgets, Completion);
|
|
7751
7764
|
const intermediateEditor = await applyEdit(editor, changes);
|
|
7752
7765
|
return {
|
|
7753
7766
|
...intermediateEditor,
|
|
@@ -8021,6 +8034,50 @@ const renderHover = (oldState, newState) => {
|
|
|
8021
8034
|
return commands;
|
|
8022
8035
|
};
|
|
8023
8036
|
|
|
8037
|
+
const combineResults = results => {
|
|
8038
|
+
return results[0] ?? [];
|
|
8039
|
+
};
|
|
8040
|
+
const executeRenameProvider = (editor, offset, newName) => {
|
|
8041
|
+
return execute({
|
|
8042
|
+
editor,
|
|
8043
|
+
event: OnRename,
|
|
8044
|
+
method: RenameExecuteRename,
|
|
8045
|
+
args: [offset, newName],
|
|
8046
|
+
noProviderFoundMessage: 'no rename provider found',
|
|
8047
|
+
noProviderFoundResult: [],
|
|
8048
|
+
combineResults
|
|
8049
|
+
});
|
|
8050
|
+
};
|
|
8051
|
+
|
|
8052
|
+
const getRenameState = editor => {
|
|
8053
|
+
return getWidgetState(editor, Rename);
|
|
8054
|
+
};
|
|
8055
|
+
|
|
8056
|
+
const accept = async editor => {
|
|
8057
|
+
const child = getRenameState(editor);
|
|
8058
|
+
if (!child) {
|
|
8059
|
+
return editor;
|
|
8060
|
+
}
|
|
8061
|
+
const {
|
|
8062
|
+
widgets
|
|
8063
|
+
} = editor;
|
|
8064
|
+
const newWidgets = removeEditorWidget(widgets, Rename);
|
|
8065
|
+
// TODO
|
|
8066
|
+
const offset = getOffsetAtCursor(editor);
|
|
8067
|
+
const result = await executeRenameProvider(editor, offset, child.newValue);
|
|
8068
|
+
console.log({
|
|
8069
|
+
result
|
|
8070
|
+
});
|
|
8071
|
+
// 1. ask extension host for rename edits
|
|
8072
|
+
// 2. apply rename edit across editor (and whole workspace)
|
|
8073
|
+
// 3. close rename widget
|
|
8074
|
+
return {
|
|
8075
|
+
...editor,
|
|
8076
|
+
focused: true,
|
|
8077
|
+
widgets: newWidgets
|
|
8078
|
+
};
|
|
8079
|
+
};
|
|
8080
|
+
|
|
8024
8081
|
const handleBlur = editor => {
|
|
8025
8082
|
return closeRename(editor);
|
|
8026
8083
|
};
|
|
@@ -9297,6 +9354,7 @@ const commandMap = {
|
|
|
9297
9354
|
'EditorCompletion.selectCurrent': selectCurrent,
|
|
9298
9355
|
'EditorCompletion.selectIndex': selectIndex,
|
|
9299
9356
|
'EditorCompletion.toggleDetails': toggleDetails,
|
|
9357
|
+
'EditorRename.accept': accept,
|
|
9300
9358
|
'EditorRename.handleBlur': handleBlur,
|
|
9301
9359
|
'EditorSourceActions.focusNext': focusNext,
|
|
9302
9360
|
'FindWidget.close': close$1,
|