@lvce-editor/editor-worker 7.16.0 → 7.17.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 +44 -0
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1265,6 +1265,7 @@ const IndentLess = 'indentLess';
|
|
|
1265
1265
|
const IndentMore = 'indentMore';
|
|
1266
1266
|
const InsertLineBreak = 'insertLineBreak';
|
|
1267
1267
|
const LineComment = 'lineComment';
|
|
1268
|
+
const Rename$1 = 'rename';
|
|
1268
1269
|
const ToggleBlockComment$1 = 'toggleBlockComment';
|
|
1269
1270
|
|
|
1270
1271
|
const map$1 = Object.create(null);
|
|
@@ -2509,6 +2510,48 @@ const applyEdit = async (editor, changes) => {
|
|
|
2509
2510
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
2510
2511
|
};
|
|
2511
2512
|
|
|
2513
|
+
// TODO maybe use a separate worker for bulk edits and bulk edit history
|
|
2514
|
+
|
|
2515
|
+
const getTextChanges = (editor, changes) => {
|
|
2516
|
+
const textChanges = [];
|
|
2517
|
+
for (const change of changes) {
|
|
2518
|
+
if (change.uri === editor.uri) {
|
|
2519
|
+
for (const edit of change.edits) {
|
|
2520
|
+
const startPosition = positionAt(editor, edit.offset);
|
|
2521
|
+
const endPosition = positionAt(editor, edit.offset + edit.deleted);
|
|
2522
|
+
const deleted = getSelectionText(editor, {
|
|
2523
|
+
start: startPosition,
|
|
2524
|
+
end: endPosition
|
|
2525
|
+
});
|
|
2526
|
+
const textChange = {
|
|
2527
|
+
start: startPosition,
|
|
2528
|
+
end: endPosition,
|
|
2529
|
+
inserted: [edit.inserted],
|
|
2530
|
+
deleted,
|
|
2531
|
+
origin: Rename$1
|
|
2532
|
+
};
|
|
2533
|
+
textChanges.push(textChange);
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
return textChanges;
|
|
2538
|
+
};
|
|
2539
|
+
const applyWorkspaceEdit = async (editor, changes) => {
|
|
2540
|
+
object(editor);
|
|
2541
|
+
array(changes);
|
|
2542
|
+
const textChanges = getTextChanges(editor, changes);
|
|
2543
|
+
if (textChanges.length === 0) {
|
|
2544
|
+
return;
|
|
2545
|
+
}
|
|
2546
|
+
// TODO
|
|
2547
|
+
// for now only apply edits to single file, if it matches the uri
|
|
2548
|
+
//
|
|
2549
|
+
// in the future:
|
|
2550
|
+
// 1. if a change targets the current editor, apply an edit to this editor
|
|
2551
|
+
// 2. else, use file system worker to write file change
|
|
2552
|
+
return scheduleDocumentAndCursorsSelections(editor, textChanges);
|
|
2553
|
+
};
|
|
2554
|
+
|
|
2512
2555
|
const handleBlur$1 = editor => {
|
|
2513
2556
|
if (editor.focusKey !== Empty) {
|
|
2514
2557
|
return editor;
|
|
@@ -9910,6 +9953,7 @@ const commandMap = {
|
|
|
9910
9953
|
'Editor.addCursorBelow': addCursorBelow,
|
|
9911
9954
|
'Editor.applyEdit': applyEdit,
|
|
9912
9955
|
'Editor.applyEdit2': applyEdits2,
|
|
9956
|
+
'Editor.applyWorkspaceEdit': applyWorkspaceEdit,
|
|
9913
9957
|
'Editor.braceCompletion': braceCompletion,
|
|
9914
9958
|
'Editor.cancelSelection': cancelSelection,
|
|
9915
9959
|
'Editor.closeCodeGenerator': closeCodeGenerator,
|