@lvce-editor/editor-worker 3.26.0 → 3.28.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 +551 -514
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -2,7 +2,7 @@ const commands = Object.create(null);
|
|
|
2
2
|
const registerCommand = (key, fn) => {
|
|
3
3
|
commands[key] = fn;
|
|
4
4
|
};
|
|
5
|
-
const register
|
|
5
|
+
const register = commandMap => {
|
|
6
6
|
for (const [key, value] of Object.entries(commandMap)) {
|
|
7
7
|
registerCommand(key, value);
|
|
8
8
|
}
|
|
@@ -144,16 +144,16 @@ const IndentMore = 'indentMore';
|
|
|
144
144
|
const InsertLineBreak = 'insertLineBreak';
|
|
145
145
|
const ToggleBlockComment = 'toggleBlockComment';
|
|
146
146
|
|
|
147
|
-
const
|
|
148
|
-
const
|
|
149
|
-
|
|
147
|
+
const map$1 = Object.create(null);
|
|
148
|
+
const set$7 = (id, widget) => {
|
|
149
|
+
map$1[id] = widget;
|
|
150
150
|
};
|
|
151
|
-
const get$
|
|
152
|
-
return
|
|
151
|
+
const get$7 = id => {
|
|
152
|
+
return map$1[id];
|
|
153
153
|
};
|
|
154
154
|
|
|
155
155
|
const getModule$2 = id => {
|
|
156
|
-
return get$
|
|
156
|
+
return get$7(id);
|
|
157
157
|
};
|
|
158
158
|
|
|
159
159
|
const applyWidgetChange = (editor, widget, changes) => {
|
|
@@ -587,7 +587,7 @@ const alloc = length => {
|
|
|
587
587
|
const clone = selections => {
|
|
588
588
|
return alloc(selections.length);
|
|
589
589
|
};
|
|
590
|
-
const map
|
|
590
|
+
const map = (selections, fn) => {
|
|
591
591
|
const newSelections = clone(selections);
|
|
592
592
|
for (let i = 0; i < newSelections.length; i += 4) {
|
|
593
593
|
const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
|
|
@@ -1021,11 +1021,11 @@ const setText = (editor, text) => {
|
|
|
1021
1021
|
};
|
|
1022
1022
|
|
|
1023
1023
|
const editors = Object.create(null);
|
|
1024
|
-
const get$
|
|
1024
|
+
const get$6 = id => {
|
|
1025
1025
|
number$1(id);
|
|
1026
1026
|
return editors[id];
|
|
1027
1027
|
};
|
|
1028
|
-
const set$
|
|
1028
|
+
const set$6 = (id, oldEditor, newEditor) => {
|
|
1029
1029
|
number$1(id);
|
|
1030
1030
|
object(oldEditor);
|
|
1031
1031
|
object(newEditor);
|
|
@@ -1073,10 +1073,10 @@ const number = value => {
|
|
|
1073
1073
|
const state$1$1 = {
|
|
1074
1074
|
callbacks: Object.create(null)
|
|
1075
1075
|
};
|
|
1076
|
-
const set$
|
|
1076
|
+
const set$5 = (id, fn) => {
|
|
1077
1077
|
state$1$1.callbacks[id] = fn;
|
|
1078
1078
|
};
|
|
1079
|
-
const get$
|
|
1079
|
+
const get$5 = id => {
|
|
1080
1080
|
return state$1$1.callbacks[id];
|
|
1081
1081
|
};
|
|
1082
1082
|
const remove$6 = id => {
|
|
@@ -1110,7 +1110,7 @@ const registerPromise = () => {
|
|
|
1110
1110
|
resolve,
|
|
1111
1111
|
promise
|
|
1112
1112
|
} = withResolvers$2();
|
|
1113
|
-
set$
|
|
1113
|
+
set$5(id, resolve);
|
|
1114
1114
|
return {
|
|
1115
1115
|
id,
|
|
1116
1116
|
promise
|
|
@@ -1118,7 +1118,7 @@ const registerPromise = () => {
|
|
|
1118
1118
|
};
|
|
1119
1119
|
const resolve = (id, args) => {
|
|
1120
1120
|
number(id);
|
|
1121
|
-
const fn = get$
|
|
1121
|
+
const fn = get$5(id);
|
|
1122
1122
|
if (!fn) {
|
|
1123
1123
|
console.log(args);
|
|
1124
1124
|
warn$1(`callback ${id} may already be disposed`);
|
|
@@ -1468,23 +1468,23 @@ const state$8 = {
|
|
|
1468
1468
|
*/
|
|
1469
1469
|
ipc: undefined
|
|
1470
1470
|
};
|
|
1471
|
-
const get$
|
|
1471
|
+
const get$4 = () => {
|
|
1472
1472
|
return state$8.ipc;
|
|
1473
1473
|
};
|
|
1474
|
-
const set$
|
|
1474
|
+
const set$4 = ipc => {
|
|
1475
1475
|
state$8.ipc = ipc;
|
|
1476
1476
|
};
|
|
1477
1477
|
|
|
1478
1478
|
const invoke$4 = (method, ...params) => {
|
|
1479
|
-
const ipc = get$
|
|
1479
|
+
const ipc = get$4();
|
|
1480
1480
|
return invoke$5(ipc, method, ...params);
|
|
1481
1481
|
};
|
|
1482
1482
|
const invokeAndTransfer$1 = async (method, ...params) => {
|
|
1483
|
-
const ipc = get$
|
|
1483
|
+
const ipc = get$4();
|
|
1484
1484
|
return invokeAndTransfer$2(ipc, method, ...params);
|
|
1485
1485
|
};
|
|
1486
1486
|
const listen$8 = ipc => {
|
|
1487
|
-
set$
|
|
1487
|
+
set$4(ipc);
|
|
1488
1488
|
};
|
|
1489
1489
|
|
|
1490
1490
|
const invoke$3 = async (method, ...params) => {
|
|
@@ -1860,7 +1860,7 @@ const createEditor = async ({
|
|
|
1860
1860
|
...newEditor3,
|
|
1861
1861
|
focused: true
|
|
1862
1862
|
};
|
|
1863
|
-
set$
|
|
1863
|
+
set$6(id, emptyEditor, newEditor4);
|
|
1864
1864
|
await invoke$2(TextDocumentSyncFull, uri, id, languageId, content);
|
|
1865
1865
|
};
|
|
1866
1866
|
|
|
@@ -2883,7 +2883,7 @@ const moveSelectionDown = (selections, i, selectionStartRow, selectionStartColum
|
|
|
2883
2883
|
moveRangeToPosition$1(selections, i, selectionEndRow + 1, selectionEndColumn);
|
|
2884
2884
|
};
|
|
2885
2885
|
const getNewSelections$9 = selections => {
|
|
2886
|
-
return map
|
|
2886
|
+
return map(selections, moveSelectionDown);
|
|
2887
2887
|
};
|
|
2888
2888
|
const cursorDown = editor => {
|
|
2889
2889
|
const {
|
|
@@ -2919,7 +2919,7 @@ const moveSelectionWithoutIntlSegmenter = (selections, i, selectionStartRow, sel
|
|
|
2919
2919
|
}
|
|
2920
2920
|
};
|
|
2921
2921
|
const getNewSelections$8 = selections => {
|
|
2922
|
-
return map
|
|
2922
|
+
return map(selections, moveSelectionWithoutIntlSegmenter);
|
|
2923
2923
|
};
|
|
2924
2924
|
const cursorVertical = (editor, getPosition, getEdgePosition, delta) => {
|
|
2925
2925
|
const {
|
|
@@ -3698,10 +3698,10 @@ const state$4 = {
|
|
|
3698
3698
|
y: 0,
|
|
3699
3699
|
editor: undefined
|
|
3700
3700
|
};
|
|
3701
|
-
const get$
|
|
3701
|
+
const get$3 = () => {
|
|
3702
3702
|
return state$4;
|
|
3703
3703
|
};
|
|
3704
|
-
const set$
|
|
3704
|
+
const set$3 = (editor, timeout, x, y) => {
|
|
3705
3705
|
state$4.editor = editor;
|
|
3706
3706
|
state$4.timeout = timeout;
|
|
3707
3707
|
state$4.x = x;
|
|
@@ -3727,7 +3727,7 @@ const onHoverIdle = async () => {
|
|
|
3727
3727
|
x,
|
|
3728
3728
|
y,
|
|
3729
3729
|
editor
|
|
3730
|
-
} = get$
|
|
3730
|
+
} = get$3();
|
|
3731
3731
|
at(editor, x, y);
|
|
3732
3732
|
await showHover$1();
|
|
3733
3733
|
};
|
|
@@ -3738,12 +3738,12 @@ const handleMouseMove = (editor, x, y) => {
|
|
|
3738
3738
|
if (!editor.hoverEnabled) {
|
|
3739
3739
|
return editor;
|
|
3740
3740
|
}
|
|
3741
|
-
const oldState = get$
|
|
3741
|
+
const oldState = get$3();
|
|
3742
3742
|
if (oldState.timeout !== -1) {
|
|
3743
3743
|
clearTimeout(oldState.timeout);
|
|
3744
3744
|
}
|
|
3745
3745
|
const timeout = setTimeout(onHoverIdle, hoverDelay);
|
|
3746
|
-
set$
|
|
3746
|
+
set$3(editor, timeout, x, y);
|
|
3747
3747
|
return editor;
|
|
3748
3748
|
};
|
|
3749
3749
|
|
|
@@ -4800,7 +4800,7 @@ const filterCompletionItems = (completionItems, word) => {
|
|
|
4800
4800
|
};
|
|
4801
4801
|
|
|
4802
4802
|
const getEditor = editorUid => {
|
|
4803
|
-
const instance = get$
|
|
4803
|
+
const instance = get$6(editorUid);
|
|
4804
4804
|
if (!instance) {
|
|
4805
4805
|
throw new Error(`editor ${editorUid} not found`);
|
|
4806
4806
|
}
|
|
@@ -4843,7 +4843,7 @@ const getWordAtOffset = editor => {
|
|
|
4843
4843
|
}
|
|
4844
4844
|
return '';
|
|
4845
4845
|
};
|
|
4846
|
-
const handleEditorType$
|
|
4846
|
+
const handleEditorType$2 = (editorUid, state, text) => {
|
|
4847
4847
|
const editor = getEditor(editorUid);
|
|
4848
4848
|
const {
|
|
4849
4849
|
unfilteredItems,
|
|
@@ -4873,7 +4873,7 @@ const handleEditorType$1 = (editorUid, state, text) => {
|
|
|
4873
4873
|
finalDeltaY
|
|
4874
4874
|
};
|
|
4875
4875
|
};
|
|
4876
|
-
const handleEditorDeleteLeft$
|
|
4876
|
+
const handleEditorDeleteLeft$2 = (editorUid, state) => {
|
|
4877
4877
|
const editor = getEditor(editorUid);
|
|
4878
4878
|
const {
|
|
4879
4879
|
unfilteredItems,
|
|
@@ -4981,7 +4981,7 @@ const openCompletion = async editor => {
|
|
|
4981
4981
|
...editor,
|
|
4982
4982
|
widgets: newWidgets
|
|
4983
4983
|
};
|
|
4984
|
-
set$
|
|
4984
|
+
set$6(uid, editor, newEditor);
|
|
4985
4985
|
const newCompletionWidget = await loadContent$2(uid, completionWidget.newState);
|
|
4986
4986
|
const FocusEditorCompletions = EditorCompletion;
|
|
4987
4987
|
await setAdditionalFocus(FocusEditorCompletions);
|
|
@@ -6145,10 +6145,10 @@ const state$1 = {
|
|
|
6145
6145
|
const has = languageId => {
|
|
6146
6146
|
return languageId in state$1.tokenizers;
|
|
6147
6147
|
};
|
|
6148
|
-
const set$
|
|
6148
|
+
const set$2 = (languageId, tokenizer) => {
|
|
6149
6149
|
state$1.tokenizers[languageId] = tokenizer;
|
|
6150
6150
|
};
|
|
6151
|
-
const get$
|
|
6151
|
+
const get$2 = languageId => {
|
|
6152
6152
|
return state$1.tokenizers[languageId];
|
|
6153
6153
|
};
|
|
6154
6154
|
const isPending = languageId => {
|
|
@@ -6169,10 +6169,10 @@ const {
|
|
|
6169
6169
|
} = createRpc(SyntaxHighlightingWorker);
|
|
6170
6170
|
|
|
6171
6171
|
const tokenMaps = Object.create(null);
|
|
6172
|
-
const set$
|
|
6172
|
+
const set$1 = (languageId, tokenMap) => {
|
|
6173
6173
|
tokenMaps[languageId] = tokenMap;
|
|
6174
6174
|
};
|
|
6175
|
-
const get$
|
|
6175
|
+
const get$1 = languageId => {
|
|
6176
6176
|
return tokenMaps[languageId] || {};
|
|
6177
6177
|
};
|
|
6178
6178
|
|
|
@@ -6183,7 +6183,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
6183
6183
|
}
|
|
6184
6184
|
if (getEnabled$1()) {
|
|
6185
6185
|
const tokenMap = await invoke$1('Tokenizer.load', languageId, tokenizePath);
|
|
6186
|
-
set$
|
|
6186
|
+
set$1(languageId, tokenMap);
|
|
6187
6187
|
return;
|
|
6188
6188
|
}
|
|
6189
6189
|
try {
|
|
@@ -6199,8 +6199,8 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
6199
6199
|
console.warn(`tokenizer.TokenMap should be an object in "${tokenizePath}"`);
|
|
6200
6200
|
return;
|
|
6201
6201
|
}
|
|
6202
|
-
set$
|
|
6203
|
-
set$
|
|
6202
|
+
set$1(languageId, tokenizer.TokenMap);
|
|
6203
|
+
set$2(languageId, tokenizer);
|
|
6204
6204
|
} catch (error) {
|
|
6205
6205
|
// TODO better error handling
|
|
6206
6206
|
console.error(error);
|
|
@@ -6209,7 +6209,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
6209
6209
|
};
|
|
6210
6210
|
const getTokenizer = languageId => {
|
|
6211
6211
|
if (has(languageId)) {
|
|
6212
|
-
return get$
|
|
6212
|
+
return get$2(languageId);
|
|
6213
6213
|
}
|
|
6214
6214
|
if (isPending(languageId)) {
|
|
6215
6215
|
return TokenizePlainText;
|
|
@@ -6218,10 +6218,10 @@ const getTokenizer = languageId => {
|
|
|
6218
6218
|
};
|
|
6219
6219
|
|
|
6220
6220
|
const tokenizers = Object.create(null);
|
|
6221
|
-
const set
|
|
6221
|
+
const set = (id, value) => {
|
|
6222
6222
|
tokenizers[id] = value;
|
|
6223
6223
|
};
|
|
6224
|
-
const get
|
|
6224
|
+
const get = id => {
|
|
6225
6225
|
return tokenizers[id] || TokenizePlainText;
|
|
6226
6226
|
};
|
|
6227
6227
|
|
|
@@ -6238,7 +6238,7 @@ const setLanguageId = async (editor, languageId, tokenizePath) => {
|
|
|
6238
6238
|
await loadTokenizer(languageId, tokenizePath);
|
|
6239
6239
|
const tokenizer = getTokenizer(languageId);
|
|
6240
6240
|
const newTokenizerId = tokenizerId + 1;
|
|
6241
|
-
set
|
|
6241
|
+
set(newTokenizerId, tokenizer);
|
|
6242
6242
|
const latest = getEditor(editor.uid);
|
|
6243
6243
|
if (!latest) {
|
|
6244
6244
|
return editor;
|
|
@@ -6497,7 +6497,7 @@ const getHoverPositionXy = (editor, rowIndex, wordStart, documentationHeight) =>
|
|
|
6497
6497
|
};
|
|
6498
6498
|
const getEditorHoverInfo = async (editorUid, position) => {
|
|
6499
6499
|
number$1(editorUid);
|
|
6500
|
-
const instance = get$
|
|
6500
|
+
const instance = get$6(editorUid);
|
|
6501
6501
|
const editor = instance.newState;
|
|
6502
6502
|
const {
|
|
6503
6503
|
selections
|
|
@@ -7511,7 +7511,8 @@ const create = () => {
|
|
|
7511
7511
|
x: 0,
|
|
7512
7512
|
y: 0,
|
|
7513
7513
|
width: 0,
|
|
7514
|
-
height: 0
|
|
7514
|
+
height: 0,
|
|
7515
|
+
borderSize: 1
|
|
7515
7516
|
},
|
|
7516
7517
|
newState: {
|
|
7517
7518
|
content: '',
|
|
@@ -7519,7 +7520,8 @@ const create = () => {
|
|
|
7519
7520
|
x: 0,
|
|
7520
7521
|
y: 0,
|
|
7521
7522
|
width: 0,
|
|
7522
|
-
height: 0
|
|
7523
|
+
height: 0,
|
|
7524
|
+
borderSize: 1
|
|
7523
7525
|
}
|
|
7524
7526
|
};
|
|
7525
7527
|
return completionWidget;
|
|
@@ -8188,7 +8190,7 @@ const getTokensViewport = (editor, startLineIndex, endLineIndex) => {
|
|
|
8188
8190
|
lines,
|
|
8189
8191
|
languageId
|
|
8190
8192
|
} = editor;
|
|
8191
|
-
const tokenizer = get
|
|
8193
|
+
const tokenizer = get(tokenizerId);
|
|
8192
8194
|
const {
|
|
8193
8195
|
hasArrayReturn,
|
|
8194
8196
|
tokenizeLine,
|
|
@@ -8452,7 +8454,7 @@ const getLineInfosViewport = (editor, tokens, embeddedResults, minLineY, maxLine
|
|
|
8452
8454
|
decorations,
|
|
8453
8455
|
languageId
|
|
8454
8456
|
} = editor;
|
|
8455
|
-
const tokenMap = get$
|
|
8457
|
+
const tokenMap = get$1(languageId);
|
|
8456
8458
|
let offset = minLineOffset;
|
|
8457
8459
|
const tabSize = 2;
|
|
8458
8460
|
for (let i = minLineY; i < maxLineY; i++) {
|
|
@@ -8637,30 +8639,22 @@ const getSelectionsVirtualDom = selections => {
|
|
|
8637
8639
|
return dom;
|
|
8638
8640
|
};
|
|
8639
8641
|
|
|
8640
|
-
const map = Object.create(null);
|
|
8641
|
-
const set = (id, widget) => {
|
|
8642
|
-
map[id] = widget;
|
|
8643
|
-
};
|
|
8644
|
-
const get = id => {
|
|
8645
|
-
return map[id];
|
|
8646
|
-
};
|
|
8647
|
-
|
|
8648
8642
|
const addWidget$1 = widget => {
|
|
8649
|
-
const module = get(widget.id);
|
|
8643
|
+
const module = get$7(widget.id);
|
|
8650
8644
|
if (!module) {
|
|
8651
8645
|
throw new Error('unsupported widget');
|
|
8652
8646
|
}
|
|
8653
8647
|
return module.add(widget);
|
|
8654
8648
|
};
|
|
8655
8649
|
const renderWidget = widget => {
|
|
8656
|
-
const module = get(widget.id);
|
|
8650
|
+
const module = get$7(widget.id);
|
|
8657
8651
|
if (!module) {
|
|
8658
8652
|
throw new Error(`unsupported widget`);
|
|
8659
8653
|
}
|
|
8660
8654
|
return module.render(widget);
|
|
8661
8655
|
};
|
|
8662
8656
|
const removeWidget$1 = widget => {
|
|
8663
|
-
const module = get(widget.id);
|
|
8657
|
+
const module = get$7(widget.id);
|
|
8664
8658
|
if (!module) {
|
|
8665
8659
|
throw new Error(`unsupported widget`);
|
|
8666
8660
|
}
|
|
@@ -8821,7 +8815,7 @@ const renderWidgets = {
|
|
|
8821
8815
|
};
|
|
8822
8816
|
const render$b = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
|
|
8823
8817
|
const renderEditor = async id => {
|
|
8824
|
-
const instance = get$
|
|
8818
|
+
const instance = get$6(id);
|
|
8825
8819
|
if (!instance) {
|
|
8826
8820
|
return [];
|
|
8827
8821
|
}
|
|
@@ -8830,7 +8824,7 @@ const renderEditor = async id => {
|
|
|
8830
8824
|
newState
|
|
8831
8825
|
} = instance;
|
|
8832
8826
|
const commands = [];
|
|
8833
|
-
set$
|
|
8827
|
+
set$6(id, newState, newState);
|
|
8834
8828
|
for (const item of render$b) {
|
|
8835
8829
|
if (!item.isEqual(oldState, newState)) {
|
|
8836
8830
|
const result = await item.apply(oldState, newState);
|
|
@@ -8901,19 +8895,19 @@ const widgetCommands = {
|
|
|
8901
8895
|
'FindWidget.focusPreviousMatchButton': Find,
|
|
8902
8896
|
'FindWidget.focusCloseButton': Find,
|
|
8903
8897
|
'EditorCompletion.handleWheel': Completion,
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
'EditorCompletion.
|
|
8907
|
-
|
|
8908
|
-
|
|
8898
|
+
'EditorCompletion.focusFirst': Completion,
|
|
8899
|
+
'EditorCompletion.focusNext': Completion,
|
|
8900
|
+
'EditorCompletion.focusPrevious': Completion,
|
|
8901
|
+
'EditorCompletion.focusIndex': Completion,
|
|
8902
|
+
'EditorCompletion.focusLast': Completion
|
|
8909
8903
|
};
|
|
8910
8904
|
|
|
8911
8905
|
// TODO wrap commands globally, not per editor
|
|
8912
8906
|
// TODO only store editor state in editor worker, not in renderer worker also
|
|
8913
8907
|
const wrapCommand = fn => async (editorUid, ...args) => {
|
|
8914
|
-
const oldInstance = get$
|
|
8908
|
+
const oldInstance = get$6(editorUid);
|
|
8915
8909
|
const newEditor = await fn(oldInstance.newState, ...args);
|
|
8916
|
-
set$
|
|
8910
|
+
set$6(editorUid, oldInstance.newState, newEditor);
|
|
8917
8911
|
// TODO if possible, rendering should be sync
|
|
8918
8912
|
const commands = await renderEditor(editorUid);
|
|
8919
8913
|
newEditor.commands = commands;
|
|
@@ -9070,8 +9064,8 @@ const commandMap = {
|
|
|
9070
9064
|
'EditorCompletion.focusPrevious': focusPrevious,
|
|
9071
9065
|
'EditorCompletion.handleEditorBlur': handleEditorBlur,
|
|
9072
9066
|
'EditorCompletion.handleEditorClick': handleEditorClick,
|
|
9073
|
-
'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$
|
|
9074
|
-
'EditorCompletion.handleEditorType': handleEditorType$
|
|
9067
|
+
'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$2,
|
|
9068
|
+
'EditorCompletion.handleEditorType': handleEditorType$2,
|
|
9075
9069
|
'EditorCompletion.handleWheel': handelWheel,
|
|
9076
9070
|
'EditorCompletion.loadContent': loadContent$2,
|
|
9077
9071
|
'EditorCompletion.openDetails': openDetails,
|
|
@@ -9112,430 +9106,74 @@ const commandMap = {
|
|
|
9112
9106
|
};
|
|
9113
9107
|
wrapCommands(commandMap);
|
|
9114
9108
|
|
|
9115
|
-
const
|
|
9116
|
-
const
|
|
9117
|
-
const
|
|
9118
|
-
const
|
|
9119
|
-
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
className: FileIcon,
|
|
9124
|
-
src: icon,
|
|
9125
|
-
role: None,
|
|
9126
|
-
childCount: 0
|
|
9127
|
-
};
|
|
9128
|
-
};
|
|
9129
|
-
|
|
9130
|
-
const getIconDom = (fileIcon, symbolName) => {
|
|
9131
|
-
if (fileIcon) {
|
|
9132
|
-
return getFileIconVirtualDom(fileIcon);
|
|
9109
|
+
const MessagePort$1 = 1;
|
|
9110
|
+
const ModuleWorker = 2;
|
|
9111
|
+
const ReferencePort = 3;
|
|
9112
|
+
const ModuleWorkerAndMessagePort = 8;
|
|
9113
|
+
const Auto = () => {
|
|
9114
|
+
// @ts-ignore
|
|
9115
|
+
if (globalThis.acceptPort) {
|
|
9116
|
+
return MessagePort$1;
|
|
9133
9117
|
}
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9118
|
+
// @ts-ignore
|
|
9119
|
+
if (globalThis.acceptReferencePort) {
|
|
9120
|
+
return ReferencePort;
|
|
9121
|
+
}
|
|
9122
|
+
return ModuleWorkerAndMessagePort;
|
|
9139
9123
|
};
|
|
9140
9124
|
|
|
9141
|
-
const
|
|
9142
|
-
|
|
9143
|
-
className: Label,
|
|
9144
|
-
childCount: 1
|
|
9145
|
-
};
|
|
9146
|
-
const completionHighlight = {
|
|
9147
|
-
type: Span,
|
|
9148
|
-
className: EditorCompletionItemHighlight,
|
|
9149
|
-
childCount: 1
|
|
9125
|
+
const getData$1 = event => {
|
|
9126
|
+
return event.data;
|
|
9150
9127
|
};
|
|
9151
|
-
const
|
|
9152
|
-
if (
|
|
9153
|
-
return
|
|
9154
|
-
}
|
|
9155
|
-
const dom = [];
|
|
9156
|
-
const labelDom = {
|
|
9157
|
-
type: Div,
|
|
9158
|
-
className: Label,
|
|
9159
|
-
childCount: 0
|
|
9160
|
-
};
|
|
9161
|
-
dom.push(labelDom);
|
|
9162
|
-
let position = 0;
|
|
9163
|
-
for (let i = 0; i < highlights.length; i += 2) {
|
|
9164
|
-
const highlightStart = highlights[i];
|
|
9165
|
-
const highlightEnd = highlights[i + 1];
|
|
9166
|
-
if (position < highlightStart) {
|
|
9167
|
-
const beforeText = label.slice(position, highlightStart);
|
|
9168
|
-
labelDom.childCount++;
|
|
9169
|
-
dom.push(text(beforeText));
|
|
9170
|
-
}
|
|
9171
|
-
const highlightText = label.slice(highlightStart, highlightEnd);
|
|
9172
|
-
labelDom.childCount++;
|
|
9173
|
-
dom.push(completionHighlight, text(highlightText));
|
|
9174
|
-
position = highlightEnd;
|
|
9175
|
-
}
|
|
9176
|
-
if (position < label.length) {
|
|
9177
|
-
const afterText = label.slice(position);
|
|
9178
|
-
labelDom.childCount++;
|
|
9179
|
-
dom.push(text(afterText));
|
|
9128
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
9129
|
+
if (!value) {
|
|
9130
|
+
return;
|
|
9180
9131
|
}
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
const getCompletionItemVirtualDom = visibleItem => {
|
|
9185
|
-
const {
|
|
9186
|
-
top,
|
|
9187
|
-
label,
|
|
9188
|
-
symbolName,
|
|
9189
|
-
highlights,
|
|
9190
|
-
focused,
|
|
9191
|
-
deprecated,
|
|
9192
|
-
fileIcon
|
|
9193
|
-
} = visibleItem;
|
|
9194
|
-
let className = EditorCompletionItem;
|
|
9195
|
-
if (focused) {
|
|
9196
|
-
className += ' ' + EditorCompletionItemFocused;
|
|
9132
|
+
if (isTransferrable(value)) {
|
|
9133
|
+
transferrables.push(value);
|
|
9134
|
+
return;
|
|
9197
9135
|
}
|
|
9198
|
-
if (
|
|
9199
|
-
|
|
9136
|
+
if (Array.isArray(value)) {
|
|
9137
|
+
for (const item of value) {
|
|
9138
|
+
walkValue(item, transferrables, isTransferrable);
|
|
9139
|
+
}
|
|
9140
|
+
return;
|
|
9200
9141
|
}
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
childCount: 2
|
|
9207
|
-
}, getIconDom(fileIcon, symbolName), ...getHighlightedLabelDom(label, highlights)];
|
|
9208
|
-
};
|
|
9209
|
-
|
|
9210
|
-
const getCompletionItemsVirtualDom = visibleItems => {
|
|
9211
|
-
if (visibleItems.length === 0) {
|
|
9212
|
-
return [{
|
|
9213
|
-
type: Div,
|
|
9214
|
-
childCount: 1
|
|
9215
|
-
}, text(noResults$1())];
|
|
9142
|
+
if (typeof value === 'object') {
|
|
9143
|
+
for (const property of Object.values(value)) {
|
|
9144
|
+
walkValue(property, transferrables, isTransferrable);
|
|
9145
|
+
}
|
|
9146
|
+
return;
|
|
9216
9147
|
}
|
|
9217
|
-
const root = {
|
|
9218
|
-
type: Div,
|
|
9219
|
-
childCount: visibleItems.length
|
|
9220
|
-
};
|
|
9221
|
-
const dom = [root, ...visibleItems.flatMap(getCompletionItemVirtualDom)];
|
|
9222
|
-
return dom;
|
|
9223
9148
|
};
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
const Value = 2;
|
|
9227
|
-
const Function = 3;
|
|
9228
|
-
const Variable = 4;
|
|
9229
|
-
const Keyword = 5;
|
|
9230
|
-
const Folder = 6;
|
|
9231
|
-
const File = 7;
|
|
9232
|
-
const Field = 8;
|
|
9233
|
-
|
|
9234
|
-
const SymbolProperty = 'SymbolProperty';
|
|
9235
|
-
const SymbolValue = 'SymbolValue';
|
|
9236
|
-
const SymbolFunction = 'SymbolFunction';
|
|
9237
|
-
const SymbolVariable = 'SymbolVariable';
|
|
9238
|
-
const SymbolKeyword = 'SymbolKeyword';
|
|
9239
|
-
const SymbolDefault = 'SymbolDefault';
|
|
9240
|
-
const SymbolField = 'SymbolField';
|
|
9241
|
-
const SymbolNone = '';
|
|
9242
|
-
|
|
9243
|
-
const getSymbolName = kind => {
|
|
9244
|
-
switch (kind) {
|
|
9245
|
-
case Property:
|
|
9246
|
-
return SymbolProperty;
|
|
9247
|
-
case Value:
|
|
9248
|
-
return SymbolValue;
|
|
9249
|
-
case Function:
|
|
9250
|
-
return SymbolFunction;
|
|
9251
|
-
case Variable:
|
|
9252
|
-
return SymbolVariable;
|
|
9253
|
-
case Keyword:
|
|
9254
|
-
return SymbolKeyword;
|
|
9255
|
-
case Field:
|
|
9256
|
-
return SymbolField;
|
|
9257
|
-
case File:
|
|
9258
|
-
return SymbolNone;
|
|
9259
|
-
default:
|
|
9260
|
-
return SymbolDefault;
|
|
9261
|
-
}
|
|
9149
|
+
const isMessagePort = value => {
|
|
9150
|
+
return value && value instanceof MessagePort;
|
|
9262
9151
|
};
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
const getCompletionFileIcon = kind => {
|
|
9266
|
-
switch (kind) {
|
|
9267
|
-
case File:
|
|
9268
|
-
return EmptyString$1;
|
|
9269
|
-
case Folder:
|
|
9270
|
-
return EmptyString$1;
|
|
9271
|
-
default:
|
|
9272
|
-
return EmptyString$1;
|
|
9273
|
-
}
|
|
9152
|
+
const isMessagePortMain = value => {
|
|
9153
|
+
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
9274
9154
|
};
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
const {
|
|
9278
|
-
matches
|
|
9279
|
-
} = item;
|
|
9280
|
-
return matches.slice(1);
|
|
9155
|
+
const isOffscreenCanvas = value => {
|
|
9156
|
+
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
9281
9157
|
};
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
return item.label;
|
|
9158
|
+
const isInstanceOf = (value, constructorName) => {
|
|
9159
|
+
return value?.constructor?.name === constructorName;
|
|
9285
9160
|
};
|
|
9286
|
-
const
|
|
9287
|
-
return
|
|
9288
|
-
label: getLabel(item),
|
|
9289
|
-
symbolName: getSymbolName(item.kind),
|
|
9290
|
-
top: i * itemHeight,
|
|
9291
|
-
highlights: getHighlights(item),
|
|
9292
|
-
focused: i === focusedIndex,
|
|
9293
|
-
deprecated: item.flags & Deprecated,
|
|
9294
|
-
fileIcon: getCompletionFileIcon(item.kind)
|
|
9295
|
-
};
|
|
9161
|
+
const isSocket = value => {
|
|
9162
|
+
return isInstanceOf(value, 'Socket');
|
|
9296
9163
|
};
|
|
9297
|
-
|
|
9298
|
-
const
|
|
9299
|
-
const
|
|
9300
|
-
|
|
9301
|
-
|
|
9302
|
-
|
|
9164
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
9165
|
+
const isTransferrable = value => {
|
|
9166
|
+
for (const fn of transferrables) {
|
|
9167
|
+
if (fn(value)) {
|
|
9168
|
+
return true;
|
|
9169
|
+
}
|
|
9303
9170
|
}
|
|
9304
|
-
return
|
|
9171
|
+
return false;
|
|
9305
9172
|
};
|
|
9306
|
-
|
|
9307
|
-
const
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
},
|
|
9311
|
-
apply(oldState, newState) {
|
|
9312
|
-
const visibleItems = getVisibleItems(newState.items, newState.itemHeight, newState.leadingWord, newState.minLineY, newState.maxLineY, newState.focusedIndex);
|
|
9313
|
-
const dom = getCompletionItemsVirtualDom(visibleItems);
|
|
9314
|
-
return ['setDom', dom];
|
|
9315
|
-
}
|
|
9316
|
-
};
|
|
9317
|
-
const renderBounds$4 = {
|
|
9318
|
-
isEqual(oldState, newState) {
|
|
9319
|
-
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.x === newState.x && oldState.y === newState.y;
|
|
9320
|
-
},
|
|
9321
|
-
apply(oldState, newState) {
|
|
9322
|
-
const {
|
|
9323
|
-
x,
|
|
9324
|
-
y,
|
|
9325
|
-
width,
|
|
9326
|
-
height
|
|
9327
|
-
} = newState;
|
|
9328
|
-
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
9329
|
-
}
|
|
9330
|
-
};
|
|
9331
|
-
const renderHeight = {
|
|
9332
|
-
isEqual(oldState, newState) {
|
|
9333
|
-
return oldState.items.length === newState.items.length;
|
|
9334
|
-
},
|
|
9335
|
-
apply(oldState, newState) {
|
|
9336
|
-
const {
|
|
9337
|
-
itemHeight
|
|
9338
|
-
} = newState;
|
|
9339
|
-
const contentHeight = newState.items.length * itemHeight;
|
|
9340
|
-
return [/* method */SetContentHeight, /* contentHeight */contentHeight];
|
|
9341
|
-
}
|
|
9342
|
-
};
|
|
9343
|
-
const renderNegativeMargin = {
|
|
9344
|
-
isEqual(oldState, newState) {
|
|
9345
|
-
return oldState.deltaY === newState.deltaY;
|
|
9346
|
-
},
|
|
9347
|
-
apply(oldState, newState) {
|
|
9348
|
-
return [/* method */SetNegativeMargin, /* negativeMargin */-newState.deltaY];
|
|
9349
|
-
}
|
|
9350
|
-
};
|
|
9351
|
-
const renderScrollBar = {
|
|
9352
|
-
isEqual(oldState, newState) {
|
|
9353
|
-
return oldState.negativeMargin === newState.negativeMargin && oldState.deltaY === newState.deltaY && oldState.height === newState.height && oldState.finalDeltaY === newState.finalDeltaY && oldState.items.length === newState.items.length;
|
|
9354
|
-
},
|
|
9355
|
-
apply(oldState, newState) {
|
|
9356
|
-
const total = newState.items.length;
|
|
9357
|
-
const contentHeight = total * newState.itemHeight;
|
|
9358
|
-
const scrollBarHeight = getScrollBarSize(newState.height, contentHeight, newState.minimumSliderSize);
|
|
9359
|
-
const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, scrollBarHeight);
|
|
9360
|
-
return [/* method */SetScrollBar, /* scrollBarY */scrollBarY, /* scrollBarHeight */scrollBarHeight];
|
|
9361
|
-
}
|
|
9362
|
-
};
|
|
9363
|
-
const render$a = [renderItems, renderBounds$4, renderHeight, renderNegativeMargin, renderScrollBar];
|
|
9364
|
-
const renderCompletion = (oldState, newState) => {
|
|
9365
|
-
const commands = [];
|
|
9366
|
-
for (const item of render$a) {
|
|
9367
|
-
if (!item.isEqual(oldState, newState)) {
|
|
9368
|
-
commands.push(item.apply(oldState, newState));
|
|
9369
|
-
}
|
|
9370
|
-
}
|
|
9371
|
-
return commands;
|
|
9372
|
-
};
|
|
9373
|
-
|
|
9374
|
-
const removeWidget = widget => {
|
|
9375
|
-
// @ts-ignore
|
|
9376
|
-
return [['Viewlet.send', widget.newState.uid, 'dispose']];
|
|
9377
|
-
};
|
|
9378
|
-
|
|
9379
|
-
const render$9 = widget => {
|
|
9380
|
-
const commands = renderCompletion(widget.oldState, widget.newState);
|
|
9381
|
-
const wrappedCommands = [];
|
|
9382
|
-
const uid = widget.newState.uid;
|
|
9383
|
-
for (const command of commands) {
|
|
9384
|
-
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
9385
|
-
}
|
|
9386
|
-
return wrappedCommands;
|
|
9387
|
-
};
|
|
9388
|
-
const add$5 = widget => {
|
|
9389
|
-
const commands = render$9(widget);
|
|
9390
|
-
const id = 'EditorCompletion';
|
|
9391
|
-
// TODO how to generate a unique integer id
|
|
9392
|
-
// that doesn't collide with ids created in renderer worker?
|
|
9393
|
-
const uid = widget.newState.uid;
|
|
9394
|
-
const allCommands = [];
|
|
9395
|
-
allCommands.push(['Viewlet.create', id, uid]);
|
|
9396
|
-
allCommands.push(...commands);
|
|
9397
|
-
return allCommands;
|
|
9398
|
-
};
|
|
9399
|
-
const remove$5 = removeWidget;
|
|
9400
|
-
const handleEditorType = (editor, state) => {
|
|
9401
|
-
const {
|
|
9402
|
-
unfilteredItems,
|
|
9403
|
-
itemHeight,
|
|
9404
|
-
maxHeight
|
|
9405
|
-
} = state;
|
|
9406
|
-
const {
|
|
9407
|
-
selections
|
|
9408
|
-
} = editor;
|
|
9409
|
-
const rowIndex = selections[0];
|
|
9410
|
-
const columnIndex = selections[1];
|
|
9411
|
-
const x$1 = x(editor, rowIndex, columnIndex);
|
|
9412
|
-
const y$1 = y(editor, rowIndex);
|
|
9413
|
-
const wordAtOffset = getWordBefore(editor, rowIndex, columnIndex);
|
|
9414
|
-
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
9415
|
-
const newMinLineY = 0;
|
|
9416
|
-
const newMaxLineY = Math.min(items.length, 8);
|
|
9417
|
-
const height = getListHeight(items.length, itemHeight, maxHeight);
|
|
9418
|
-
const finalDeltaY = items.length * itemHeight - height;
|
|
9419
|
-
return {
|
|
9420
|
-
...state,
|
|
9421
|
-
items,
|
|
9422
|
-
x: x$1,
|
|
9423
|
-
y: y$1,
|
|
9424
|
-
minLineY: newMinLineY,
|
|
9425
|
-
maxLineY: newMaxLineY,
|
|
9426
|
-
leadingWord: wordAtOffset,
|
|
9427
|
-
height,
|
|
9428
|
-
finalDeltaY
|
|
9429
|
-
};
|
|
9430
|
-
};
|
|
9431
|
-
const handleEditorDeleteLeft = (editor, state) => {
|
|
9432
|
-
const {
|
|
9433
|
-
unfilteredItems,
|
|
9434
|
-
itemHeight,
|
|
9435
|
-
maxHeight
|
|
9436
|
-
} = state;
|
|
9437
|
-
const {
|
|
9438
|
-
selections
|
|
9439
|
-
} = editor;
|
|
9440
|
-
const rowIndex = selections[0];
|
|
9441
|
-
const columnIndex = selections[1];
|
|
9442
|
-
const x$1 = x(editor, rowIndex, columnIndex);
|
|
9443
|
-
const y$1 = y(editor, rowIndex);
|
|
9444
|
-
const wordAtOffset = getWordBefore(editor, rowIndex, columnIndex);
|
|
9445
|
-
if (!wordAtOffset) {
|
|
9446
|
-
return undefined;
|
|
9447
|
-
}
|
|
9448
|
-
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
9449
|
-
const newMaxLineY = Math.min(items.length, 8);
|
|
9450
|
-
const height = getListHeight(items.length, itemHeight, maxHeight);
|
|
9451
|
-
return {
|
|
9452
|
-
...state,
|
|
9453
|
-
items,
|
|
9454
|
-
x: x$1,
|
|
9455
|
-
y: y$1,
|
|
9456
|
-
maxLineY: newMaxLineY,
|
|
9457
|
-
leadingWord: wordAtOffset,
|
|
9458
|
-
height
|
|
9459
|
-
};
|
|
9460
|
-
};
|
|
9461
|
-
|
|
9462
|
-
const EditorCompletionWidget = {
|
|
9463
|
-
__proto__: null,
|
|
9464
|
-
add: add$5,
|
|
9465
|
-
handleEditorDeleteLeft,
|
|
9466
|
-
handleEditorType,
|
|
9467
|
-
remove: remove$5,
|
|
9468
|
-
render: render$9
|
|
9469
|
-
};
|
|
9470
|
-
|
|
9471
|
-
const MessagePort$1 = 1;
|
|
9472
|
-
const ModuleWorker = 2;
|
|
9473
|
-
const ReferencePort = 3;
|
|
9474
|
-
const ModuleWorkerAndMessagePort = 8;
|
|
9475
|
-
const Auto = () => {
|
|
9476
|
-
// @ts-ignore
|
|
9477
|
-
if (globalThis.acceptPort) {
|
|
9478
|
-
return MessagePort$1;
|
|
9479
|
-
}
|
|
9480
|
-
// @ts-ignore
|
|
9481
|
-
if (globalThis.acceptReferencePort) {
|
|
9482
|
-
return ReferencePort;
|
|
9483
|
-
}
|
|
9484
|
-
return ModuleWorkerAndMessagePort;
|
|
9485
|
-
};
|
|
9486
|
-
|
|
9487
|
-
const getData$1 = event => {
|
|
9488
|
-
return event.data;
|
|
9489
|
-
};
|
|
9490
|
-
const walkValue = (value, transferrables, isTransferrable) => {
|
|
9491
|
-
if (!value) {
|
|
9492
|
-
return;
|
|
9493
|
-
}
|
|
9494
|
-
if (isTransferrable(value)) {
|
|
9495
|
-
transferrables.push(value);
|
|
9496
|
-
return;
|
|
9497
|
-
}
|
|
9498
|
-
if (Array.isArray(value)) {
|
|
9499
|
-
for (const item of value) {
|
|
9500
|
-
walkValue(item, transferrables, isTransferrable);
|
|
9501
|
-
}
|
|
9502
|
-
return;
|
|
9503
|
-
}
|
|
9504
|
-
if (typeof value === 'object') {
|
|
9505
|
-
for (const property of Object.values(value)) {
|
|
9506
|
-
walkValue(property, transferrables, isTransferrable);
|
|
9507
|
-
}
|
|
9508
|
-
return;
|
|
9509
|
-
}
|
|
9510
|
-
};
|
|
9511
|
-
const isMessagePort = value => {
|
|
9512
|
-
return value && value instanceof MessagePort;
|
|
9513
|
-
};
|
|
9514
|
-
const isMessagePortMain = value => {
|
|
9515
|
-
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
9516
|
-
};
|
|
9517
|
-
const isOffscreenCanvas = value => {
|
|
9518
|
-
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
9519
|
-
};
|
|
9520
|
-
const isInstanceOf = (value, constructorName) => {
|
|
9521
|
-
return value?.constructor?.name === constructorName;
|
|
9522
|
-
};
|
|
9523
|
-
const isSocket = value => {
|
|
9524
|
-
return isInstanceOf(value, 'Socket');
|
|
9525
|
-
};
|
|
9526
|
-
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
9527
|
-
const isTransferrable = value => {
|
|
9528
|
-
for (const fn of transferrables) {
|
|
9529
|
-
if (fn(value)) {
|
|
9530
|
-
return true;
|
|
9531
|
-
}
|
|
9532
|
-
}
|
|
9533
|
-
return false;
|
|
9534
|
-
};
|
|
9535
|
-
const getTransferrables = value => {
|
|
9536
|
-
const transferrables = [];
|
|
9537
|
-
walkValue(value, transferrables, isTransferrable);
|
|
9538
|
-
return transferrables;
|
|
9173
|
+
const getTransferrables = value => {
|
|
9174
|
+
const transferrables = [];
|
|
9175
|
+
walkValue(value, transferrables, isTransferrable);
|
|
9176
|
+
return transferrables;
|
|
9539
9177
|
};
|
|
9540
9178
|
const attachEvents = that => {
|
|
9541
9179
|
const handleMessage = (...args) => {
|
|
@@ -9944,8 +9582,7 @@ const listen$1 = async ({
|
|
|
9944
9582
|
};
|
|
9945
9583
|
|
|
9946
9584
|
const listen = async () => {
|
|
9947
|
-
register
|
|
9948
|
-
register(Completion, EditorCompletionWidget);
|
|
9585
|
+
register(commandMap);
|
|
9949
9586
|
const ipc = await listen$1({
|
|
9950
9587
|
method: Auto()
|
|
9951
9588
|
});
|
|
@@ -10039,7 +9676,7 @@ const renderContent$1 = {
|
|
|
10039
9676
|
return ['Viewlet.setDom2', newState.uid, dom];
|
|
10040
9677
|
}
|
|
10041
9678
|
};
|
|
10042
|
-
const renderBounds$
|
|
9679
|
+
const renderBounds$4 = {
|
|
10043
9680
|
isEqual(oldState, newState) {
|
|
10044
9681
|
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
10045
9682
|
},
|
|
@@ -10053,10 +9690,10 @@ const renderBounds$3 = {
|
|
|
10053
9690
|
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
10054
9691
|
}
|
|
10055
9692
|
};
|
|
10056
|
-
const render$
|
|
9693
|
+
const render$a = [renderContent$1, renderBounds$4, renderColor, renderOffsetX];
|
|
10057
9694
|
const renderFull$1 = (oldState, newState) => {
|
|
10058
9695
|
const commands = [];
|
|
10059
|
-
for (const item of render$
|
|
9696
|
+
for (const item of render$a) {
|
|
10060
9697
|
if (!item.isEqual(oldState, newState)) {
|
|
10061
9698
|
commands.push(item.apply(oldState, newState));
|
|
10062
9699
|
}
|
|
@@ -10064,7 +9701,12 @@ const renderFull$1 = (oldState, newState) => {
|
|
|
10064
9701
|
return commands;
|
|
10065
9702
|
};
|
|
10066
9703
|
|
|
10067
|
-
const
|
|
9704
|
+
const removeWidget = widget => {
|
|
9705
|
+
// @ts-ignore
|
|
9706
|
+
return [['Viewlet.send', widget.newState.uid, 'dispose']];
|
|
9707
|
+
};
|
|
9708
|
+
|
|
9709
|
+
const render$9 = widget => {
|
|
10068
9710
|
const commands = renderFull$1(widget.oldState, widget.newState);
|
|
10069
9711
|
const wrappedCommands = [];
|
|
10070
9712
|
const uid = widget.newState.uid;
|
|
@@ -10077,10 +9719,10 @@ const render$7 = widget => {
|
|
|
10077
9719
|
}
|
|
10078
9720
|
return wrappedCommands;
|
|
10079
9721
|
};
|
|
10080
|
-
const add$
|
|
10081
|
-
return addWidget(widget, 'ColorPicker', render$
|
|
9722
|
+
const add$5 = widget => {
|
|
9723
|
+
return addWidget(widget, 'ColorPicker', render$9);
|
|
10082
9724
|
};
|
|
10083
|
-
const remove$
|
|
9725
|
+
const remove$5 = removeWidget;
|
|
10084
9726
|
const Commands$1 = {
|
|
10085
9727
|
'ColorPicker.handleSliderPointerDown': handleSliderPointerDown,
|
|
10086
9728
|
'ColorPicker.handleSliderPointerMove': handleSliderPointerMove
|
|
@@ -10089,9 +9731,9 @@ const Commands$1 = {
|
|
|
10089
9731
|
const EditorColorPickerWidget = {
|
|
10090
9732
|
__proto__: null,
|
|
10091
9733
|
Commands: Commands$1,
|
|
10092
|
-
add: add$
|
|
10093
|
-
remove: remove$
|
|
10094
|
-
render: render$
|
|
9734
|
+
add: add$5,
|
|
9735
|
+
remove: remove$5,
|
|
9736
|
+
render: render$9
|
|
10095
9737
|
};
|
|
10096
9738
|
|
|
10097
9739
|
const getCompletionDetailVirtualDom = content => {
|
|
@@ -10135,7 +9777,7 @@ const renderContent = {
|
|
|
10135
9777
|
return ['Viewlet.setDom2', newState.uid, dom];
|
|
10136
9778
|
}
|
|
10137
9779
|
};
|
|
10138
|
-
const renderBounds$
|
|
9780
|
+
const renderBounds$3 = {
|
|
10139
9781
|
isEqual(oldState, newState) {
|
|
10140
9782
|
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
10141
9783
|
},
|
|
@@ -10149,32 +9791,427 @@ const renderBounds$2 = {
|
|
|
10149
9791
|
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
10150
9792
|
}
|
|
10151
9793
|
};
|
|
10152
|
-
const render$
|
|
9794
|
+
const render$8 = [renderContent, renderBounds$3];
|
|
10153
9795
|
const renderFull = (oldState, newState) => {
|
|
10154
|
-
return renderParts(render$
|
|
9796
|
+
return renderParts(render$8, oldState, newState);
|
|
10155
9797
|
};
|
|
10156
9798
|
|
|
10157
|
-
const
|
|
10158
|
-
const
|
|
10159
|
-
|
|
10160
|
-
|
|
10161
|
-
|
|
10162
|
-
|
|
10163
|
-
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
9799
|
+
const getPositionAtCursor = editor => {
|
|
9800
|
+
const {
|
|
9801
|
+
selections
|
|
9802
|
+
} = editor;
|
|
9803
|
+
const rowIndex = selections[0];
|
|
9804
|
+
const columnIndex = selections[1];
|
|
9805
|
+
const x$1 = x(editor, rowIndex, columnIndex);
|
|
9806
|
+
const y$1 = y(editor, rowIndex);
|
|
9807
|
+
return {
|
|
9808
|
+
x: x$1,
|
|
9809
|
+
y: y$1,
|
|
9810
|
+
rowIndex,
|
|
9811
|
+
columnIndex
|
|
9812
|
+
};
|
|
9813
|
+
};
|
|
9814
|
+
|
|
9815
|
+
const render$7 = widget => {
|
|
9816
|
+
const commands = renderFull(widget.oldState, widget.newState);
|
|
9817
|
+
const wrappedCommands = [];
|
|
9818
|
+
const uid = widget.newState.uid;
|
|
9819
|
+
for (const command of commands) {
|
|
9820
|
+
if (command[0] === 'Viewlet.setDom2') {
|
|
9821
|
+
wrappedCommands.push(command);
|
|
9822
|
+
} else {
|
|
9823
|
+
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
9824
|
+
}
|
|
9825
|
+
}
|
|
9826
|
+
return wrappedCommands;
|
|
9827
|
+
};
|
|
9828
|
+
const add$4 = widget => {
|
|
9829
|
+
return addWidget(widget, 'EditorCompletionDetails', render$7);
|
|
9830
|
+
};
|
|
9831
|
+
const remove$4 = removeWidget;
|
|
9832
|
+
const handleEditorType$1 = (editor, state) => {
|
|
9833
|
+
const completionState = getCompletionState(editor);
|
|
9834
|
+
if (!completionState) {
|
|
9835
|
+
return editor;
|
|
9836
|
+
}
|
|
9837
|
+
const {
|
|
9838
|
+
x
|
|
9839
|
+
} = getPositionAtCursor(editor);
|
|
9840
|
+
const detailX = x + completionState.width - state.borderSize;
|
|
9841
|
+
return {
|
|
9842
|
+
...state,
|
|
9843
|
+
x: detailX
|
|
9844
|
+
};
|
|
9845
|
+
};
|
|
9846
|
+
const handleEditorDeleteLeft$1 = (editor, state) => {
|
|
9847
|
+
const completionState = getCompletionState(editor);
|
|
9848
|
+
if (!completionState) {
|
|
9849
|
+
return editor;
|
|
9850
|
+
}
|
|
9851
|
+
const {
|
|
9852
|
+
x
|
|
9853
|
+
} = getPositionAtCursor(editor);
|
|
9854
|
+
const detailX = x + completionState.width - state.borderSize;
|
|
9855
|
+
return {
|
|
9856
|
+
...state,
|
|
9857
|
+
x: detailX
|
|
9858
|
+
};
|
|
10172
9859
|
};
|
|
10173
|
-
const remove$3 = removeWidget;
|
|
10174
9860
|
|
|
10175
9861
|
const EditorCompletionDetailWidget = {
|
|
9862
|
+
__proto__: null,
|
|
9863
|
+
add: add$4,
|
|
9864
|
+
handleEditorDeleteLeft: handleEditorDeleteLeft$1,
|
|
9865
|
+
handleEditorType: handleEditorType$1,
|
|
9866
|
+
remove: remove$4,
|
|
9867
|
+
render: render$7
|
|
9868
|
+
};
|
|
9869
|
+
|
|
9870
|
+
const CheckBox = 'checkbox';
|
|
9871
|
+
const Group = 'group';
|
|
9872
|
+
const None = 'none';
|
|
9873
|
+
const Option = 'option';
|
|
9874
|
+
|
|
9875
|
+
const getFileIconVirtualDom = icon => {
|
|
9876
|
+
return {
|
|
9877
|
+
type: Img,
|
|
9878
|
+
className: FileIcon,
|
|
9879
|
+
src: icon,
|
|
9880
|
+
role: None,
|
|
9881
|
+
childCount: 0
|
|
9882
|
+
};
|
|
9883
|
+
};
|
|
9884
|
+
|
|
9885
|
+
const getIconDom = (fileIcon, symbolName) => {
|
|
9886
|
+
if (fileIcon) {
|
|
9887
|
+
return getFileIconVirtualDom(fileIcon);
|
|
9888
|
+
}
|
|
9889
|
+
return {
|
|
9890
|
+
type: Div,
|
|
9891
|
+
className: `${ColoredMaskIcon} ${symbolName}`,
|
|
9892
|
+
childCount: 0
|
|
9893
|
+
};
|
|
9894
|
+
};
|
|
9895
|
+
|
|
9896
|
+
const label1 = {
|
|
9897
|
+
type: Div,
|
|
9898
|
+
className: Label,
|
|
9899
|
+
childCount: 1
|
|
9900
|
+
};
|
|
9901
|
+
const completionHighlight = {
|
|
9902
|
+
type: Span,
|
|
9903
|
+
className: EditorCompletionItemHighlight,
|
|
9904
|
+
childCount: 1
|
|
9905
|
+
};
|
|
9906
|
+
const getHighlightedLabelDom = (label, highlights) => {
|
|
9907
|
+
if (highlights.length === 0) {
|
|
9908
|
+
return [label1, text(label)];
|
|
9909
|
+
}
|
|
9910
|
+
const dom = [];
|
|
9911
|
+
const labelDom = {
|
|
9912
|
+
type: Div,
|
|
9913
|
+
className: Label,
|
|
9914
|
+
childCount: 0
|
|
9915
|
+
};
|
|
9916
|
+
dom.push(labelDom);
|
|
9917
|
+
let position = 0;
|
|
9918
|
+
for (let i = 0; i < highlights.length; i += 2) {
|
|
9919
|
+
const highlightStart = highlights[i];
|
|
9920
|
+
const highlightEnd = highlights[i + 1];
|
|
9921
|
+
if (position < highlightStart) {
|
|
9922
|
+
const beforeText = label.slice(position, highlightStart);
|
|
9923
|
+
labelDom.childCount++;
|
|
9924
|
+
dom.push(text(beforeText));
|
|
9925
|
+
}
|
|
9926
|
+
const highlightText = label.slice(highlightStart, highlightEnd);
|
|
9927
|
+
labelDom.childCount++;
|
|
9928
|
+
dom.push(completionHighlight, text(highlightText));
|
|
9929
|
+
position = highlightEnd;
|
|
9930
|
+
}
|
|
9931
|
+
if (position < label.length) {
|
|
9932
|
+
const afterText = label.slice(position);
|
|
9933
|
+
labelDom.childCount++;
|
|
9934
|
+
dom.push(text(afterText));
|
|
9935
|
+
}
|
|
9936
|
+
return dom;
|
|
9937
|
+
};
|
|
9938
|
+
|
|
9939
|
+
const getCompletionItemVirtualDom = visibleItem => {
|
|
9940
|
+
const {
|
|
9941
|
+
top,
|
|
9942
|
+
label,
|
|
9943
|
+
symbolName,
|
|
9944
|
+
highlights,
|
|
9945
|
+
focused,
|
|
9946
|
+
deprecated,
|
|
9947
|
+
fileIcon
|
|
9948
|
+
} = visibleItem;
|
|
9949
|
+
let className = EditorCompletionItem;
|
|
9950
|
+
if (focused) {
|
|
9951
|
+
className += ' ' + EditorCompletionItemFocused;
|
|
9952
|
+
}
|
|
9953
|
+
if (deprecated) {
|
|
9954
|
+
className += ' ' + EditorCompletionItemDeprecated;
|
|
9955
|
+
}
|
|
9956
|
+
return [{
|
|
9957
|
+
type: Div,
|
|
9958
|
+
role: Option,
|
|
9959
|
+
className,
|
|
9960
|
+
top,
|
|
9961
|
+
childCount: 2
|
|
9962
|
+
}, getIconDom(fileIcon, symbolName), ...getHighlightedLabelDom(label, highlights)];
|
|
9963
|
+
};
|
|
9964
|
+
|
|
9965
|
+
const getCompletionItemsVirtualDom = visibleItems => {
|
|
9966
|
+
if (visibleItems.length === 0) {
|
|
9967
|
+
return [{
|
|
9968
|
+
type: Div,
|
|
9969
|
+
childCount: 1
|
|
9970
|
+
}, text(noResults$1())];
|
|
9971
|
+
}
|
|
9972
|
+
const root = {
|
|
9973
|
+
type: Div,
|
|
9974
|
+
childCount: visibleItems.length
|
|
9975
|
+
};
|
|
9976
|
+
const dom = [root, ...visibleItems.flatMap(getCompletionItemVirtualDom)];
|
|
9977
|
+
return dom;
|
|
9978
|
+
};
|
|
9979
|
+
|
|
9980
|
+
const Property = 1;
|
|
9981
|
+
const Value = 2;
|
|
9982
|
+
const Function = 3;
|
|
9983
|
+
const Variable = 4;
|
|
9984
|
+
const Keyword = 5;
|
|
9985
|
+
const Folder = 6;
|
|
9986
|
+
const File = 7;
|
|
9987
|
+
const Field = 8;
|
|
9988
|
+
|
|
9989
|
+
const SymbolProperty = 'SymbolProperty';
|
|
9990
|
+
const SymbolValue = 'SymbolValue';
|
|
9991
|
+
const SymbolFunction = 'SymbolFunction';
|
|
9992
|
+
const SymbolVariable = 'SymbolVariable';
|
|
9993
|
+
const SymbolKeyword = 'SymbolKeyword';
|
|
9994
|
+
const SymbolDefault = 'SymbolDefault';
|
|
9995
|
+
const SymbolField = 'SymbolField';
|
|
9996
|
+
const SymbolNone = '';
|
|
9997
|
+
|
|
9998
|
+
const getSymbolName = kind => {
|
|
9999
|
+
switch (kind) {
|
|
10000
|
+
case Property:
|
|
10001
|
+
return SymbolProperty;
|
|
10002
|
+
case Value:
|
|
10003
|
+
return SymbolValue;
|
|
10004
|
+
case Function:
|
|
10005
|
+
return SymbolFunction;
|
|
10006
|
+
case Variable:
|
|
10007
|
+
return SymbolVariable;
|
|
10008
|
+
case Keyword:
|
|
10009
|
+
return SymbolKeyword;
|
|
10010
|
+
case Field:
|
|
10011
|
+
return SymbolField;
|
|
10012
|
+
case File:
|
|
10013
|
+
return SymbolNone;
|
|
10014
|
+
default:
|
|
10015
|
+
return SymbolDefault;
|
|
10016
|
+
}
|
|
10017
|
+
};
|
|
10018
|
+
|
|
10019
|
+
// TODO
|
|
10020
|
+
const getCompletionFileIcon = kind => {
|
|
10021
|
+
switch (kind) {
|
|
10022
|
+
case File:
|
|
10023
|
+
return EmptyString$1;
|
|
10024
|
+
case Folder:
|
|
10025
|
+
return EmptyString$1;
|
|
10026
|
+
default:
|
|
10027
|
+
return EmptyString$1;
|
|
10028
|
+
}
|
|
10029
|
+
};
|
|
10030
|
+
|
|
10031
|
+
const getHighlights = item => {
|
|
10032
|
+
const {
|
|
10033
|
+
matches
|
|
10034
|
+
} = item;
|
|
10035
|
+
return matches.slice(1);
|
|
10036
|
+
};
|
|
10037
|
+
|
|
10038
|
+
const getLabel = item => {
|
|
10039
|
+
return item.label;
|
|
10040
|
+
};
|
|
10041
|
+
const getVisibleIem = (item, itemHeight, leadingWord, i, focusedIndex) => {
|
|
10042
|
+
return {
|
|
10043
|
+
label: getLabel(item),
|
|
10044
|
+
symbolName: getSymbolName(item.kind),
|
|
10045
|
+
top: i * itemHeight,
|
|
10046
|
+
highlights: getHighlights(item),
|
|
10047
|
+
focused: i === focusedIndex,
|
|
10048
|
+
deprecated: item.flags & Deprecated,
|
|
10049
|
+
fileIcon: getCompletionFileIcon(item.kind)
|
|
10050
|
+
};
|
|
10051
|
+
};
|
|
10052
|
+
|
|
10053
|
+
const getVisibleItems = (filteredItems, itemHeight, leadingWord, minLineY, maxLineY, focusedIndex) => {
|
|
10054
|
+
const visibleItems = [];
|
|
10055
|
+
for (let i = minLineY; i < maxLineY; i++) {
|
|
10056
|
+
const filteredItem = filteredItems[i];
|
|
10057
|
+
visibleItems.push(getVisibleIem(filteredItem, itemHeight, leadingWord, i, focusedIndex));
|
|
10058
|
+
}
|
|
10059
|
+
return visibleItems;
|
|
10060
|
+
};
|
|
10061
|
+
|
|
10062
|
+
const renderItems = {
|
|
10063
|
+
isEqual(oldState, newState) {
|
|
10064
|
+
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex;
|
|
10065
|
+
},
|
|
10066
|
+
apply(oldState, newState) {
|
|
10067
|
+
const visibleItems = getVisibleItems(newState.items, newState.itemHeight, newState.leadingWord, newState.minLineY, newState.maxLineY, newState.focusedIndex);
|
|
10068
|
+
const dom = getCompletionItemsVirtualDom(visibleItems);
|
|
10069
|
+
return ['setDom', dom];
|
|
10070
|
+
}
|
|
10071
|
+
};
|
|
10072
|
+
const renderBounds$2 = {
|
|
10073
|
+
isEqual(oldState, newState) {
|
|
10074
|
+
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.x === newState.x && oldState.y === newState.y;
|
|
10075
|
+
},
|
|
10076
|
+
apply(oldState, newState) {
|
|
10077
|
+
const {
|
|
10078
|
+
x,
|
|
10079
|
+
y,
|
|
10080
|
+
width,
|
|
10081
|
+
height
|
|
10082
|
+
} = newState;
|
|
10083
|
+
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
10084
|
+
}
|
|
10085
|
+
};
|
|
10086
|
+
const renderHeight = {
|
|
10087
|
+
isEqual(oldState, newState) {
|
|
10088
|
+
return oldState.items.length === newState.items.length;
|
|
10089
|
+
},
|
|
10090
|
+
apply(oldState, newState) {
|
|
10091
|
+
const {
|
|
10092
|
+
itemHeight
|
|
10093
|
+
} = newState;
|
|
10094
|
+
const contentHeight = newState.items.length * itemHeight;
|
|
10095
|
+
return [/* method */SetContentHeight, /* contentHeight */contentHeight];
|
|
10096
|
+
}
|
|
10097
|
+
};
|
|
10098
|
+
const renderNegativeMargin = {
|
|
10099
|
+
isEqual(oldState, newState) {
|
|
10100
|
+
return oldState.deltaY === newState.deltaY;
|
|
10101
|
+
},
|
|
10102
|
+
apply(oldState, newState) {
|
|
10103
|
+
return [/* method */SetNegativeMargin, /* negativeMargin */-newState.deltaY];
|
|
10104
|
+
}
|
|
10105
|
+
};
|
|
10106
|
+
const renderScrollBar = {
|
|
10107
|
+
isEqual(oldState, newState) {
|
|
10108
|
+
return oldState.negativeMargin === newState.negativeMargin && oldState.deltaY === newState.deltaY && oldState.height === newState.height && oldState.finalDeltaY === newState.finalDeltaY && oldState.items.length === newState.items.length;
|
|
10109
|
+
},
|
|
10110
|
+
apply(oldState, newState) {
|
|
10111
|
+
const total = newState.items.length;
|
|
10112
|
+
const contentHeight = total * newState.itemHeight;
|
|
10113
|
+
const scrollBarHeight = getScrollBarSize(newState.height, contentHeight, newState.minimumSliderSize);
|
|
10114
|
+
const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, scrollBarHeight);
|
|
10115
|
+
return [/* method */SetScrollBar, /* scrollBarY */scrollBarY, /* scrollBarHeight */scrollBarHeight];
|
|
10116
|
+
}
|
|
10117
|
+
};
|
|
10118
|
+
const render$6 = [renderItems, renderBounds$2, renderHeight, renderNegativeMargin, renderScrollBar];
|
|
10119
|
+
const renderCompletion = (oldState, newState) => {
|
|
10120
|
+
const commands = [];
|
|
10121
|
+
for (const item of render$6) {
|
|
10122
|
+
if (!item.isEqual(oldState, newState)) {
|
|
10123
|
+
commands.push(item.apply(oldState, newState));
|
|
10124
|
+
}
|
|
10125
|
+
}
|
|
10126
|
+
return commands;
|
|
10127
|
+
};
|
|
10128
|
+
|
|
10129
|
+
const render$5 = widget => {
|
|
10130
|
+
const commands = renderCompletion(widget.oldState, widget.newState);
|
|
10131
|
+
const wrappedCommands = [];
|
|
10132
|
+
const uid = widget.newState.uid;
|
|
10133
|
+
for (const command of commands) {
|
|
10134
|
+
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
10135
|
+
}
|
|
10136
|
+
return wrappedCommands;
|
|
10137
|
+
};
|
|
10138
|
+
const add$3 = widget => {
|
|
10139
|
+
const commands = render$5(widget);
|
|
10140
|
+
const id = 'EditorCompletion';
|
|
10141
|
+
// TODO how to generate a unique integer id
|
|
10142
|
+
// that doesn't collide with ids created in renderer worker?
|
|
10143
|
+
const uid = widget.newState.uid;
|
|
10144
|
+
const allCommands = [];
|
|
10145
|
+
allCommands.push(['Viewlet.create', id, uid]);
|
|
10146
|
+
allCommands.push(...commands);
|
|
10147
|
+
return allCommands;
|
|
10148
|
+
};
|
|
10149
|
+
const remove$3 = removeWidget;
|
|
10150
|
+
const handleEditorType = (editor, state) => {
|
|
10151
|
+
const {
|
|
10152
|
+
unfilteredItems,
|
|
10153
|
+
itemHeight,
|
|
10154
|
+
maxHeight
|
|
10155
|
+
} = state;
|
|
10156
|
+
const {
|
|
10157
|
+
x,
|
|
10158
|
+
y,
|
|
10159
|
+
rowIndex,
|
|
10160
|
+
columnIndex
|
|
10161
|
+
} = getPositionAtCursor(editor);
|
|
10162
|
+
const wordAtOffset = getWordBefore(editor, rowIndex, columnIndex);
|
|
10163
|
+
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
10164
|
+
const newMinLineY = 0;
|
|
10165
|
+
const newMaxLineY = Math.min(items.length, 8);
|
|
10166
|
+
const height = getListHeight(items.length, itemHeight, maxHeight);
|
|
10167
|
+
const finalDeltaY = items.length * itemHeight - height;
|
|
10168
|
+
return {
|
|
10169
|
+
...state,
|
|
10170
|
+
items,
|
|
10171
|
+
x,
|
|
10172
|
+
y,
|
|
10173
|
+
minLineY: newMinLineY,
|
|
10174
|
+
maxLineY: newMaxLineY,
|
|
10175
|
+
leadingWord: wordAtOffset,
|
|
10176
|
+
height,
|
|
10177
|
+
finalDeltaY
|
|
10178
|
+
};
|
|
10179
|
+
};
|
|
10180
|
+
const handleEditorDeleteLeft = (editor, state) => {
|
|
10181
|
+
const {
|
|
10182
|
+
unfilteredItems,
|
|
10183
|
+
itemHeight,
|
|
10184
|
+
maxHeight
|
|
10185
|
+
} = state;
|
|
10186
|
+
const {
|
|
10187
|
+
x,
|
|
10188
|
+
y,
|
|
10189
|
+
rowIndex,
|
|
10190
|
+
columnIndex
|
|
10191
|
+
} = getPositionAtCursor(editor);
|
|
10192
|
+
const wordAtOffset = getWordBefore(editor, rowIndex, columnIndex);
|
|
10193
|
+
if (!wordAtOffset) {
|
|
10194
|
+
return undefined;
|
|
10195
|
+
}
|
|
10196
|
+
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
10197
|
+
const newMaxLineY = Math.min(items.length, 8);
|
|
10198
|
+
const height = getListHeight(items.length, itemHeight, maxHeight);
|
|
10199
|
+
return {
|
|
10200
|
+
...state,
|
|
10201
|
+
items,
|
|
10202
|
+
x,
|
|
10203
|
+
y,
|
|
10204
|
+
maxLineY: newMaxLineY,
|
|
10205
|
+
leadingWord: wordAtOffset,
|
|
10206
|
+
height
|
|
10207
|
+
};
|
|
10208
|
+
};
|
|
10209
|
+
|
|
10210
|
+
const EditorCompletionWidget = {
|
|
10176
10211
|
__proto__: null,
|
|
10177
10212
|
add: add$3,
|
|
10213
|
+
handleEditorDeleteLeft,
|
|
10214
|
+
handleEditorType,
|
|
10178
10215
|
remove: remove$3,
|
|
10179
10216
|
render: render$5
|
|
10180
10217
|
};
|
|
@@ -10702,12 +10739,12 @@ const EditorSourceActionWidget = {
|
|
|
10702
10739
|
};
|
|
10703
10740
|
|
|
10704
10741
|
const registerWidgets = () => {
|
|
10705
|
-
set(ColorPicker$2, EditorColorPickerWidget);
|
|
10706
|
-
set(Completion, EditorCompletionWidget);
|
|
10707
|
-
set(CompletionDetail$1, EditorCompletionDetailWidget);
|
|
10708
|
-
set(Find, EditorFindWidget);
|
|
10709
|
-
set(Hover, EditorHoverWidget);
|
|
10710
|
-
set(SourceAction, EditorSourceActionWidget);
|
|
10742
|
+
set$7(ColorPicker$2, EditorColorPickerWidget);
|
|
10743
|
+
set$7(Completion, EditorCompletionWidget);
|
|
10744
|
+
set$7(CompletionDetail$1, EditorCompletionDetailWidget);
|
|
10745
|
+
set$7(Find, EditorFindWidget);
|
|
10746
|
+
set$7(Hover, EditorHoverWidget);
|
|
10747
|
+
set$7(SourceAction, EditorSourceActionWidget);
|
|
10711
10748
|
};
|
|
10712
10749
|
|
|
10713
10750
|
const main = async () => {
|