@lvce-editor/editor-worker 3.15.0 → 3.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 +107 -65
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -595,14 +595,10 @@ const getSelectionPairs = (selections, i) => {
|
|
|
595
595
|
return [first, second, third, fourth, 0];
|
|
596
596
|
};
|
|
597
597
|
|
|
598
|
-
const
|
|
599
|
-
const
|
|
600
|
-
const EmptyString = '';
|
|
601
|
-
const Space = ' ';
|
|
598
|
+
const EmptyString$1 = '';
|
|
599
|
+
const Space$1 = ' ';
|
|
602
600
|
const Tab = '\t';
|
|
603
|
-
const Underline = '_';
|
|
604
601
|
const DoubleQuote$1 = '"';
|
|
605
|
-
const T = 't';
|
|
606
602
|
|
|
607
603
|
const getTabCount = string => {
|
|
608
604
|
let count = 0;
|
|
@@ -675,7 +671,7 @@ const measureTextWidth = (text, fontWeight, fontSize, fontFamily, letterSpacing,
|
|
|
675
671
|
|
|
676
672
|
const normalizeText = (text, normalize, tabSize) => {
|
|
677
673
|
if (normalize) {
|
|
678
|
-
return text.replaceAll(Tab, Space.repeat(tabSize));
|
|
674
|
+
return text.replaceAll(Tab, Space$1.repeat(tabSize));
|
|
679
675
|
}
|
|
680
676
|
return text;
|
|
681
677
|
};
|
|
@@ -2431,6 +2427,9 @@ const setAdditionalFocus = async focusKey => {
|
|
|
2431
2427
|
};
|
|
2432
2428
|
|
|
2433
2429
|
const setFocus = async focusKey => {
|
|
2430
|
+
if (!focusKey) {
|
|
2431
|
+
return;
|
|
2432
|
+
}
|
|
2434
2433
|
await invoke$3('Focus.setFocus', focusKey);
|
|
2435
2434
|
};
|
|
2436
2435
|
|
|
@@ -2825,7 +2824,7 @@ const characterRight = (line, columnIndex) => {
|
|
|
2825
2824
|
return next.segment.length;
|
|
2826
2825
|
};
|
|
2827
2826
|
const isWhitespace = char => {
|
|
2828
|
-
return char === Space || char === Tab;
|
|
2827
|
+
return char === Space$1 || char === Tab;
|
|
2829
2828
|
};
|
|
2830
2829
|
const lineCharacterStart = (line, columnIndex) => {
|
|
2831
2830
|
if (line.length === 0) {
|
|
@@ -3342,7 +3341,7 @@ const getWordAt$1 = (line, columnIndex) => {
|
|
|
3342
3341
|
const matchBefore = before.match(RE_WORD_END$1);
|
|
3343
3342
|
const after = line.slice(columnIndex);
|
|
3344
3343
|
const matchAfter = after.match(RE_WORD_START$1);
|
|
3345
|
-
let word = EmptyString;
|
|
3344
|
+
let word = EmptyString$1;
|
|
3346
3345
|
if (matchBefore) {
|
|
3347
3346
|
word += matchBefore[0];
|
|
3348
3347
|
}
|
|
@@ -3359,7 +3358,7 @@ const getWordBefore$1 = (line, columnIndex) => {
|
|
|
3359
3358
|
if (matchBefore) {
|
|
3360
3359
|
return matchBefore[0];
|
|
3361
3360
|
}
|
|
3362
|
-
return EmptyString;
|
|
3361
|
+
return EmptyString$1;
|
|
3363
3362
|
};
|
|
3364
3363
|
|
|
3365
3364
|
const getWordAt = (editor, rowIndex, columnIndex) => {
|
|
@@ -4682,8 +4681,6 @@ const resolveCompletion = async (editor, name, completionItem) => {
|
|
|
4682
4681
|
|
|
4683
4682
|
const None$1 = 1;
|
|
4684
4683
|
|
|
4685
|
-
const EmptyMatches = [];
|
|
4686
|
-
|
|
4687
4684
|
const Diagonal = 1;
|
|
4688
4685
|
const Left = 2;
|
|
4689
4686
|
|
|
@@ -4697,11 +4694,16 @@ const createTable = size => {
|
|
|
4697
4694
|
}
|
|
4698
4695
|
return table;
|
|
4699
4696
|
};
|
|
4700
|
-
|
|
4697
|
+
const EmptyMatches$1 = [];
|
|
4698
|
+
const Dash = '-';
|
|
4699
|
+
const Dot = '.';
|
|
4700
|
+
const EmptyString = '';
|
|
4701
|
+
const Space = ' ';
|
|
4702
|
+
const Underline = '_';
|
|
4703
|
+
const T = 't';
|
|
4701
4704
|
const isLowerCase = char => {
|
|
4702
4705
|
return char === char.toLowerCase();
|
|
4703
4706
|
};
|
|
4704
|
-
|
|
4705
4707
|
const isUpperCase = char => {
|
|
4706
4708
|
return char === char.toUpperCase();
|
|
4707
4709
|
};
|
|
@@ -4724,7 +4726,7 @@ const isGap = (columnCharBefore, columnChar) => {
|
|
|
4724
4726
|
};
|
|
4725
4727
|
|
|
4726
4728
|
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
4727
|
-
const getScore = (rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar,
|
|
4729
|
+
const getScore = (rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch) => {
|
|
4728
4730
|
if (rowCharLow !== columnCharLow) {
|
|
4729
4731
|
return -1;
|
|
4730
4732
|
}
|
|
@@ -4791,13 +4793,13 @@ const traceHighlights = (table, arrows, patternLength, wordLength) => {
|
|
|
4791
4793
|
const gridSize = 128;
|
|
4792
4794
|
const table = createTable(gridSize);
|
|
4793
4795
|
const arrows = createTable(gridSize);
|
|
4794
|
-
const
|
|
4796
|
+
const fuzzySearch = (pattern, word) => {
|
|
4795
4797
|
const patternLength = Math.min(pattern.length, gridSize - 1);
|
|
4796
4798
|
const wordLength = Math.min(word.length, gridSize - 1);
|
|
4797
4799
|
const patternLower = pattern.toLowerCase();
|
|
4798
4800
|
const wordLower = word.toLowerCase();
|
|
4799
4801
|
if (!isPatternInWord(patternLower, 0, patternLength, wordLower, 0, wordLength)) {
|
|
4800
|
-
return EmptyMatches;
|
|
4802
|
+
return EmptyMatches$1;
|
|
4801
4803
|
}
|
|
4802
4804
|
let strongMatch = false;
|
|
4803
4805
|
for (let row = 1; row < patternLength + 1; row++) {
|
|
@@ -4808,7 +4810,7 @@ const filterCompletionItem = (pattern, word) => {
|
|
|
4808
4810
|
const columnCharLow = wordLower[column - 1];
|
|
4809
4811
|
const columnCharBefore = word[column - 2] || '';
|
|
4810
4812
|
const isDiagonalMatch = arrows[row - 1][column - 1] === Diagonal;
|
|
4811
|
-
const score = getScore(rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar,
|
|
4813
|
+
const score = getScore(rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch);
|
|
4812
4814
|
if (row === 1 && score > 5) {
|
|
4813
4815
|
strongMatch = true;
|
|
4814
4816
|
}
|
|
@@ -4827,7 +4829,7 @@ const filterCompletionItem = (pattern, word) => {
|
|
|
4827
4829
|
}
|
|
4828
4830
|
}
|
|
4829
4831
|
if (!strongMatch) {
|
|
4830
|
-
return EmptyMatches;
|
|
4832
|
+
return EmptyMatches$1;
|
|
4831
4833
|
}
|
|
4832
4834
|
const highlights = traceHighlights(table, arrows, patternLength, wordLength);
|
|
4833
4835
|
return highlights;
|
|
@@ -4835,6 +4837,8 @@ const filterCompletionItem = (pattern, word) => {
|
|
|
4835
4837
|
|
|
4836
4838
|
const Deprecated = 1 << 0;
|
|
4837
4839
|
|
|
4840
|
+
const EmptyMatches = [];
|
|
4841
|
+
|
|
4838
4842
|
const addEmptyMatch = item => {
|
|
4839
4843
|
return {
|
|
4840
4844
|
...item,
|
|
@@ -4842,7 +4846,7 @@ const addEmptyMatch = item => {
|
|
|
4842
4846
|
};
|
|
4843
4847
|
};
|
|
4844
4848
|
const filterCompletionItems = (completionItems, word) => {
|
|
4845
|
-
if (word === EmptyString) {
|
|
4849
|
+
if (word === EmptyString$1) {
|
|
4846
4850
|
return completionItems.map(addEmptyMatch);
|
|
4847
4851
|
}
|
|
4848
4852
|
const filteredCompletions = [];
|
|
@@ -4852,8 +4856,8 @@ const filterCompletionItems = (completionItems, word) => {
|
|
|
4852
4856
|
label,
|
|
4853
4857
|
flags
|
|
4854
4858
|
} = completionItem;
|
|
4855
|
-
const result =
|
|
4856
|
-
if (result
|
|
4859
|
+
const result = fuzzySearch(word, label);
|
|
4860
|
+
if (result.length > 0) {
|
|
4857
4861
|
if (flags & Deprecated) {
|
|
4858
4862
|
// TODO avoid mutation
|
|
4859
4863
|
completionItem.matches = EmptyMatches;
|
|
@@ -5192,58 +5196,108 @@ const focusFind = state => {
|
|
|
5192
5196
|
return setFindWidgetFocus(state, FindWidget);
|
|
5193
5197
|
};
|
|
5194
5198
|
|
|
5199
|
+
const getWidgetState = (editor, id) => {
|
|
5200
|
+
const {
|
|
5201
|
+
widgets
|
|
5202
|
+
} = editor;
|
|
5203
|
+
for (const widget of widgets) {
|
|
5204
|
+
if (widget.id === id) {
|
|
5205
|
+
return widget.newState;
|
|
5206
|
+
}
|
|
5207
|
+
}
|
|
5208
|
+
return undefined;
|
|
5209
|
+
};
|
|
5210
|
+
|
|
5211
|
+
const getFindState = editor => {
|
|
5212
|
+
return getWidgetState(editor, Find);
|
|
5213
|
+
};
|
|
5214
|
+
|
|
5215
|
+
const isFind = widget => {
|
|
5216
|
+
return widget.id === Find;
|
|
5217
|
+
};
|
|
5195
5218
|
// TODO don't call renderer worker, set editor state
|
|
5196
5219
|
// TODO this function should be synchronous
|
|
5197
|
-
const focusIndex$1 =
|
|
5220
|
+
const focusIndex$1 = (editor, index) => {
|
|
5221
|
+
const findState = getFindState(editor);
|
|
5222
|
+
if (!findState) {
|
|
5223
|
+
return editor;
|
|
5224
|
+
}
|
|
5198
5225
|
const {
|
|
5199
5226
|
value,
|
|
5200
5227
|
matches,
|
|
5201
5228
|
matchIndex
|
|
5202
|
-
} =
|
|
5229
|
+
} = findState;
|
|
5203
5230
|
if (index === matchIndex) {
|
|
5204
|
-
return
|
|
5231
|
+
return editor;
|
|
5205
5232
|
}
|
|
5233
|
+
const {
|
|
5234
|
+
widgets
|
|
5235
|
+
} = editor;
|
|
5236
|
+
const childIndex = widgets.findIndex(isFind);
|
|
5237
|
+
const childWidget = widgets[childIndex];
|
|
5238
|
+
|
|
5206
5239
|
// TODO find next match and highlight it
|
|
5207
5240
|
const matchRowIndex = matches[index * 2];
|
|
5208
5241
|
const matchColumnIndex = matches[index * 2 + 1];
|
|
5209
|
-
// @ts-ignore
|
|
5210
5242
|
const newSelections = new Uint32Array([matchRowIndex, matchColumnIndex, matchRowIndex, matchColumnIndex + value.length]);
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
// TODO
|
|
5214
|
-
await invoke$3('Editor.setSelections', newSelections);
|
|
5215
|
-
return {
|
|
5216
|
-
...state,
|
|
5243
|
+
const newState = {
|
|
5244
|
+
...findState,
|
|
5217
5245
|
matchIndex: index
|
|
5218
5246
|
};
|
|
5247
|
+
const newWidget = {
|
|
5248
|
+
...childWidget,
|
|
5249
|
+
newState
|
|
5250
|
+
};
|
|
5251
|
+
const newWidgets = [...widgets.slice(0, childIndex), newWidget, ...widgets.slice(childIndex + 1)];
|
|
5252
|
+
return {
|
|
5253
|
+
...editor,
|
|
5254
|
+
selections: newSelections,
|
|
5255
|
+
widgets: newWidgets
|
|
5256
|
+
};
|
|
5219
5257
|
};
|
|
5220
|
-
const focusFirst$1 =
|
|
5221
|
-
|
|
5258
|
+
const focusFirst$1 = editor => {
|
|
5259
|
+
const findState = getFindState(editor);
|
|
5260
|
+
if (!findState) {
|
|
5261
|
+
return editor;
|
|
5262
|
+
}
|
|
5263
|
+
return focusIndex$1(editor, 0);
|
|
5222
5264
|
};
|
|
5223
|
-
const focusLast =
|
|
5265
|
+
const focusLast = editor => {
|
|
5266
|
+
const findState = getFindState(editor);
|
|
5267
|
+
if (!findState) {
|
|
5268
|
+
return editor;
|
|
5269
|
+
}
|
|
5224
5270
|
const {
|
|
5225
5271
|
matchCount
|
|
5226
|
-
} =
|
|
5227
|
-
return focusIndex$1(
|
|
5272
|
+
} = findState;
|
|
5273
|
+
return focusIndex$1(editor, matchCount - 1);
|
|
5228
5274
|
};
|
|
5229
|
-
const focusNext$1 =
|
|
5275
|
+
const focusNext$1 = editor => {
|
|
5276
|
+
const findState = getFindState(editor);
|
|
5277
|
+
if (!findState) {
|
|
5278
|
+
return editor;
|
|
5279
|
+
}
|
|
5230
5280
|
const {
|
|
5231
5281
|
matchIndex,
|
|
5232
5282
|
matchCount
|
|
5233
|
-
} =
|
|
5283
|
+
} = findState;
|
|
5234
5284
|
if (matchIndex === matchCount - 1) {
|
|
5235
|
-
return focusFirst$1(
|
|
5285
|
+
return focusFirst$1(editor);
|
|
5236
5286
|
}
|
|
5237
|
-
return focusIndex$1(
|
|
5287
|
+
return focusIndex$1(editor, matchIndex + 1);
|
|
5238
5288
|
};
|
|
5239
|
-
const focusPrevious$1 =
|
|
5289
|
+
const focusPrevious$1 = editor => {
|
|
5290
|
+
const findState = getFindState(editor);
|
|
5291
|
+
if (!findState) {
|
|
5292
|
+
return editor;
|
|
5293
|
+
}
|
|
5240
5294
|
const {
|
|
5241
5295
|
matchIndex
|
|
5242
|
-
} =
|
|
5296
|
+
} = findState;
|
|
5243
5297
|
if (matchIndex === 0) {
|
|
5244
|
-
return focusLast(
|
|
5298
|
+
return focusLast(editor);
|
|
5245
5299
|
}
|
|
5246
|
-
return focusIndex$1(
|
|
5300
|
+
return focusIndex$1(editor, matchIndex - 1);
|
|
5247
5301
|
};
|
|
5248
5302
|
|
|
5249
5303
|
const focusNextMatchButton = state => {
|
|
@@ -7123,18 +7177,6 @@ const closeDetails = editor => {
|
|
|
7123
7177
|
};
|
|
7124
7178
|
};
|
|
7125
7179
|
|
|
7126
|
-
const getWidgetState = (editor, id) => {
|
|
7127
|
-
const {
|
|
7128
|
-
widgets
|
|
7129
|
-
} = editor;
|
|
7130
|
-
for (const widget of widgets) {
|
|
7131
|
-
if (widget.id === id) {
|
|
7132
|
-
return widget.newState;
|
|
7133
|
-
}
|
|
7134
|
-
}
|
|
7135
|
-
return undefined;
|
|
7136
|
-
};
|
|
7137
|
-
|
|
7138
7180
|
const getCompletionState = editor => {
|
|
7139
7181
|
return getWidgetState(editor, Completion);
|
|
7140
7182
|
};
|
|
@@ -8713,12 +8755,12 @@ const wrapWidgetCommand = (widgetId, fn) => {
|
|
|
8713
8755
|
const widgetCommands = {
|
|
8714
8756
|
'ColorPicker.handleSliderPointerDown': ColorPicker$1,
|
|
8715
8757
|
'ColorPicker.handleSliderPointerMove': ColorPicker$1,
|
|
8716
|
-
'FindWidget.focusNext': Find,
|
|
8717
|
-
'FindWidget.focusPrevious': Find,
|
|
8758
|
+
// 'FindWidget.focusNext': WidgetId.Find,
|
|
8759
|
+
// 'FindWidget.focusPrevious': WidgetId.Find,
|
|
8718
8760
|
'FindWidget.close': Find,
|
|
8719
|
-
'FindWidget.focusIndex': Find,
|
|
8720
|
-
'FindWidget.focusFirst': Find,
|
|
8721
|
-
'FindWidget.focusLast': Find,
|
|
8761
|
+
// 'FindWidget.focusIndex': WidgetId.Find,
|
|
8762
|
+
// 'FindWidget.focusFirst': WidgetId.Find,
|
|
8763
|
+
// 'FindWidget.focusLast': WidgetId.Find,
|
|
8722
8764
|
'FindWidget.toggleReplace': Find,
|
|
8723
8765
|
'FindWidget.handleFocus': Find,
|
|
8724
8766
|
'FindWidget.handleBlur': Find,
|
|
@@ -9089,11 +9131,11 @@ const getSymbolName = kind => {
|
|
|
9089
9131
|
const getCompletionFileIcon = kind => {
|
|
9090
9132
|
switch (kind) {
|
|
9091
9133
|
case File:
|
|
9092
|
-
return EmptyString;
|
|
9134
|
+
return EmptyString$1;
|
|
9093
9135
|
case Folder:
|
|
9094
|
-
return EmptyString;
|
|
9136
|
+
return EmptyString$1;
|
|
9095
9137
|
default:
|
|
9096
|
-
return EmptyString;
|
|
9138
|
+
return EmptyString$1;
|
|
9097
9139
|
}
|
|
9098
9140
|
};
|
|
9099
9141
|
|