@lvce-editor/editor-worker 3.30.0 → 4.0.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 +60 -32
- package/package.json +2 -2
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 TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompletionProvider';
|
|
1739
1740
|
const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
|
|
1740
1741
|
|
|
1741
1742
|
const measureCharacterWidth = (fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
@@ -2999,7 +3000,7 @@ const cut = editor => {
|
|
|
2999
3000
|
|
|
3000
3001
|
// TODO optimize this function by profiling and not allocating too many objects
|
|
3001
3002
|
// @ts-ignore
|
|
3002
|
-
const getChanges$
|
|
3003
|
+
const getChanges$5 = (lines, selections, getDelta) => {
|
|
3003
3004
|
const changes = [];
|
|
3004
3005
|
// TODO avoid closure
|
|
3005
3006
|
const deleteSelection = (selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn) => {
|
|
@@ -3063,7 +3064,7 @@ const deleteLeftWithAutoClose = editor => {
|
|
|
3063
3064
|
selections[i + 1]++;
|
|
3064
3065
|
selections[i + 3]++;
|
|
3065
3066
|
}
|
|
3066
|
-
const changes = getChanges$
|
|
3067
|
+
const changes = getChanges$5(lines, selections, twoCharactersLeft);
|
|
3067
3068
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
3068
3069
|
};
|
|
3069
3070
|
const editorDeleteHorizontalLeft = (editor, getDelta) => {
|
|
@@ -3076,7 +3077,7 @@ const editorDeleteHorizontalLeft = (editor, getDelta) => {
|
|
|
3076
3077
|
return deleteLeftWithAutoClose(editor);
|
|
3077
3078
|
}
|
|
3078
3079
|
if (isEverySelectionEmpty(selections)) {
|
|
3079
|
-
const changes = getChanges$
|
|
3080
|
+
const changes = getChanges$5(lines, selections, getDelta);
|
|
3080
3081
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
3081
3082
|
}
|
|
3082
3083
|
const changes = editorReplaceSelections(editor, [''], DeleteLeft);
|
|
@@ -3091,7 +3092,7 @@ const deleteAllLeft = editor => {
|
|
|
3091
3092
|
// @ts-ignore
|
|
3092
3093
|
|
|
3093
3094
|
// @ts-ignore
|
|
3094
|
-
const getChanges$
|
|
3095
|
+
const getChanges$4 = (editor, getDelta) => {
|
|
3095
3096
|
const selections = editor.selections;
|
|
3096
3097
|
if (isEverySelectionEmpty(selections)) {
|
|
3097
3098
|
const changes = [];
|
|
@@ -3121,7 +3122,7 @@ const getChanges$5 = (editor, getDelta) => {
|
|
|
3121
3122
|
return changes;
|
|
3122
3123
|
};
|
|
3123
3124
|
const editorDeleteHorizontalRight = (editor, getDelta) => {
|
|
3124
|
-
const changes = getChanges$
|
|
3125
|
+
const changes = getChanges$4(editor, getDelta);
|
|
3125
3126
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
3126
3127
|
};
|
|
3127
3128
|
|
|
@@ -3817,7 +3818,7 @@ const getSelectionFromNativeRange = (editor, range) => {
|
|
|
3817
3818
|
};
|
|
3818
3819
|
|
|
3819
3820
|
// @ts-ignore
|
|
3820
|
-
const getChanges$
|
|
3821
|
+
const getChanges$3 = (editor, data, range) => {
|
|
3821
3822
|
const selection = getSelectionFromNativeRange(editor, range);
|
|
3822
3823
|
const selectionRange = {
|
|
3823
3824
|
start: {
|
|
@@ -3839,7 +3840,7 @@ const getChanges$4 = (editor, data, range) => {
|
|
|
3839
3840
|
return changes;
|
|
3840
3841
|
};
|
|
3841
3842
|
const handleBeforeInputFromContentEditable = (editor, data, range) => {
|
|
3842
|
-
const changes = getChanges$
|
|
3843
|
+
const changes = getChanges$3(editor, data, range);
|
|
3843
3844
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
3844
3845
|
};
|
|
3845
3846
|
|
|
@@ -4195,7 +4196,7 @@ const handleTouchMove = (editor, touchEvent) => {
|
|
|
4195
4196
|
};
|
|
4196
4197
|
|
|
4197
4198
|
// @ts-ignore
|
|
4198
|
-
const getChanges$
|
|
4199
|
+
const getChanges$2 = selections => {
|
|
4199
4200
|
const changes = [];
|
|
4200
4201
|
const rowsToIndentLess = [];
|
|
4201
4202
|
for (let i = 0; i < selections.length; i += 4) {
|
|
@@ -4226,11 +4227,11 @@ const getChanges$3 = selections => {
|
|
|
4226
4227
|
// @ts-ignore
|
|
4227
4228
|
const indentLess = editor => {
|
|
4228
4229
|
const selections = editor.selections;
|
|
4229
|
-
const changes = getChanges$
|
|
4230
|
+
const changes = getChanges$2(selections);
|
|
4230
4231
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
4231
4232
|
};
|
|
4232
4233
|
|
|
4233
|
-
const getChanges$
|
|
4234
|
+
const getChanges$1 = selections => {
|
|
4234
4235
|
const rowsToIndent = [];
|
|
4235
4236
|
for (let i = 0; i < selections.length; i += 4) {
|
|
4236
4237
|
const selectionStartRow = selections[i];
|
|
@@ -4261,7 +4262,7 @@ const indentMore = editor => {
|
|
|
4261
4262
|
const {
|
|
4262
4263
|
selections
|
|
4263
4264
|
} = editor;
|
|
4264
|
-
const changes = getChanges$
|
|
4265
|
+
const changes = getChanges$1(selections);
|
|
4265
4266
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
4266
4267
|
};
|
|
4267
4268
|
|
|
@@ -4285,7 +4286,7 @@ const shouldIncreaseIndent = (before, increaseIndentRegex) => {
|
|
|
4285
4286
|
}
|
|
4286
4287
|
return increaseIndentRegex.test(before);
|
|
4287
4288
|
};
|
|
4288
|
-
const getChanges
|
|
4289
|
+
const getChanges = (lines, selections, languageConfiguration) => {
|
|
4289
4290
|
const changes = [];
|
|
4290
4291
|
const selectionChanges = [];
|
|
4291
4292
|
const increaseIndentRegex = getIncreaseIndentRegex(languageConfiguration);
|
|
@@ -4357,7 +4358,7 @@ const insertLineBreak = async editor => {
|
|
|
4357
4358
|
const {
|
|
4358
4359
|
changes,
|
|
4359
4360
|
selectionChanges
|
|
4360
|
-
} = getChanges
|
|
4361
|
+
} = getChanges(lines, selections, languageConfiguration);
|
|
4361
4362
|
return scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
|
|
4362
4363
|
};
|
|
4363
4364
|
|
|
@@ -4525,6 +4526,7 @@ const create$4 = () => {
|
|
|
4525
4526
|
|
|
4526
4527
|
const OnCompletion = 'onCompletion';
|
|
4527
4528
|
const OnHover = 'onHover';
|
|
4529
|
+
const OnTabCompletion = 'onTabCompletion';
|
|
4528
4530
|
|
|
4529
4531
|
// TODO add tests for this
|
|
4530
4532
|
const activateByEvent = async event => {
|
|
@@ -4545,7 +4547,7 @@ const execute = async ({
|
|
|
4545
4547
|
return result;
|
|
4546
4548
|
};
|
|
4547
4549
|
|
|
4548
|
-
const combineResults = results => {
|
|
4550
|
+
const combineResults$1 = results => {
|
|
4549
4551
|
return results[0] ?? [];
|
|
4550
4552
|
};
|
|
4551
4553
|
const executeCompletionProvider = (editor, offset) => {
|
|
@@ -4556,7 +4558,7 @@ const executeCompletionProvider = (editor, offset) => {
|
|
|
4556
4558
|
args: [offset],
|
|
4557
4559
|
noProviderFoundMessage: 'no completion provider found',
|
|
4558
4560
|
noProviderFoundResult: [],
|
|
4559
|
-
combineResults
|
|
4561
|
+
combineResults: combineResults$1
|
|
4560
4562
|
});
|
|
4561
4563
|
};
|
|
4562
4564
|
const combineResultsResolve = items => {
|
|
@@ -4574,15 +4576,19 @@ const executeResolveCompletionItem = (editor, offset, name, completionItem) => {
|
|
|
4574
4576
|
});
|
|
4575
4577
|
};
|
|
4576
4578
|
|
|
4577
|
-
|
|
4578
|
-
const getCompletions = async editor => {
|
|
4579
|
+
const getOffsetAtCursor = editor => {
|
|
4579
4580
|
const {
|
|
4580
4581
|
selections
|
|
4581
4582
|
} = editor;
|
|
4582
4583
|
const rowIndex = selections[0];
|
|
4583
4584
|
const columnIndex = selections[1];
|
|
4584
|
-
|
|
4585
|
-
|
|
4585
|
+
const offset = offsetAt(editor, rowIndex, columnIndex);
|
|
4586
|
+
return offset;
|
|
4587
|
+
};
|
|
4588
|
+
|
|
4589
|
+
// TODO possible to do this with events/state machine instead of promises -> enables canceling operations / concurrent calls
|
|
4590
|
+
const getCompletions = async editor => {
|
|
4591
|
+
const offset = getOffsetAtCursor(editor);
|
|
4586
4592
|
const completions = await executeCompletionProvider(editor, offset);
|
|
4587
4593
|
return completions;
|
|
4588
4594
|
};
|
|
@@ -4593,9 +4599,7 @@ const resolveCompletion = async (editor, name, completionItem) => {
|
|
|
4593
4599
|
object(editor);
|
|
4594
4600
|
string(name);
|
|
4595
4601
|
object(completionItem);
|
|
4596
|
-
const
|
|
4597
|
-
const columnIndex = editor.selections[1];
|
|
4598
|
-
const offset = await offsetAt(editor, rowIndex, columnIndex);
|
|
4602
|
+
const offset = getOffsetAtCursor(editor);
|
|
4599
4603
|
// @ts-ignore
|
|
4600
4604
|
const resolvedCompletionItem = await executeResolveCompletionItem(editor, offset, name, completionItem);
|
|
4601
4605
|
return resolvedCompletionItem;
|
|
@@ -6705,18 +6709,28 @@ const sortLinesAscending = editor => {
|
|
|
6705
6709
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
6706
6710
|
};
|
|
6707
6711
|
|
|
6712
|
+
const combineResults = results => {
|
|
6713
|
+
return results[0];
|
|
6714
|
+
};
|
|
6715
|
+
const executeTabCompletionProvider = (editor, offset) => {
|
|
6716
|
+
return execute({
|
|
6717
|
+
editor,
|
|
6718
|
+
event: OnTabCompletion,
|
|
6719
|
+
method: TabCompletionExecuteTabCompletionProvider,
|
|
6720
|
+
args: [offset],
|
|
6721
|
+
noProviderFoundMessage: 'No tab completion provider found',
|
|
6722
|
+
combineResults,
|
|
6723
|
+
noProviderFoundResult: undefined
|
|
6724
|
+
});
|
|
6725
|
+
};
|
|
6726
|
+
|
|
6708
6727
|
const getTabCompletion = async editor => {
|
|
6709
|
-
const
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
const rowIndex = selections[0];
|
|
6713
|
-
const columnIndex = selections[1];
|
|
6714
|
-
const offset = offsetAt(editor, rowIndex, columnIndex);
|
|
6715
|
-
const tabCompletion = await invoke$3('ExtensionHostTabCompletion.executeTabCompletionProvider', editor, offset);
|
|
6716
|
-
return tabCompletion;
|
|
6728
|
+
const offset = getOffsetAtCursor(editor);
|
|
6729
|
+
const completions = await executeTabCompletionProvider(editor, offset);
|
|
6730
|
+
return completions;
|
|
6717
6731
|
};
|
|
6718
6732
|
|
|
6719
|
-
const
|
|
6733
|
+
const getSnippetChanges = (lines, selections, snippet) => {
|
|
6720
6734
|
// TODO verify that deleted fits in the line
|
|
6721
6735
|
const insertedLines = splitLines$2(snippet.inserted);
|
|
6722
6736
|
const changes = [];
|
|
@@ -6808,7 +6822,7 @@ const editorSnippet = (editor, snippet) => {
|
|
|
6808
6822
|
const {
|
|
6809
6823
|
changes,
|
|
6810
6824
|
selectionChanges
|
|
6811
|
-
} =
|
|
6825
|
+
} = getSnippetChanges(lines, selections, snippet);
|
|
6812
6826
|
return scheduleDocumentAndCursorsSelections(editor, changes, selectionChanges);
|
|
6813
6827
|
};
|
|
6814
6828
|
|
|
@@ -8017,6 +8031,19 @@ const handleBeforeInput = (editor, inputType, data) => {
|
|
|
8017
8031
|
}
|
|
8018
8032
|
};
|
|
8019
8033
|
|
|
8034
|
+
const applyTabCompletion = (editor, result) => {
|
|
8035
|
+
return editorSnippet(editor, result);
|
|
8036
|
+
};
|
|
8037
|
+
|
|
8038
|
+
const handleTab = async editor => {
|
|
8039
|
+
const result = await getTabCompletion(editor);
|
|
8040
|
+
if (!result) {
|
|
8041
|
+
// TODO enter tab or two spaces
|
|
8042
|
+
return editor;
|
|
8043
|
+
}
|
|
8044
|
+
return applyTabCompletion(editor, result);
|
|
8045
|
+
};
|
|
8046
|
+
|
|
8020
8047
|
let enabled = false;
|
|
8021
8048
|
const setEnabled = value => {
|
|
8022
8049
|
enabled = value;
|
|
@@ -8982,6 +9009,7 @@ const commandMap = {
|
|
|
8982
9009
|
'ColorPicker.loadContent': loadContent$3,
|
|
8983
9010
|
'Editor.addCursorAbove': addCursorAbove,
|
|
8984
9011
|
'Editor.addCursorBelow': addCursorBelow,
|
|
9012
|
+
'Editor.handleTab': handleTab,
|
|
8985
9013
|
'Editor.applyEdit': applyEdit,
|
|
8986
9014
|
'Editor.braceCompletion': braceCompletion,
|
|
8987
9015
|
'Editor.cancelSelection': cancelSelection,
|
package/package.json
CHANGED