@lvce-editor/editor-worker 6.3.0 → 7.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 +565 -1488
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -263,7 +263,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
|
263
263
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
264
264
|
return create$1$1(message, errorProperty);
|
|
265
265
|
};
|
|
266
|
-
const create$
|
|
266
|
+
const create$d = (message, result) => {
|
|
267
267
|
return {
|
|
268
268
|
jsonrpc: Two,
|
|
269
269
|
id: message.id,
|
|
@@ -272,7 +272,7 @@ const create$e = (message, result) => {
|
|
|
272
272
|
};
|
|
273
273
|
const getSuccessResponse = (message, result) => {
|
|
274
274
|
const resultProperty = result ?? null;
|
|
275
|
-
return create$
|
|
275
|
+
return create$d(message, resultProperty);
|
|
276
276
|
};
|
|
277
277
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
278
278
|
try {
|
|
@@ -1082,7 +1082,7 @@ const invoke$6 = async (method, ...params) => {
|
|
|
1082
1082
|
return await worker.invoke(method, ...params);
|
|
1083
1083
|
};
|
|
1084
1084
|
|
|
1085
|
-
const loadContent$
|
|
1085
|
+
const loadContent$2 = async (state, parentUid) => {
|
|
1086
1086
|
const {
|
|
1087
1087
|
uid,
|
|
1088
1088
|
x,
|
|
@@ -1129,17 +1129,17 @@ const getModule$2 = id => {
|
|
|
1129
1129
|
return get$5(id);
|
|
1130
1130
|
};
|
|
1131
1131
|
|
|
1132
|
-
const applyWidgetChange = (editor, widget, changes) => {
|
|
1132
|
+
const applyWidgetChange = async (editor, widget, changes) => {
|
|
1133
1133
|
const module = getModule$2(widget.id);
|
|
1134
1134
|
if (changes.length === 1 && changes[0].origin === EditorType && module.handleEditorType) {
|
|
1135
|
-
const newState = module.handleEditorType(editor, widget.newState);
|
|
1135
|
+
const newState = await module.handleEditorType(editor, widget.newState);
|
|
1136
1136
|
return {
|
|
1137
1137
|
...widget,
|
|
1138
1138
|
newState
|
|
1139
1139
|
};
|
|
1140
1140
|
}
|
|
1141
1141
|
if (changes.length === 1 && changes[0].origin === DeleteLeft && module.handleEditorDeleteLeft) {
|
|
1142
|
-
const newState = module.handleEditorDeleteLeft(editor, widget.newState);
|
|
1142
|
+
const newState = await module.handleEditorDeleteLeft(editor, widget.newState);
|
|
1143
1143
|
return {
|
|
1144
1144
|
...widget,
|
|
1145
1145
|
newState
|
|
@@ -1148,14 +1148,14 @@ const applyWidgetChange = (editor, widget, changes) => {
|
|
|
1148
1148
|
return widget;
|
|
1149
1149
|
};
|
|
1150
1150
|
|
|
1151
|
-
const applyWidgetChanges = (editor, changes) => {
|
|
1151
|
+
const applyWidgetChanges = async (editor, changes) => {
|
|
1152
1152
|
const widgets = editor.widgets || [];
|
|
1153
1153
|
if (widgets.length === 0) {
|
|
1154
1154
|
return widgets;
|
|
1155
1155
|
}
|
|
1156
1156
|
const newWidgets = [];
|
|
1157
1157
|
for (const widget of widgets) {
|
|
1158
|
-
const newWidget = applyWidgetChange(editor, widget, changes);
|
|
1158
|
+
const newWidget = await applyWidgetChange(editor, widget, changes);
|
|
1159
1159
|
if (newWidget.newState) {
|
|
1160
1160
|
newWidgets.push(newWidget);
|
|
1161
1161
|
}
|
|
@@ -1163,6 +1163,20 @@ const applyWidgetChanges = (editor, changes) => {
|
|
|
1163
1163
|
return newWidgets;
|
|
1164
1164
|
};
|
|
1165
1165
|
|
|
1166
|
+
const editors = Object.create(null);
|
|
1167
|
+
const get$4 = id => {
|
|
1168
|
+
number(id);
|
|
1169
|
+
return editors[id];
|
|
1170
|
+
};
|
|
1171
|
+
const set$4 = (id, oldEditor, newEditor) => {
|
|
1172
|
+
object(oldEditor);
|
|
1173
|
+
object(newEditor);
|
|
1174
|
+
editors[id] = {
|
|
1175
|
+
oldState: oldEditor,
|
|
1176
|
+
newState: newEditor
|
|
1177
|
+
};
|
|
1178
|
+
};
|
|
1179
|
+
|
|
1166
1180
|
const clamp = (num, min, max) => {
|
|
1167
1181
|
number(num);
|
|
1168
1182
|
number(min);
|
|
@@ -1214,7 +1228,7 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
|
1214
1228
|
};
|
|
1215
1229
|
|
|
1216
1230
|
// TODO this should be in a separate scrolling module
|
|
1217
|
-
const setDeltaY$
|
|
1231
|
+
const setDeltaY$2 = (state, value) => {
|
|
1218
1232
|
object(state);
|
|
1219
1233
|
number(value);
|
|
1220
1234
|
const {
|
|
@@ -1365,15 +1379,11 @@ const getText$1 = state => {
|
|
|
1365
1379
|
// TDOO this doesn;t belong here
|
|
1366
1380
|
const getSelectionText = (textDocument, range) => {
|
|
1367
1381
|
object(textDocument);
|
|
1368
|
-
// console.log(range)
|
|
1369
|
-
// console.log(textDocument)
|
|
1370
1382
|
const startRowIndex = range.start.rowIndex;
|
|
1371
1383
|
const startColumnIndex = range.start.columnIndex;
|
|
1372
1384
|
const endRowIndex = Math.min(range.end.rowIndex, textDocument.lines.length - 1);
|
|
1373
1385
|
const endColumnIndex = range.end.columnIndex;
|
|
1374
1386
|
if (startRowIndex === endRowIndex) {
|
|
1375
|
-
// console.log(startRowIndex)
|
|
1376
|
-
// console.log(textDocument.lines)
|
|
1377
1387
|
return [textDocument.lines[startRowIndex].slice(startColumnIndex, endColumnIndex)];
|
|
1378
1388
|
}
|
|
1379
1389
|
const selectedLines = [textDocument.lines[startRowIndex].slice(startColumnIndex), ...textDocument.lines.slice(startRowIndex + 1, endRowIndex), textDocument.lines[endRowIndex].slice(0, endColumnIndex)];
|
|
@@ -1448,9 +1458,9 @@ const getSelectionPairs = (selections, i) => {
|
|
|
1448
1458
|
return [first, second, third, fourth, 0];
|
|
1449
1459
|
};
|
|
1450
1460
|
|
|
1451
|
-
const EmptyString
|
|
1461
|
+
const EmptyString = '';
|
|
1452
1462
|
const NewLine = '\n';
|
|
1453
|
-
const Space$
|
|
1463
|
+
const Space$1 = ' ';
|
|
1454
1464
|
const Tab$1 = '\t';
|
|
1455
1465
|
const DoubleQuote$1 = '"';
|
|
1456
1466
|
|
|
@@ -1534,7 +1544,7 @@ const measureTextWidth = (text, fontWeight, fontSize, fontFamily, letterSpacing,
|
|
|
1534
1544
|
|
|
1535
1545
|
const normalizeText = (text, normalize, tabSize) => {
|
|
1536
1546
|
if (normalize) {
|
|
1537
|
-
return text.replaceAll(Tab$1, Space$
|
|
1547
|
+
return text.replaceAll(Tab$1, Space$1.repeat(tabSize));
|
|
1538
1548
|
}
|
|
1539
1549
|
return text;
|
|
1540
1550
|
};
|
|
@@ -1822,9 +1832,9 @@ const applyEdit$1 = (editor, changes) => {
|
|
|
1822
1832
|
|
|
1823
1833
|
// TODO
|
|
1824
1834
|
const setDeltaYFixedValue$1 = (editor, value) => {
|
|
1825
|
-
return setDeltaY$
|
|
1835
|
+
return setDeltaY$2(editor, value);
|
|
1826
1836
|
};
|
|
1827
|
-
const setDeltaY$
|
|
1837
|
+
const setDeltaY$1 = (editor, value) => {
|
|
1828
1838
|
return setDeltaYFixedValue$1(editor, editor.deltaY + value);
|
|
1829
1839
|
};
|
|
1830
1840
|
const isAutoClosingChange = change => {
|
|
@@ -1869,7 +1879,7 @@ const scheduleSelections = (editor, selectionEdits) => {
|
|
|
1869
1879
|
* @param {Uint32Array|undefined} selectionChanges
|
|
1870
1880
|
* @returns
|
|
1871
1881
|
*/
|
|
1872
|
-
const scheduleDocumentAndCursorsSelections = (editor, changes, selectionChanges = undefined) => {
|
|
1882
|
+
const scheduleDocumentAndCursorsSelections = async (editor, changes, selectionChanges = undefined) => {
|
|
1873
1883
|
object(editor);
|
|
1874
1884
|
array(changes);
|
|
1875
1885
|
if (changes.length === 0) {
|
|
@@ -1898,7 +1908,8 @@ const scheduleDocumentAndCursorsSelections = (editor, changes, selectionChanges
|
|
|
1898
1908
|
invalidStartIndex,
|
|
1899
1909
|
autoClosingRanges
|
|
1900
1910
|
};
|
|
1901
|
-
|
|
1911
|
+
set$4(editor.uid, editor, newEditor);
|
|
1912
|
+
const newWidgets = await applyWidgetChanges(newEditor, changes);
|
|
1902
1913
|
const newEditor2 = {
|
|
1903
1914
|
...newEditor,
|
|
1904
1915
|
widgets: newWidgets
|
|
@@ -1931,11 +1942,7 @@ const scheduleDocumentAndCursorsSelectionIsUndo = (editor, changes) => {
|
|
|
1931
1942
|
|
|
1932
1943
|
// @ts-ignore
|
|
1933
1944
|
const scheduleDocument = async (editor, changes) => {
|
|
1934
|
-
// console.log('before')
|
|
1935
|
-
// console.log([...editor.lines])
|
|
1936
1945
|
const newLines = applyEdits(editor, changes);
|
|
1937
|
-
// console.log('after')
|
|
1938
|
-
// console.log([...editor.lines])
|
|
1939
1946
|
const invalidStartIndex = changes[0].start.rowIndex;
|
|
1940
1947
|
// if (editor.undoStack) {
|
|
1941
1948
|
// editor.undoStack.push(changes)
|
|
@@ -2017,23 +2024,6 @@ const setText = (editor, text) => {
|
|
|
2017
2024
|
};
|
|
2018
2025
|
};
|
|
2019
2026
|
|
|
2020
|
-
const editors = Object.create(null);
|
|
2021
|
-
const get$4 = id => {
|
|
2022
|
-
number(id);
|
|
2023
|
-
return editors[id];
|
|
2024
|
-
};
|
|
2025
|
-
const set$4 = (id, oldEditor, newEditor) => {
|
|
2026
|
-
number(id);
|
|
2027
|
-
object(oldEditor);
|
|
2028
|
-
object(newEditor);
|
|
2029
|
-
editors[id] = {
|
|
2030
|
-
oldState: oldEditor,
|
|
2031
|
-
newState: newEditor
|
|
2032
|
-
};
|
|
2033
|
-
};
|
|
2034
|
-
|
|
2035
|
-
const CompletionExecute = 'ExtensionHostCompletion.execute';
|
|
2036
|
-
const CompletionResolveExecute = 'ExtensionHostCompletion.executeResolve';
|
|
2037
2027
|
const HoverExecute = 'ExtensionHostHover.execute';
|
|
2038
2028
|
const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompletionProvider';
|
|
2039
2029
|
const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
|
|
@@ -2111,7 +2101,7 @@ const waitForFirstMessage = async port => {
|
|
|
2111
2101
|
return event;
|
|
2112
2102
|
};
|
|
2113
2103
|
|
|
2114
|
-
const create$
|
|
2104
|
+
const create$c = async () => {
|
|
2115
2105
|
const {
|
|
2116
2106
|
port1,
|
|
2117
2107
|
port2
|
|
@@ -2156,7 +2146,7 @@ const wrap$2 = port => {
|
|
|
2156
2146
|
|
|
2157
2147
|
const IpcParentWithExtensionHostWorker = {
|
|
2158
2148
|
__proto__: null,
|
|
2159
|
-
create: create$
|
|
2149
|
+
create: create$c,
|
|
2160
2150
|
wrap: wrap$2
|
|
2161
2151
|
};
|
|
2162
2152
|
|
|
@@ -2164,7 +2154,7 @@ const sendMessagePortToRendererProcess = async port => {
|
|
|
2164
2154
|
await invokeAndTransfer('SendMessagePortToRendererProcess.sendMessagePortToRendererProcess', port, 'HandleMessagePort.handleMessagePort');
|
|
2165
2155
|
};
|
|
2166
2156
|
|
|
2167
|
-
const create$
|
|
2157
|
+
const create$b = async () => {
|
|
2168
2158
|
const {
|
|
2169
2159
|
port1,
|
|
2170
2160
|
port2
|
|
@@ -2209,7 +2199,7 @@ const wrap$1 = port => {
|
|
|
2209
2199
|
|
|
2210
2200
|
const IpcParentWithRendererProcess = {
|
|
2211
2201
|
__proto__: null,
|
|
2212
|
-
create: create$
|
|
2202
|
+
create: create$b,
|
|
2213
2203
|
wrap: wrap$1
|
|
2214
2204
|
};
|
|
2215
2205
|
|
|
@@ -2217,7 +2207,7 @@ const sendMessagePortToSyntaxHighlightingWorker = async port => {
|
|
|
2217
2207
|
await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
|
|
2218
2208
|
};
|
|
2219
2209
|
|
|
2220
|
-
const create$
|
|
2210
|
+
const create$a = async () => {
|
|
2221
2211
|
const {
|
|
2222
2212
|
port1,
|
|
2223
2213
|
port2
|
|
@@ -2262,7 +2252,7 @@ const wrap = port => {
|
|
|
2262
2252
|
|
|
2263
2253
|
const IpcParentWithSyntaxHighlightingWorker = {
|
|
2264
2254
|
__proto__: null,
|
|
2265
|
-
create: create$
|
|
2255
|
+
create: create$a,
|
|
2266
2256
|
wrap
|
|
2267
2257
|
};
|
|
2268
2258
|
|
|
@@ -2279,7 +2269,7 @@ const getModule$1 = method => {
|
|
|
2279
2269
|
}
|
|
2280
2270
|
};
|
|
2281
2271
|
|
|
2282
|
-
const create$
|
|
2272
|
+
const create$9 = async ({
|
|
2283
2273
|
method,
|
|
2284
2274
|
...options
|
|
2285
2275
|
}) => {
|
|
@@ -2297,7 +2287,7 @@ const create$a = async ({
|
|
|
2297
2287
|
const createRpc = method => {
|
|
2298
2288
|
let _ipc;
|
|
2299
2289
|
const listen = async () => {
|
|
2300
|
-
const ipc = await create$
|
|
2290
|
+
const ipc = await create$9({
|
|
2301
2291
|
method
|
|
2302
2292
|
});
|
|
2303
2293
|
handleIpc(ipc);
|
|
@@ -2321,7 +2311,6 @@ const {
|
|
|
2321
2311
|
invoke: invoke$5} = createRpc(ExtensionHostWorker);
|
|
2322
2312
|
|
|
2323
2313
|
const ColorPicker$1 = 41;
|
|
2324
|
-
const CompletionDetail$1 = 999;
|
|
2325
2314
|
const EditorCompletion = 9;
|
|
2326
2315
|
const Empty = 0;
|
|
2327
2316
|
const FindWidget = 16;
|
|
@@ -2334,7 +2323,6 @@ const measureCharacterWidth = (fontWeight, fontSize, fontFamily, letterSpacing)
|
|
|
2334
2323
|
return measureTextWidth('a', fontWeight, fontSize, fontFamily, letterSpacing, false, 0);
|
|
2335
2324
|
};
|
|
2336
2325
|
|
|
2337
|
-
const OnCompletion = 'onCompletion';
|
|
2338
2326
|
const OnDiagnostic = 'onDiagnostic';
|
|
2339
2327
|
const OnHover = 'onHover';
|
|
2340
2328
|
const OnTabCompletion = 'onTabCompletion';
|
|
@@ -2557,7 +2545,7 @@ const createEditor = async ({
|
|
|
2557
2545
|
// TODO avoid creating intermediate editors here
|
|
2558
2546
|
const newEditor1 = setBounds(editor, x, y, width, height, 9);
|
|
2559
2547
|
const newEditor2 = setText(newEditor1, content);
|
|
2560
|
-
const newEditor3 = setDeltaY$
|
|
2548
|
+
const newEditor3 = setDeltaY$2(newEditor2, 0);
|
|
2561
2549
|
const newEditor4 = {
|
|
2562
2550
|
...newEditor3,
|
|
2563
2551
|
focused: true
|
|
@@ -2692,7 +2680,7 @@ const getAccurateColumnIndexAscii = (line, guess, averageCharWidth, eventX, font
|
|
|
2692
2680
|
const supported = () => {
|
|
2693
2681
|
return 'Segmenter' in Intl;
|
|
2694
2682
|
};
|
|
2695
|
-
const create$
|
|
2683
|
+
const create$8 = () => {
|
|
2696
2684
|
// @ts-ignore
|
|
2697
2685
|
const segmenter = new Intl.Segmenter();
|
|
2698
2686
|
return {
|
|
@@ -2730,7 +2718,7 @@ const create$9 = () => {
|
|
|
2730
2718
|
|
|
2731
2719
|
// @ts-ignore
|
|
2732
2720
|
const getAccurateColumnIndexUnicode = (line, guess, averageCharWidth, eventX, fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
2733
|
-
const segmenter = create$
|
|
2721
|
+
const segmenter = create$8();
|
|
2734
2722
|
const segments = segmenter.getSegments(line);
|
|
2735
2723
|
const isMonospaceFont = false;
|
|
2736
2724
|
const charWidth = 0;
|
|
@@ -3002,24 +2990,6 @@ const closeCodeGenerator = editor => {
|
|
|
3002
2990
|
};
|
|
3003
2991
|
};
|
|
3004
2992
|
|
|
3005
|
-
const isCompletionWidget = widget => {
|
|
3006
|
-
return widget.id === Completion;
|
|
3007
|
-
};
|
|
3008
|
-
const closeCompletion = editor => {
|
|
3009
|
-
const {
|
|
3010
|
-
widgets
|
|
3011
|
-
} = editor;
|
|
3012
|
-
const completionWidgetIndex = widgets.findIndex(isCompletionWidget);
|
|
3013
|
-
if (completionWidgetIndex === -1) {
|
|
3014
|
-
return editor;
|
|
3015
|
-
}
|
|
3016
|
-
const newWidgets = removeEditorWidget(widgets, Completion);
|
|
3017
|
-
return {
|
|
3018
|
-
...editor,
|
|
3019
|
-
widgets: newWidgets
|
|
3020
|
-
};
|
|
3021
|
-
};
|
|
3022
|
-
|
|
3023
2993
|
const isMatchingWidget$1 = widget => {
|
|
3024
2994
|
return widget.id === Find;
|
|
3025
2995
|
};
|
|
@@ -3039,24 +3009,60 @@ const closeFind = editor => {
|
|
|
3039
3009
|
};
|
|
3040
3010
|
};
|
|
3041
3011
|
|
|
3012
|
+
const launchRenameWorker = async () => {
|
|
3013
|
+
const name = 'Rename Worker';
|
|
3014
|
+
const {
|
|
3015
|
+
port1,
|
|
3016
|
+
port2
|
|
3017
|
+
} = getPortTuple();
|
|
3018
|
+
await invokeAndTransfer('IpcParent.create', {
|
|
3019
|
+
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
|
|
3020
|
+
url: 'renameWorkerMain.js',
|
|
3021
|
+
name: name,
|
|
3022
|
+
raw: true,
|
|
3023
|
+
port: port1
|
|
3024
|
+
});
|
|
3025
|
+
const rpc = await MessagePortRpcParent.create({
|
|
3026
|
+
commandMap: {},
|
|
3027
|
+
messagePort: port2,
|
|
3028
|
+
isMessagePortOpen: true
|
|
3029
|
+
});
|
|
3030
|
+
port2.start();
|
|
3031
|
+
return rpc;
|
|
3032
|
+
};
|
|
3033
|
+
|
|
3034
|
+
let workerPromise$2;
|
|
3035
|
+
const getOrCreate$2 = () => {
|
|
3036
|
+
if (!workerPromise$2) {
|
|
3037
|
+
workerPromise$2 = launchRenameWorker();
|
|
3038
|
+
}
|
|
3039
|
+
return workerPromise$2;
|
|
3040
|
+
};
|
|
3041
|
+
const invoke$4 = async (method, ...params) => {
|
|
3042
|
+
const worker = await getOrCreate$2();
|
|
3043
|
+
return await worker.invoke(method, ...params);
|
|
3044
|
+
};
|
|
3045
|
+
|
|
3042
3046
|
// TODO duplicate code
|
|
3043
3047
|
const isRenameWidget = widget => {
|
|
3044
3048
|
return widget.id === Rename;
|
|
3045
3049
|
};
|
|
3046
|
-
const closeRename = editor => {
|
|
3050
|
+
const closeRename = async editor => {
|
|
3047
3051
|
const {
|
|
3048
|
-
widgets
|
|
3052
|
+
widgets,
|
|
3053
|
+
uid
|
|
3049
3054
|
} = editor;
|
|
3050
3055
|
const renameWidgetIndex = widgets.findIndex(isRenameWidget);
|
|
3051
3056
|
if (renameWidgetIndex === -1) {
|
|
3052
3057
|
return editor;
|
|
3053
3058
|
}
|
|
3054
|
-
const
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
};
|
|
3059
|
+
const renameWidget = widgets[renameWidgetIndex];
|
|
3060
|
+
await invoke$4('Rename.close', renameWidget.newState.uid);
|
|
3061
|
+
const latest = get$4(uid);
|
|
3062
|
+
const {
|
|
3063
|
+
newState
|
|
3064
|
+
} = latest;
|
|
3065
|
+
return newState;
|
|
3060
3066
|
};
|
|
3061
3067
|
|
|
3062
3068
|
const isMatchingWidget = widget => {
|
|
@@ -3096,6 +3102,12 @@ const setFocus = async focusKey => {
|
|
|
3096
3102
|
}
|
|
3097
3103
|
await invoke$7('Focus.setFocus', focusKey);
|
|
3098
3104
|
};
|
|
3105
|
+
const unsetAdditionalFocus = async focusKey => {
|
|
3106
|
+
if (!focusKey) {
|
|
3107
|
+
return;
|
|
3108
|
+
}
|
|
3109
|
+
await invoke$7('Focus.removeAdditionalFocus', focusKey);
|
|
3110
|
+
};
|
|
3099
3111
|
|
|
3100
3112
|
const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGenerator, fullFocus) => {
|
|
3101
3113
|
const {
|
|
@@ -3127,12 +3139,12 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
|
|
|
3127
3139
|
return newEditor;
|
|
3128
3140
|
};
|
|
3129
3141
|
|
|
3130
|
-
const create$
|
|
3142
|
+
const create$7 = () => {
|
|
3131
3143
|
return Math.random();
|
|
3132
3144
|
};
|
|
3133
3145
|
|
|
3134
|
-
const create$
|
|
3135
|
-
const completionUid = create$
|
|
3146
|
+
const create$6 = () => {
|
|
3147
|
+
const completionUid = create$7();
|
|
3136
3148
|
const widget = {
|
|
3137
3149
|
id: ColorPicker,
|
|
3138
3150
|
oldState: {
|
|
@@ -3155,11 +3167,11 @@ const create$7 = () => {
|
|
|
3155
3167
|
return widget;
|
|
3156
3168
|
};
|
|
3157
3169
|
|
|
3158
|
-
const newStateGenerator$
|
|
3159
|
-
return loadContent$
|
|
3170
|
+
const newStateGenerator$5 = (state, parentUid) => {
|
|
3171
|
+
return loadContent$2(state, parentUid);
|
|
3160
3172
|
};
|
|
3161
3173
|
const openColorPicker = async editor => {
|
|
3162
|
-
return addWidgetToEditor(ColorPicker, ColorPicker$1, editor, create$
|
|
3174
|
+
return addWidgetToEditor(ColorPicker, ColorPicker$1, editor, create$6, newStateGenerator$5);
|
|
3163
3175
|
};
|
|
3164
3176
|
|
|
3165
3177
|
const state$6 = {
|
|
@@ -3404,7 +3416,7 @@ const characterLeft = (line, columnIndex) => {
|
|
|
3404
3416
|
if (!supported()) {
|
|
3405
3417
|
return 1;
|
|
3406
3418
|
}
|
|
3407
|
-
const segmenter = create$
|
|
3419
|
+
const segmenter = create$8();
|
|
3408
3420
|
const last = segmenter.at(line, columnIndex - 1);
|
|
3409
3421
|
return columnIndex - last.index;
|
|
3410
3422
|
};
|
|
@@ -3415,12 +3427,12 @@ const characterRight = (line, columnIndex) => {
|
|
|
3415
3427
|
if (!supported()) {
|
|
3416
3428
|
return 1;
|
|
3417
3429
|
}
|
|
3418
|
-
const segmenter = create$
|
|
3430
|
+
const segmenter = create$8();
|
|
3419
3431
|
const next = segmenter.at(line, columnIndex);
|
|
3420
3432
|
return next.segment.length;
|
|
3421
3433
|
};
|
|
3422
3434
|
const isWhitespace = char => {
|
|
3423
|
-
return char === Space$
|
|
3435
|
+
return char === Space$1 || char === Tab$1;
|
|
3424
3436
|
};
|
|
3425
3437
|
const lineCharacterStart = (line, columnIndex) => {
|
|
3426
3438
|
if (line.length === 0) {
|
|
@@ -3942,7 +3954,7 @@ const getWordAt$2 = (line, columnIndex) => {
|
|
|
3942
3954
|
const matchBefore = before.match(RE_WORD_END$1);
|
|
3943
3955
|
const after = line.slice(columnIndex);
|
|
3944
3956
|
const matchAfter = after.match(RE_WORD_START$1);
|
|
3945
|
-
let word = EmptyString
|
|
3957
|
+
let word = EmptyString;
|
|
3946
3958
|
if (matchBefore) {
|
|
3947
3959
|
word += matchBefore[0];
|
|
3948
3960
|
}
|
|
@@ -3959,7 +3971,7 @@ const getWordBefore$1 = (line, columnIndex) => {
|
|
|
3959
3971
|
if (matchBefore) {
|
|
3960
3972
|
return matchBefore[0];
|
|
3961
3973
|
}
|
|
3962
|
-
return EmptyString
|
|
3974
|
+
return EmptyString;
|
|
3963
3975
|
};
|
|
3964
3976
|
|
|
3965
3977
|
const getWordAt$1 = (editor, rowIndex, columnIndex) => {
|
|
@@ -4020,7 +4032,6 @@ const MoveLineUp = 'Move Line Up';
|
|
|
4020
4032
|
const NoCodeActionsAvailable = 'No code actions available';
|
|
4021
4033
|
const NoDefinitionFound = 'No definition found';
|
|
4022
4034
|
const NoDefinitionFoundFor = "No definition found for '{PH1}'";
|
|
4023
|
-
const NoResults = 'No Results';
|
|
4024
4035
|
const NoTypeDefinitionFound = 'No type definition found';
|
|
4025
4036
|
const NoTypeDefinitionFoundFor = "No type definition found for '{PH1}'";
|
|
4026
4037
|
const SourceAction = 'Source Action';
|
|
@@ -4042,9 +4053,6 @@ const noTypeDefinitionFoundFor = word => {
|
|
|
4042
4053
|
const noTypeDefinitionFound = () => {
|
|
4043
4054
|
return i18nString(NoTypeDefinitionFound);
|
|
4044
4055
|
};
|
|
4045
|
-
const noResults = () => {
|
|
4046
|
-
return i18nString(NoResults);
|
|
4047
|
-
};
|
|
4048
4056
|
const sourceAction = () => {
|
|
4049
4057
|
return i18nString(SourceAction);
|
|
4050
4058
|
};
|
|
@@ -4683,7 +4691,6 @@ const getNewPercent$1 = (size, scrollBarSize, relativeX) => {
|
|
|
4683
4691
|
return 0;
|
|
4684
4692
|
}
|
|
4685
4693
|
// if (relativeY <= editor.scrollBarHeight / 2) {
|
|
4686
|
-
// console.log('clicked at top')
|
|
4687
4694
|
// // clicked at top
|
|
4688
4695
|
// return 0
|
|
4689
4696
|
// }
|
|
@@ -4769,7 +4776,6 @@ const getNewPercent = (state, relativeY) => {
|
|
|
4769
4776
|
scrollBarHeight
|
|
4770
4777
|
} = state;
|
|
4771
4778
|
// if (relativeY <= editor.scrollBarHeight / 2) {
|
|
4772
|
-
// console.log('clicked at top')
|
|
4773
4779
|
// // clicked at top
|
|
4774
4780
|
// return 0
|
|
4775
4781
|
// }
|
|
@@ -4848,7 +4854,6 @@ const handleTouchEnd = (editor, touchEvent) => {
|
|
|
4848
4854
|
// EditorCursorSet.cursorSet(editor, position)
|
|
4849
4855
|
// }
|
|
4850
4856
|
// } else {
|
|
4851
|
-
// console.log('different position')
|
|
4852
4857
|
// }
|
|
4853
4858
|
};
|
|
4854
4859
|
|
|
@@ -4871,8 +4876,8 @@ const handleTouchStart = (editor, touchEvent) => {
|
|
|
4871
4876
|
};
|
|
4872
4877
|
|
|
4873
4878
|
// @ts-ignore
|
|
4874
|
-
const setDeltaY
|
|
4875
|
-
return setDeltaY$
|
|
4879
|
+
const setDeltaY = (editor, deltaY) => {
|
|
4880
|
+
return setDeltaY$1(editor, deltaY);
|
|
4876
4881
|
};
|
|
4877
4882
|
|
|
4878
4883
|
// @ts-ignore
|
|
@@ -4889,11 +4894,11 @@ const setDelta = (editor, deltaMode, eventDeltaX, eventDeltaY) => {
|
|
|
4889
4894
|
const {
|
|
4890
4895
|
deltaX} = editor;
|
|
4891
4896
|
if (eventDeltaX === 0) {
|
|
4892
|
-
return setDeltaY
|
|
4897
|
+
return setDeltaY(editor, eventDeltaY);
|
|
4893
4898
|
}
|
|
4894
4899
|
const newDeltaX = clamp(deltaX + eventDeltaX, 0, Number.POSITIVE_INFINITY);
|
|
4895
4900
|
return {
|
|
4896
|
-
...setDeltaY
|
|
4901
|
+
...setDeltaY(editor, eventDeltaY),
|
|
4897
4902
|
deltaX: newDeltaX
|
|
4898
4903
|
};
|
|
4899
4904
|
};
|
|
@@ -5257,8 +5262,8 @@ const moveSelectionPx = (editor, x, y) => {
|
|
|
5257
5262
|
const Script = 2;
|
|
5258
5263
|
const Unknown$1 = 0;
|
|
5259
5264
|
|
|
5260
|
-
const create$
|
|
5261
|
-
const completionUid = create$
|
|
5265
|
+
const create$5 = () => {
|
|
5266
|
+
const completionUid = create$7();
|
|
5262
5267
|
const widget = {
|
|
5263
5268
|
id: CodeGenerator,
|
|
5264
5269
|
oldState: {
|
|
@@ -5285,7 +5290,7 @@ const create$6 = () => {
|
|
|
5285
5290
|
return widget;
|
|
5286
5291
|
};
|
|
5287
5292
|
|
|
5288
|
-
const newStateGenerator$
|
|
5293
|
+
const newStateGenerator$4 = async state => {
|
|
5289
5294
|
const latestState = {
|
|
5290
5295
|
...state,
|
|
5291
5296
|
x: 100,
|
|
@@ -5297,575 +5302,163 @@ const newStateGenerator$3 = async state => {
|
|
|
5297
5302
|
};
|
|
5298
5303
|
const openCodeGenerator = async editor => {
|
|
5299
5304
|
const fullFocus = true;
|
|
5300
|
-
return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create$
|
|
5305
|
+
return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create$5, newStateGenerator$4, fullFocus);
|
|
5301
5306
|
};
|
|
5302
5307
|
|
|
5303
|
-
const create$
|
|
5304
|
-
const completionUid = create$
|
|
5308
|
+
const create$4 = () => {
|
|
5309
|
+
const completionUid = create$7();
|
|
5305
5310
|
const completionWidget = {
|
|
5306
5311
|
id: Completion,
|
|
5307
5312
|
oldState: {
|
|
5308
|
-
items: [],
|
|
5309
|
-
itemHeight: 20,
|
|
5310
|
-
maxHeight: 150,
|
|
5311
|
-
minLineY: 0,
|
|
5312
|
-
maxLineY: 0,
|
|
5313
5313
|
uid: completionUid,
|
|
5314
|
-
focusedIndex: -1,
|
|
5315
5314
|
x: 0,
|
|
5316
5315
|
y: 0,
|
|
5317
5316
|
width: 0,
|
|
5318
5317
|
height: 0,
|
|
5319
|
-
|
|
5320
|
-
finalDeltaY: 0,
|
|
5321
|
-
focused: false,
|
|
5322
|
-
headerHeight: 0
|
|
5318
|
+
commands: []
|
|
5323
5319
|
},
|
|
5324
5320
|
newState: {
|
|
5325
|
-
items: [],
|
|
5326
|
-
itemHeight: 20,
|
|
5327
|
-
maxHeight: 150,
|
|
5328
|
-
minLineY: 0,
|
|
5329
|
-
maxLineY: 10,
|
|
5330
5321
|
uid: completionUid,
|
|
5331
|
-
focusedIndex: -1,
|
|
5332
5322
|
x: 0,
|
|
5333
5323
|
y: 0,
|
|
5334
5324
|
width: 0,
|
|
5335
5325
|
height: 0,
|
|
5336
|
-
|
|
5337
|
-
finalDeltaY: 0,
|
|
5338
|
-
headerHeight: 0,
|
|
5339
|
-
focused: false
|
|
5326
|
+
commands: []
|
|
5340
5327
|
}
|
|
5341
5328
|
};
|
|
5342
5329
|
return completionWidget;
|
|
5343
5330
|
};
|
|
5344
5331
|
|
|
5345
|
-
const
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5332
|
+
const launchCompletionWorker = async () => {
|
|
5333
|
+
const name = 'Completion Worker';
|
|
5334
|
+
const {
|
|
5335
|
+
port1,
|
|
5336
|
+
port2
|
|
5337
|
+
} = getPortTuple();
|
|
5338
|
+
await invokeAndTransfer('IpcParent.create', {
|
|
5339
|
+
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
|
|
5340
|
+
url: 'completionWorkerMain.js',
|
|
5341
|
+
name: name,
|
|
5342
|
+
raw: true,
|
|
5343
|
+
port: port1
|
|
5344
|
+
});
|
|
5345
|
+
const rpc = await MessagePortRpcParent.create({
|
|
5346
|
+
commandMap: {},
|
|
5347
|
+
messagePort: port2,
|
|
5348
|
+
isMessagePortOpen: true
|
|
5349
|
+
});
|
|
5350
|
+
port2.start();
|
|
5351
|
+
await rpc.invoke('Completions.initialize');
|
|
5352
|
+
return rpc;
|
|
5353
5353
|
};
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5354
|
+
|
|
5355
|
+
let workerPromise$1;
|
|
5356
|
+
const getOrCreate$1 = () => {
|
|
5357
|
+
if (!workerPromise$1) {
|
|
5358
|
+
workerPromise$1 = launchCompletionWorker();
|
|
5359
|
+
}
|
|
5360
|
+
return workerPromise$1;
|
|
5361
|
+
};
|
|
5362
|
+
const invoke$3 = async (method, ...params) => {
|
|
5363
|
+
const worker = await getOrCreate$1();
|
|
5364
|
+
return await worker.invoke(method, ...params);
|
|
5362
5365
|
};
|
|
5363
5366
|
|
|
5364
|
-
const
|
|
5367
|
+
const newStateGenerator$3 = async (state, parentUid) => {
|
|
5365
5368
|
const {
|
|
5366
|
-
|
|
5369
|
+
uid,
|
|
5370
|
+
x,
|
|
5371
|
+
y,
|
|
5372
|
+
width,
|
|
5373
|
+
height
|
|
5374
|
+
} = state;
|
|
5375
|
+
const editor = get$4(parentUid);
|
|
5376
|
+
const {
|
|
5377
|
+
languageId
|
|
5367
5378
|
} = editor;
|
|
5368
|
-
|
|
5369
|
-
|
|
5370
|
-
const
|
|
5371
|
-
|
|
5379
|
+
await invoke$3('Completions.create', uid, x, y, width, height, parentUid, languageId);
|
|
5380
|
+
await invoke$3('Completions.loadContent', uid);
|
|
5381
|
+
const diff = await invoke$3('Completions.diff2', uid);
|
|
5382
|
+
const commands = await invoke$3('Completions.render2', uid, diff);
|
|
5383
|
+
return {
|
|
5384
|
+
...state,
|
|
5385
|
+
commands
|
|
5386
|
+
};
|
|
5372
5387
|
};
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
const offset = getOffsetAtCursor(editor);
|
|
5377
|
-
const completions = await executeCompletionProvider(editor, offset);
|
|
5378
|
-
return completions;
|
|
5388
|
+
const openCompletion = async editor => {
|
|
5389
|
+
const fullFocus = false;
|
|
5390
|
+
return addWidgetToEditor(Completion, EditorCompletion, editor, create$4, newStateGenerator$3, fullFocus);
|
|
5379
5391
|
};
|
|
5380
5392
|
|
|
5381
|
-
|
|
5382
|
-
const
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5393
|
+
const create$3 = () => {
|
|
5394
|
+
const uid = create$7();
|
|
5395
|
+
const widget = {
|
|
5396
|
+
id: Find,
|
|
5397
|
+
oldState: {
|
|
5398
|
+
uid,
|
|
5399
|
+
x: 0,
|
|
5400
|
+
y: 0,
|
|
5401
|
+
width: 0,
|
|
5402
|
+
height: 0,
|
|
5403
|
+
commands: [],
|
|
5404
|
+
editorUid: 0
|
|
5405
|
+
},
|
|
5406
|
+
newState: {
|
|
5407
|
+
uid,
|
|
5408
|
+
x: 0,
|
|
5409
|
+
y: 0,
|
|
5410
|
+
width: 0,
|
|
5411
|
+
height: 0,
|
|
5412
|
+
commands: [],
|
|
5413
|
+
editorUid: 0
|
|
5414
|
+
}
|
|
5415
|
+
};
|
|
5416
|
+
return widget;
|
|
5394
5417
|
};
|
|
5395
5418
|
|
|
5396
|
-
const
|
|
5397
|
-
|
|
5398
|
-
const
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
}
|
|
5409
|
-
|
|
5410
|
-
}
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
const Underline = '_';
|
|
5417
|
-
const T = 't';
|
|
5418
|
-
const isLowerCase = char => {
|
|
5419
|
-
return char === char.toLowerCase();
|
|
5420
|
-
};
|
|
5421
|
-
const isUpperCase = char => {
|
|
5422
|
-
return char === char.toUpperCase();
|
|
5423
|
-
};
|
|
5424
|
-
|
|
5425
|
-
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
5426
|
-
const isGap = (columnCharBefore, columnChar) => {
|
|
5427
|
-
switch (columnCharBefore) {
|
|
5428
|
-
case Dash:
|
|
5429
|
-
case Underline:
|
|
5430
|
-
case EmptyString:
|
|
5431
|
-
case T:
|
|
5432
|
-
case Space$1:
|
|
5433
|
-
case Dot:
|
|
5434
|
-
return true;
|
|
5435
|
-
}
|
|
5436
|
-
if (isLowerCase(columnCharBefore) && isUpperCase(columnChar)) {
|
|
5437
|
-
return true;
|
|
5438
|
-
}
|
|
5439
|
-
return false;
|
|
5419
|
+
const launchFindWidgetWorker = async () => {
|
|
5420
|
+
const name = 'Find Widget Worker';
|
|
5421
|
+
const {
|
|
5422
|
+
port1,
|
|
5423
|
+
port2
|
|
5424
|
+
} = getPortTuple();
|
|
5425
|
+
await invokeAndTransfer('IpcParent.create', {
|
|
5426
|
+
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
|
|
5427
|
+
url: 'findWidgetWorkerMain.js',
|
|
5428
|
+
name: name,
|
|
5429
|
+
raw: true,
|
|
5430
|
+
port: port1
|
|
5431
|
+
});
|
|
5432
|
+
const rpc = await MessagePortRpcParent.create({
|
|
5433
|
+
commandMap: {},
|
|
5434
|
+
messagePort: port2,
|
|
5435
|
+
isMessagePortOpen: true
|
|
5436
|
+
});
|
|
5437
|
+
port2.start();
|
|
5438
|
+
return rpc;
|
|
5440
5439
|
};
|
|
5441
5440
|
|
|
5442
|
-
|
|
5443
|
-
const
|
|
5444
|
-
if (
|
|
5445
|
-
|
|
5446
|
-
}
|
|
5447
|
-
const isMatch = rowChar === columnChar;
|
|
5448
|
-
if (isMatch) {
|
|
5449
|
-
if (isDiagonalMatch) {
|
|
5450
|
-
return 8;
|
|
5451
|
-
}
|
|
5452
|
-
if (isGap(columnCharBefore, columnChar)) {
|
|
5453
|
-
return 8;
|
|
5454
|
-
}
|
|
5455
|
-
return 5;
|
|
5456
|
-
}
|
|
5457
|
-
if (isGap(columnCharBefore, columnChar)) {
|
|
5458
|
-
return 8;
|
|
5441
|
+
let workerPromise;
|
|
5442
|
+
const getOrCreate = () => {
|
|
5443
|
+
if (!workerPromise) {
|
|
5444
|
+
workerPromise = launchFindWidgetWorker();
|
|
5459
5445
|
}
|
|
5460
|
-
return
|
|
5446
|
+
return workerPromise;
|
|
5447
|
+
};
|
|
5448
|
+
const invoke$2 = async (method, ...params) => {
|
|
5449
|
+
const worker = await getOrCreate();
|
|
5450
|
+
return await worker.invoke(method, ...params);
|
|
5461
5451
|
};
|
|
5462
5452
|
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
if (patternLow[patternPos] === wordLow[wordPos]) {
|
|
5468
|
-
patternPos += 1;
|
|
5469
|
-
}
|
|
5470
|
-
wordPos += 1;
|
|
5453
|
+
const getEditor = editorUid => {
|
|
5454
|
+
const instance = get$4(editorUid);
|
|
5455
|
+
if (!instance) {
|
|
5456
|
+
throw new Error(`editor ${editorUid} not found`);
|
|
5471
5457
|
}
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
const traceHighlights = (table, arrows, patternLength, wordLength) => {
|
|
5477
|
-
let row = patternLength;
|
|
5478
|
-
let column = wordLength;
|
|
5479
|
-
const matches = [];
|
|
5480
|
-
while (row >= 1 && column >= 1) {
|
|
5481
|
-
const arrow = arrows[row][column];
|
|
5482
|
-
if (arrow === Left) {
|
|
5483
|
-
column--;
|
|
5484
|
-
} else if (arrow === Diagonal) {
|
|
5485
|
-
row--;
|
|
5486
|
-
column--;
|
|
5487
|
-
const start = column + 1;
|
|
5488
|
-
while (row >= 1 && column >= 1) {
|
|
5489
|
-
const arrow = arrows[row][column];
|
|
5490
|
-
if (arrow === Left) {
|
|
5491
|
-
break;
|
|
5492
|
-
}
|
|
5493
|
-
if (arrow === Diagonal) {
|
|
5494
|
-
row--;
|
|
5495
|
-
column--;
|
|
5496
|
-
}
|
|
5497
|
-
}
|
|
5498
|
-
const end = column;
|
|
5499
|
-
matches.unshift(end, start);
|
|
5500
|
-
}
|
|
5501
|
-
}
|
|
5502
|
-
matches.unshift(table[patternLength][wordLength - 1]);
|
|
5503
|
-
return matches;
|
|
5504
|
-
};
|
|
5505
|
-
|
|
5506
|
-
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
5507
|
-
const gridSize = 128;
|
|
5508
|
-
const table = createTable(gridSize);
|
|
5509
|
-
const arrows = createTable(gridSize);
|
|
5510
|
-
const fuzzySearch = (pattern, word) => {
|
|
5511
|
-
const patternLength = Math.min(pattern.length, gridSize - 1);
|
|
5512
|
-
const wordLength = Math.min(word.length, gridSize - 1);
|
|
5513
|
-
const patternLower = pattern.toLowerCase();
|
|
5514
|
-
const wordLower = word.toLowerCase();
|
|
5515
|
-
if (!isPatternInWord(patternLower, 0, patternLength, wordLower, 0, wordLength)) {
|
|
5516
|
-
return EmptyMatches$1;
|
|
5517
|
-
}
|
|
5518
|
-
let strongMatch = false;
|
|
5519
|
-
for (let row = 1; row < patternLength + 1; row++) {
|
|
5520
|
-
const rowChar = pattern[row - 1];
|
|
5521
|
-
const rowCharLow = patternLower[row - 1];
|
|
5522
|
-
for (let column = 1; column < wordLength + 1; column++) {
|
|
5523
|
-
const columnChar = word[column - 1];
|
|
5524
|
-
const columnCharLow = wordLower[column - 1];
|
|
5525
|
-
const columnCharBefore = word[column - 2] || '';
|
|
5526
|
-
const isDiagonalMatch = arrows[row - 1][column - 1] === Diagonal;
|
|
5527
|
-
const score = getScore(rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch);
|
|
5528
|
-
if (row === 1 && score > 5) {
|
|
5529
|
-
strongMatch = true;
|
|
5530
|
-
}
|
|
5531
|
-
let diagonalScore = score + table[row - 1][column - 1];
|
|
5532
|
-
if (isDiagonalMatch && score !== -1) {
|
|
5533
|
-
diagonalScore += 2;
|
|
5534
|
-
}
|
|
5535
|
-
const leftScore = table[row][column - 1];
|
|
5536
|
-
if (leftScore > diagonalScore) {
|
|
5537
|
-
table[row][column] = leftScore;
|
|
5538
|
-
arrows[row][column] = Left;
|
|
5539
|
-
} else {
|
|
5540
|
-
table[row][column] = diagonalScore;
|
|
5541
|
-
arrows[row][column] = Diagonal;
|
|
5542
|
-
}
|
|
5543
|
-
}
|
|
5544
|
-
}
|
|
5545
|
-
if (!strongMatch) {
|
|
5546
|
-
return EmptyMatches$1;
|
|
5547
|
-
}
|
|
5548
|
-
const highlights = traceHighlights(table, arrows, patternLength, wordLength);
|
|
5549
|
-
return highlights;
|
|
5550
|
-
};
|
|
5551
|
-
|
|
5552
|
-
const Deprecated = 1 << 0;
|
|
5553
|
-
|
|
5554
|
-
const EmptyMatches = [];
|
|
5555
|
-
|
|
5556
|
-
const addEmptyMatch = item => {
|
|
5557
|
-
return {
|
|
5558
|
-
...item,
|
|
5559
|
-
matches: EmptyMatches
|
|
5560
|
-
};
|
|
5561
|
-
};
|
|
5562
|
-
const filterCompletionItems = (completionItems, word) => {
|
|
5563
|
-
if (word === EmptyString$1) {
|
|
5564
|
-
return completionItems.map(addEmptyMatch);
|
|
5565
|
-
}
|
|
5566
|
-
const filteredCompletions = [];
|
|
5567
|
-
const deprecated = [];
|
|
5568
|
-
for (const completionItem of completionItems) {
|
|
5569
|
-
const {
|
|
5570
|
-
label,
|
|
5571
|
-
flags
|
|
5572
|
-
} = completionItem;
|
|
5573
|
-
const result = fuzzySearch(word, label);
|
|
5574
|
-
if (result.length > 0) {
|
|
5575
|
-
if (flags & Deprecated) {
|
|
5576
|
-
// TODO avoid mutation
|
|
5577
|
-
completionItem.matches = EmptyMatches;
|
|
5578
|
-
deprecated.push(completionItem);
|
|
5579
|
-
} else {
|
|
5580
|
-
// TODO avoid mutation
|
|
5581
|
-
completionItem.matches = result;
|
|
5582
|
-
filteredCompletions.push(completionItem);
|
|
5583
|
-
}
|
|
5584
|
-
}
|
|
5585
|
-
}
|
|
5586
|
-
if (deprecated.length > 0) {
|
|
5587
|
-
filteredCompletions.push(...deprecated);
|
|
5588
|
-
}
|
|
5589
|
-
return filteredCompletions;
|
|
5590
|
-
};
|
|
5591
|
-
|
|
5592
|
-
const getEditor = editorUid => {
|
|
5593
|
-
const instance = get$4(editorUid);
|
|
5594
|
-
if (!instance) {
|
|
5595
|
-
throw new Error(`editor ${editorUid} not found`);
|
|
5596
|
-
}
|
|
5597
|
-
const {
|
|
5598
|
-
newState
|
|
5599
|
-
} = instance;
|
|
5600
|
-
return newState;
|
|
5601
|
-
};
|
|
5602
|
-
|
|
5603
|
-
const getFinalDeltaY = (height, itemHeight, itemsLength) => {
|
|
5604
|
-
const contentHeight = itemsLength * itemHeight;
|
|
5605
|
-
const finalDeltaY = Math.max(contentHeight - height, 0);
|
|
5606
|
-
return finalDeltaY;
|
|
5607
|
-
};
|
|
5608
|
-
|
|
5609
|
-
const getListHeight = (itemsLength, itemHeight, maxHeight) => {
|
|
5610
|
-
number(itemsLength);
|
|
5611
|
-
number(itemHeight);
|
|
5612
|
-
number(maxHeight);
|
|
5613
|
-
if (itemsLength === 0) {
|
|
5614
|
-
return itemHeight;
|
|
5615
|
-
}
|
|
5616
|
-
const totalHeight = itemsLength * itemHeight;
|
|
5617
|
-
return Math.min(totalHeight, maxHeight);
|
|
5618
|
-
};
|
|
5619
|
-
|
|
5620
|
-
const getPositionAtCursor$1 = editor => {
|
|
5621
|
-
const {
|
|
5622
|
-
selections
|
|
5623
|
-
} = editor;
|
|
5624
|
-
const rowIndex = selections[0];
|
|
5625
|
-
const columnIndex = selections[1];
|
|
5626
|
-
const x$1 = x(editor, rowIndex, columnIndex);
|
|
5627
|
-
const y$1 = y(editor, rowIndex);
|
|
5628
|
-
return {
|
|
5629
|
-
x: x$1,
|
|
5630
|
-
y: y$1,
|
|
5631
|
-
rowIndex,
|
|
5632
|
-
columnIndex
|
|
5633
|
-
};
|
|
5634
|
-
};
|
|
5635
|
-
|
|
5636
|
-
const RE_WORD = /[\w\-]+$/;
|
|
5637
|
-
const getWordAtOffset = editor => {
|
|
5638
|
-
const {
|
|
5639
|
-
lines,
|
|
5640
|
-
selections
|
|
5641
|
-
} = editor;
|
|
5642
|
-
const rowIndex = selections[0];
|
|
5643
|
-
const columnIndex = selections[1];
|
|
5644
|
-
const line = lines[rowIndex];
|
|
5645
|
-
const part = line.slice(0, columnIndex);
|
|
5646
|
-
const wordMatch = part.match(RE_WORD);
|
|
5647
|
-
if (wordMatch) {
|
|
5648
|
-
return wordMatch[0];
|
|
5649
|
-
}
|
|
5650
|
-
return '';
|
|
5651
|
-
};
|
|
5652
|
-
|
|
5653
|
-
const handleEditorType$2 = (editorUid, state, text) => {
|
|
5654
|
-
const editor = getEditor(editorUid);
|
|
5655
|
-
const {
|
|
5656
|
-
unfilteredItems,
|
|
5657
|
-
itemHeight,
|
|
5658
|
-
maxHeight
|
|
5659
|
-
} = state;
|
|
5660
|
-
const rowIndex = editor.selections[0];
|
|
5661
|
-
const columnIndex = editor.selections[1];
|
|
5662
|
-
const x$1 = x(editor, rowIndex, columnIndex);
|
|
5663
|
-
// @ts-ignore
|
|
5664
|
-
const y$1 = y(editor, rowIndex);
|
|
5665
|
-
const wordAtOffset = getWordAtOffset(editor);
|
|
5666
|
-
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
5667
|
-
const newMinLineY = 0;
|
|
5668
|
-
const newMaxLineY = Math.min(items.length, 8);
|
|
5669
|
-
const height = getListHeight(items.length, itemHeight, maxHeight);
|
|
5670
|
-
const finalDeltaY = items.length * itemHeight - height;
|
|
5671
|
-
return {
|
|
5672
|
-
...state,
|
|
5673
|
-
items,
|
|
5674
|
-
x: x$1,
|
|
5675
|
-
y: y$1,
|
|
5676
|
-
minLineY: newMinLineY,
|
|
5677
|
-
maxLineY: newMaxLineY,
|
|
5678
|
-
leadingWord: wordAtOffset,
|
|
5679
|
-
height,
|
|
5680
|
-
finalDeltaY
|
|
5681
|
-
};
|
|
5682
|
-
};
|
|
5683
|
-
const handleEditorDeleteLeft$2 = (editorUid, state) => {
|
|
5684
|
-
const editor = getEditor(editorUid);
|
|
5685
|
-
const {
|
|
5686
|
-
unfilteredItems,
|
|
5687
|
-
itemHeight,
|
|
5688
|
-
maxHeight
|
|
5689
|
-
} = state;
|
|
5690
|
-
const rowIndex = editor.selections[0];
|
|
5691
|
-
const columnIndex = editor.selections[1];
|
|
5692
|
-
const x$1 = x(editor, rowIndex, columnIndex);
|
|
5693
|
-
// @ts-ignore
|
|
5694
|
-
const y$1 = y(editor, rowIndex);
|
|
5695
|
-
const wordAtOffset = getWordAtOffset(editor);
|
|
5696
|
-
if (!wordAtOffset) {
|
|
5697
|
-
editor.completionState = None$1;
|
|
5698
|
-
return {
|
|
5699
|
-
...state,
|
|
5700
|
-
disposed: true
|
|
5701
|
-
};
|
|
5702
|
-
}
|
|
5703
|
-
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
5704
|
-
const newMaxLineY = Math.min(items.length, 8);
|
|
5705
|
-
const height = getListHeight(items.length, itemHeight, maxHeight);
|
|
5706
|
-
return {
|
|
5707
|
-
...state,
|
|
5708
|
-
items,
|
|
5709
|
-
x: x$1,
|
|
5710
|
-
y: y$1,
|
|
5711
|
-
maxLineY: newMaxLineY,
|
|
5712
|
-
leadingWord: wordAtOffset,
|
|
5713
|
-
height
|
|
5714
|
-
};
|
|
5715
|
-
};
|
|
5716
|
-
const dispose = state => {
|
|
5717
|
-
return {
|
|
5718
|
-
...state,
|
|
5719
|
-
disposed: true
|
|
5720
|
-
};
|
|
5721
|
-
};
|
|
5722
|
-
const disposeWithEditor = (state, editor) => {
|
|
5723
|
-
editor.completionState = None$1;
|
|
5724
|
-
editor.completionUid = 0;
|
|
5725
|
-
// Focus.removeAdditionalFocus(FocusKey.EditorCompletion)
|
|
5726
|
-
return dispose(state);
|
|
5727
|
-
};
|
|
5728
|
-
const handleEditorClick = disposeWithEditor;
|
|
5729
|
-
const handleEditorBlur = disposeWithEditor;
|
|
5730
|
-
const loadContent$2 = async (editorUid, state) => {
|
|
5731
|
-
const editor = getEditor(editorUid);
|
|
5732
|
-
const {
|
|
5733
|
-
itemHeight,
|
|
5734
|
-
maxHeight
|
|
5735
|
-
} = state;
|
|
5736
|
-
const unfilteredItems = await getCompletions(editor);
|
|
5737
|
-
const wordAtOffset = getWordAtOffset(editor);
|
|
5738
|
-
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
5739
|
-
const {
|
|
5740
|
-
rowIndex,
|
|
5741
|
-
columnIndex,
|
|
5742
|
-
x,
|
|
5743
|
-
y
|
|
5744
|
-
} = getPositionAtCursor$1(editor);
|
|
5745
|
-
const newMaxLineY = Math.min(items.length, 8);
|
|
5746
|
-
editor.widgets = editor.widgets || [];
|
|
5747
|
-
// editor.widgets.push(ViewletModuleId.EditorCompletion)
|
|
5748
|
-
const itemsLength = items.length;
|
|
5749
|
-
const newFocusedIndex = itemsLength === 0 ? -1 : 0;
|
|
5750
|
-
const total = items.length;
|
|
5751
|
-
const height = getListHeight(items.length, itemHeight, maxHeight);
|
|
5752
|
-
const finalDeltaY = getFinalDeltaY(height, itemHeight, total);
|
|
5753
|
-
return {
|
|
5754
|
-
...state,
|
|
5755
|
-
unfilteredItems,
|
|
5756
|
-
items,
|
|
5757
|
-
x,
|
|
5758
|
-
y,
|
|
5759
|
-
maxLineY: newMaxLineY,
|
|
5760
|
-
focusedIndex: newFocusedIndex,
|
|
5761
|
-
finalDeltaY,
|
|
5762
|
-
leadingWord: wordAtOffset,
|
|
5763
|
-
height,
|
|
5764
|
-
rowIndex,
|
|
5765
|
-
columnIndex,
|
|
5766
|
-
editorUid,
|
|
5767
|
-
width: 200
|
|
5768
|
-
};
|
|
5769
|
-
};
|
|
5770
|
-
const advance = (state, word) => {
|
|
5771
|
-
const filteredItems = filterCompletionItems(state.items, word);
|
|
5772
|
-
return {
|
|
5773
|
-
...state,
|
|
5774
|
-
filteredItems
|
|
5775
|
-
};
|
|
5776
|
-
};
|
|
5777
|
-
|
|
5778
|
-
const openCompletion = async editor => {
|
|
5779
|
-
const {
|
|
5780
|
-
widgets,
|
|
5781
|
-
uid
|
|
5782
|
-
} = editor;
|
|
5783
|
-
if (hasWidget(widgets, Completion)) {
|
|
5784
|
-
return editor;
|
|
5785
|
-
}
|
|
5786
|
-
const completionWidget = create$5();
|
|
5787
|
-
const newWidgets = [...widgets, completionWidget];
|
|
5788
|
-
const newEditor = {
|
|
5789
|
-
...editor,
|
|
5790
|
-
widgets: newWidgets
|
|
5791
|
-
};
|
|
5792
|
-
set$4(uid, editor, newEditor);
|
|
5793
|
-
const newCompletionWidget = await loadContent$2(uid, completionWidget.newState);
|
|
5794
|
-
const FocusEditorCompletions = EditorCompletion;
|
|
5795
|
-
await setAdditionalFocus(FocusEditorCompletions);
|
|
5796
|
-
const latestEditor = getEditor(uid);
|
|
5797
|
-
if (!latestEditor.widgets.includes(completionWidget)) {
|
|
5798
|
-
return editor;
|
|
5799
|
-
}
|
|
5800
|
-
const index = latestEditor.widgets.indexOf(completionWidget);
|
|
5801
|
-
const latestWidgets = [...latestEditor.widgets.slice(0, index), {
|
|
5802
|
-
...completionWidget,
|
|
5803
|
-
newState: newCompletionWidget
|
|
5804
|
-
}, ...latestEditor.widgets.slice(index + 1)];
|
|
5805
|
-
return {
|
|
5806
|
-
...latestEditor,
|
|
5807
|
-
widgets: latestWidgets
|
|
5808
|
-
};
|
|
5809
|
-
};
|
|
5810
|
-
|
|
5811
|
-
const create$4 = () => {
|
|
5812
|
-
const uid = create$8();
|
|
5813
|
-
const widget = {
|
|
5814
|
-
id: Find,
|
|
5815
|
-
oldState: {
|
|
5816
|
-
uid,
|
|
5817
|
-
x: 0,
|
|
5818
|
-
y: 0,
|
|
5819
|
-
width: 0,
|
|
5820
|
-
height: 0,
|
|
5821
|
-
commands: [],
|
|
5822
|
-
editorUid: 0
|
|
5823
|
-
},
|
|
5824
|
-
newState: {
|
|
5825
|
-
uid,
|
|
5826
|
-
x: 0,
|
|
5827
|
-
y: 0,
|
|
5828
|
-
width: 0,
|
|
5829
|
-
height: 0,
|
|
5830
|
-
commands: [],
|
|
5831
|
-
editorUid: 0
|
|
5832
|
-
}
|
|
5833
|
-
};
|
|
5834
|
-
return widget;
|
|
5835
|
-
};
|
|
5836
|
-
|
|
5837
|
-
const launchFindWidgetWorker = async () => {
|
|
5838
|
-
const name = 'Find Widget Worker';
|
|
5839
|
-
const {
|
|
5840
|
-
port1,
|
|
5841
|
-
port2
|
|
5842
|
-
} = getPortTuple();
|
|
5843
|
-
await invokeAndTransfer('IpcParent.create', {
|
|
5844
|
-
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
|
|
5845
|
-
url: 'findWidgetWorkerMain.js',
|
|
5846
|
-
name: name,
|
|
5847
|
-
raw: true,
|
|
5848
|
-
port: port1
|
|
5849
|
-
});
|
|
5850
|
-
const rpc = await MessagePortRpcParent.create({
|
|
5851
|
-
commandMap: {},
|
|
5852
|
-
messagePort: port2,
|
|
5853
|
-
isMessagePortOpen: true
|
|
5854
|
-
});
|
|
5855
|
-
port2.start();
|
|
5856
|
-
return rpc;
|
|
5857
|
-
};
|
|
5858
|
-
|
|
5859
|
-
let workerPromise$2;
|
|
5860
|
-
const getOrCreate$2 = () => {
|
|
5861
|
-
if (!workerPromise$2) {
|
|
5862
|
-
workerPromise$2 = launchFindWidgetWorker();
|
|
5863
|
-
}
|
|
5864
|
-
return workerPromise$2;
|
|
5865
|
-
};
|
|
5866
|
-
const invoke$4 = async (method, ...params) => {
|
|
5867
|
-
const worker = await getOrCreate$2();
|
|
5868
|
-
return await worker.invoke(method, ...params);
|
|
5458
|
+
const {
|
|
5459
|
+
newState
|
|
5460
|
+
} = instance;
|
|
5461
|
+
return newState;
|
|
5869
5462
|
};
|
|
5870
5463
|
|
|
5871
5464
|
const loadContent$1 = async (state, parentUid) => {
|
|
@@ -5879,16 +5472,16 @@ const loadContent$1 = async (state, parentUid) => {
|
|
|
5879
5472
|
width,
|
|
5880
5473
|
height
|
|
5881
5474
|
} = editor;
|
|
5882
|
-
await invoke$
|
|
5883
|
-
await invoke$
|
|
5884
|
-
const diff = await invoke$
|
|
5885
|
-
const commands = await invoke$
|
|
5475
|
+
await invoke$2('FindWidget.create', uid, x, y, width, height, parentUid);
|
|
5476
|
+
await invoke$2('FindWidget.loadContent', uid);
|
|
5477
|
+
const diff = await invoke$2('FindWidget.diff2', uid);
|
|
5478
|
+
const commands = await invoke$2('FindWidget.render2', uid, diff);
|
|
5886
5479
|
return {
|
|
5887
5480
|
...state,
|
|
5888
5481
|
commands
|
|
5889
5482
|
};
|
|
5890
5483
|
};
|
|
5891
|
-
const close = async state => {
|
|
5484
|
+
const close$1 = async state => {
|
|
5892
5485
|
// TODO
|
|
5893
5486
|
// await Viewlet.closeWidget(uid)
|
|
5894
5487
|
return {
|
|
@@ -5902,15 +5495,31 @@ const newStateGenerator$2 = (state, parentUid) => {
|
|
|
5902
5495
|
};
|
|
5903
5496
|
const openFind2 = async editor => {
|
|
5904
5497
|
const fullFocus = true;
|
|
5905
|
-
return addWidgetToEditor(ColorPicker, FindWidget, editor, create$
|
|
5498
|
+
return addWidgetToEditor(ColorPicker, FindWidget, editor, create$3, newStateGenerator$2, fullFocus);
|
|
5906
5499
|
};
|
|
5907
5500
|
|
|
5908
5501
|
const openFind = async state => {
|
|
5909
5502
|
return openFind2(state);
|
|
5910
5503
|
};
|
|
5911
5504
|
|
|
5912
|
-
const
|
|
5913
|
-
const
|
|
5505
|
+
const getPositionAtCursor$1 = editor => {
|
|
5506
|
+
const {
|
|
5507
|
+
selections
|
|
5508
|
+
} = editor;
|
|
5509
|
+
const rowIndex = selections[0];
|
|
5510
|
+
const columnIndex = selections[1];
|
|
5511
|
+
const x$1 = x(editor, rowIndex, columnIndex);
|
|
5512
|
+
const y$1 = y(editor, rowIndex);
|
|
5513
|
+
return {
|
|
5514
|
+
x: x$1,
|
|
5515
|
+
y: y$1,
|
|
5516
|
+
rowIndex,
|
|
5517
|
+
columnIndex
|
|
5518
|
+
};
|
|
5519
|
+
};
|
|
5520
|
+
|
|
5521
|
+
const create$2 = () => {
|
|
5522
|
+
const completionUid = create$7();
|
|
5914
5523
|
const renameWidget = {
|
|
5915
5524
|
id: Rename,
|
|
5916
5525
|
oldState: {
|
|
@@ -5933,40 +5542,6 @@ const create$3 = () => {
|
|
|
5933
5542
|
return renameWidget;
|
|
5934
5543
|
};
|
|
5935
5544
|
|
|
5936
|
-
const launchRenameWorker = async () => {
|
|
5937
|
-
const name = 'Rename Worker';
|
|
5938
|
-
const {
|
|
5939
|
-
port1,
|
|
5940
|
-
port2
|
|
5941
|
-
} = getPortTuple();
|
|
5942
|
-
await invokeAndTransfer('IpcParent.create', {
|
|
5943
|
-
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
|
|
5944
|
-
url: 'renameWorkerMain.js',
|
|
5945
|
-
name: name,
|
|
5946
|
-
raw: true,
|
|
5947
|
-
port: port1
|
|
5948
|
-
});
|
|
5949
|
-
const rpc = await MessagePortRpcParent.create({
|
|
5950
|
-
commandMap: {},
|
|
5951
|
-
messagePort: port2,
|
|
5952
|
-
isMessagePortOpen: true
|
|
5953
|
-
});
|
|
5954
|
-
port2.start();
|
|
5955
|
-
return rpc;
|
|
5956
|
-
};
|
|
5957
|
-
|
|
5958
|
-
let workerPromise$1;
|
|
5959
|
-
const getOrCreate$1 = () => {
|
|
5960
|
-
if (!workerPromise$1) {
|
|
5961
|
-
workerPromise$1 = launchRenameWorker();
|
|
5962
|
-
}
|
|
5963
|
-
return workerPromise$1;
|
|
5964
|
-
};
|
|
5965
|
-
const invoke$3 = async (method, ...params) => {
|
|
5966
|
-
const worker = await getOrCreate$1();
|
|
5967
|
-
return await worker.invoke(method, ...params);
|
|
5968
|
-
};
|
|
5969
|
-
|
|
5970
5545
|
const newStateGenerator$1 = async (state, parentUid) => {
|
|
5971
5546
|
// const editor: any = {}
|
|
5972
5547
|
const {
|
|
@@ -5976,10 +5551,10 @@ const newStateGenerator$1 = async (state, parentUid) => {
|
|
|
5976
5551
|
width,
|
|
5977
5552
|
height
|
|
5978
5553
|
} = state;
|
|
5979
|
-
await invoke$
|
|
5980
|
-
await invoke$
|
|
5981
|
-
const diff = await invoke$
|
|
5982
|
-
const commands = await invoke$
|
|
5554
|
+
await invoke$4('Rename.create', uid, x, y, width, height, parentUid);
|
|
5555
|
+
await invoke$4('Rename.loadContent', uid);
|
|
5556
|
+
const diff = await invoke$4('Rename.diff2', uid);
|
|
5557
|
+
const commands = await invoke$4('Rename.render2', uid, diff);
|
|
5983
5558
|
return {
|
|
5984
5559
|
...state,
|
|
5985
5560
|
commands
|
|
@@ -5997,7 +5572,7 @@ const openRename = async editor => {
|
|
|
5997
5572
|
return editor;
|
|
5998
5573
|
}
|
|
5999
5574
|
const fullFocus = true;
|
|
6000
|
-
return addWidgetToEditor(Rename, FocusEditorRename$1, editor, create$
|
|
5575
|
+
return addWidgetToEditor(Rename, FocusEditorRename$1, editor, create$2, newStateGenerator$1, fullFocus);
|
|
6001
5576
|
};
|
|
6002
5577
|
|
|
6003
5578
|
const getOrganizeImportEdits = async editor => {
|
|
@@ -6727,7 +6302,7 @@ const getEnabled$1 = () => {
|
|
|
6727
6302
|
|
|
6728
6303
|
const {
|
|
6729
6304
|
listen: listen$3,
|
|
6730
|
-
invoke: invoke$
|
|
6305
|
+
invoke: invoke$1
|
|
6731
6306
|
} = createRpc(SyntaxHighlightingWorker);
|
|
6732
6307
|
|
|
6733
6308
|
/**
|
|
@@ -6797,7 +6372,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
6797
6372
|
return;
|
|
6798
6373
|
}
|
|
6799
6374
|
if (getEnabled$1()) {
|
|
6800
|
-
const tokenMap = await invoke$
|
|
6375
|
+
const tokenMap = await invoke$1('Tokenizer.load', languageId, tokenizePath);
|
|
6801
6376
|
set$1(languageId, tokenMap);
|
|
6802
6377
|
return;
|
|
6803
6378
|
}
|
|
@@ -6902,8 +6477,8 @@ const setSelections = (editor, selections) => {
|
|
|
6902
6477
|
};
|
|
6903
6478
|
};
|
|
6904
6479
|
|
|
6905
|
-
const create$
|
|
6906
|
-
const uid = create$
|
|
6480
|
+
const create$1 = () => {
|
|
6481
|
+
const uid = create$7();
|
|
6907
6482
|
const widget = {
|
|
6908
6483
|
id: Hover,
|
|
6909
6484
|
oldState: {
|
|
@@ -6956,18 +6531,18 @@ const getHover = async (editor, offset) => {
|
|
|
6956
6531
|
|
|
6957
6532
|
let _ipc;
|
|
6958
6533
|
const listen$2 = async () => {
|
|
6959
|
-
const ipc = await create$
|
|
6534
|
+
const ipc = await create$9({
|
|
6960
6535
|
method: RendererProcess
|
|
6961
6536
|
});
|
|
6962
6537
|
handleIpc(ipc);
|
|
6963
6538
|
_ipc = ipc;
|
|
6964
6539
|
};
|
|
6965
|
-
const invoke
|
|
6540
|
+
const invoke = async (method, ...args) => {
|
|
6966
6541
|
return invoke$9(_ipc, method, ...args);
|
|
6967
6542
|
};
|
|
6968
6543
|
|
|
6969
6544
|
const measureTextBlockHeight = async (text, fontFamily, fontSize, lineHeight, width) => {
|
|
6970
|
-
return invoke
|
|
6545
|
+
return invoke('MeasureTextBlockHeight.measureTextBlockHeight', text, fontSize, fontFamily, lineHeight, width);
|
|
6971
6546
|
};
|
|
6972
6547
|
|
|
6973
6548
|
const deepCopy = value => {
|
|
@@ -7173,7 +6748,7 @@ const newStateGenerator = async state => {
|
|
|
7173
6748
|
return loadHoverContent(state);
|
|
7174
6749
|
};
|
|
7175
6750
|
const showHover2 = async editor => {
|
|
7176
|
-
return addWidgetToEditor(Hover, FocusEditorHover, editor, create$
|
|
6751
|
+
return addWidgetToEditor(Hover, FocusEditorHover, editor, create$1, newStateGenerator);
|
|
7177
6752
|
};
|
|
7178
6753
|
|
|
7179
6754
|
const EditorHover = 'EditorHover';
|
|
@@ -7236,8 +6811,8 @@ const loadSourceActions = async (editor, state) => {
|
|
|
7236
6811
|
};
|
|
7237
6812
|
};
|
|
7238
6813
|
|
|
7239
|
-
const create
|
|
7240
|
-
const completionUid = create$
|
|
6814
|
+
const create = () => {
|
|
6815
|
+
const completionUid = create$7();
|
|
7241
6816
|
const widget = {
|
|
7242
6817
|
id: SourceAction$1,
|
|
7243
6818
|
oldState: {
|
|
@@ -7268,7 +6843,7 @@ const showSourceActions = async editor => {
|
|
|
7268
6843
|
const newStateGenerator = async state => {
|
|
7269
6844
|
return loadSourceActions(editor, state);
|
|
7270
6845
|
};
|
|
7271
|
-
return addWidgetToEditor(SourceAction$1, SourceActions, editor, create
|
|
6846
|
+
return addWidgetToEditor(SourceAction$1, SourceActions, editor, create, newStateGenerator);
|
|
7272
6847
|
};
|
|
7273
6848
|
|
|
7274
6849
|
const compareString = (a, b) => {
|
|
@@ -7341,6 +6916,16 @@ const executeTabCompletionProvider = async (editor, offset) => {
|
|
|
7341
6916
|
});
|
|
7342
6917
|
};
|
|
7343
6918
|
|
|
6919
|
+
const getOffsetAtCursor = editor => {
|
|
6920
|
+
const {
|
|
6921
|
+
selections
|
|
6922
|
+
} = editor;
|
|
6923
|
+
const rowIndex = selections[0];
|
|
6924
|
+
const columnIndex = selections[1];
|
|
6925
|
+
const offset = offsetAt(editor, rowIndex, columnIndex);
|
|
6926
|
+
return offset;
|
|
6927
|
+
};
|
|
6928
|
+
|
|
7344
6929
|
const getTabCompletion = async editor => {
|
|
7345
6930
|
const offset = getOffsetAtCursor(editor);
|
|
7346
6931
|
const completions = await executeTabCompletionProvider(editor, offset);
|
|
@@ -7887,7 +7472,6 @@ const typeWithAutoClosing = async (editor, text) => {
|
|
|
7887
7472
|
|
|
7888
7473
|
return newEditor;
|
|
7889
7474
|
// if (isBrace(text)) {
|
|
7890
|
-
// console.log('is brace')
|
|
7891
7475
|
// return editorTypeWithBraceCompletion(editor, text)
|
|
7892
7476
|
// }
|
|
7893
7477
|
// if (isSlash(text)) {
|
|
@@ -8051,242 +7635,151 @@ const editorUnindent = editor => {
|
|
|
8051
7635
|
|
|
8052
7636
|
// editor.lines //?
|
|
8053
7637
|
|
|
8054
|
-
const
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
return editor;
|
|
7638
|
+
const isFunctional = widgetId => {
|
|
7639
|
+
switch (widgetId) {
|
|
7640
|
+
case ColorPicker:
|
|
7641
|
+
case Rename:
|
|
7642
|
+
case Completion:
|
|
7643
|
+
case Find:
|
|
7644
|
+
return true;
|
|
7645
|
+
default:
|
|
7646
|
+
return false;
|
|
8064
7647
|
}
|
|
8065
|
-
const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
|
|
8066
|
-
return {
|
|
8067
|
-
...editor,
|
|
8068
|
-
widgets: newWidgets
|
|
8069
|
-
};
|
|
8070
|
-
};
|
|
8071
|
-
|
|
8072
|
-
const focusIndex$1 = (state, index) => {
|
|
8073
|
-
const newState = {
|
|
8074
|
-
...state,
|
|
8075
|
-
focusedIndex: index,
|
|
8076
|
-
focused: true
|
|
8077
|
-
};
|
|
8078
|
-
return newState;
|
|
8079
|
-
};
|
|
8080
|
-
|
|
8081
|
-
const focusFirst = state => {
|
|
8082
|
-
const firstIndex = 0;
|
|
8083
|
-
return focusIndex$1(state, firstIndex);
|
|
8084
|
-
};
|
|
8085
|
-
|
|
8086
|
-
const focusNext$1 = state => {
|
|
8087
|
-
const nextIndex = state.focusedIndex + 1;
|
|
8088
|
-
return focusIndex$1(state, nextIndex);
|
|
8089
|
-
};
|
|
8090
|
-
|
|
8091
|
-
const focusPrevious = state => {
|
|
8092
|
-
const previousIndex = state.focusedIndex - 1;
|
|
8093
|
-
return focusIndex$1(state, previousIndex);
|
|
8094
7648
|
};
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
//
|
|
8098
|
-
//
|
|
8099
|
-
|
|
8100
|
-
return Math.ceil(listHeight / itemHeight) + 1;
|
|
8101
|
-
};
|
|
8102
|
-
|
|
8103
|
-
const setDeltaY = (state, value) => {
|
|
8104
|
-
object(state);
|
|
8105
|
-
number(value);
|
|
7649
|
+
const addWidget$1 = (widget, id, render) => {
|
|
7650
|
+
const commands = render(widget);
|
|
7651
|
+
// TODO how to generate a unique integer id
|
|
7652
|
+
// that doesn't collide with ids created in renderer worker?
|
|
7653
|
+
// @ts-ignore
|
|
8106
7654
|
const {
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
return state;
|
|
7655
|
+
uid
|
|
7656
|
+
} = widget.newState;
|
|
7657
|
+
const allCommands = [];
|
|
7658
|
+
allCommands.push(['Viewlet.createFunctionalRoot', id, uid, isFunctional(widget.id)]);
|
|
7659
|
+
allCommands.push(...commands);
|
|
7660
|
+
if (isFunctional(widget.id)) {
|
|
7661
|
+
allCommands.push(['Viewlet.appendToBody', uid]);
|
|
7662
|
+
} else {
|
|
7663
|
+
allCommands.push(['Viewlet.send', uid, 'appendWidget']);
|
|
8117
7664
|
}
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
return setDeltaY(state, state.deltaY + deltaY);
|
|
8133
|
-
};
|
|
8134
|
-
|
|
8135
|
-
const handleWheel = (state, deltaMode, deltaY) => {
|
|
8136
|
-
const newState = handleWheel$1(state, deltaMode, deltaY);
|
|
8137
|
-
return newState;
|
|
7665
|
+
const focusCommandIndex = allCommands.findIndex(command => {
|
|
7666
|
+
return command[2] === 'focus' || command[0] === 'Viewlet.focusSelector';
|
|
7667
|
+
});
|
|
7668
|
+
// TODO have separate rendering functions, e.g.
|
|
7669
|
+
// 1. renderDom
|
|
7670
|
+
// 2. renderAriaAnnouncement
|
|
7671
|
+
// 3. renderFocus
|
|
7672
|
+
// to ensure that focus is always after the element is added to the dom
|
|
7673
|
+
if (focusCommandIndex !== -1) {
|
|
7674
|
+
const command = allCommands[focusCommandIndex];
|
|
7675
|
+
allCommands.splice(focusCommandIndex, 1);
|
|
7676
|
+
allCommands.push(command);
|
|
7677
|
+
}
|
|
7678
|
+
return allCommands;
|
|
8138
7679
|
};
|
|
8139
7680
|
|
|
8140
|
-
const
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
borderSize: 1
|
|
8152
|
-
},
|
|
8153
|
-
newState: {
|
|
8154
|
-
content: '',
|
|
8155
|
-
uid: completionUid,
|
|
8156
|
-
x: 0,
|
|
8157
|
-
y: 0,
|
|
8158
|
-
width: 0,
|
|
8159
|
-
height: 0,
|
|
8160
|
-
borderSize: 1
|
|
8161
|
-
}
|
|
8162
|
-
};
|
|
8163
|
-
return completionWidget;
|
|
8164
|
-
};
|
|
7681
|
+
const AppendToBody = 'Viewlet.appendToBody';
|
|
7682
|
+
const Focus = 'focus';
|
|
7683
|
+
const RegisterEventListeners = 'Viewlet.registerEventListeners';
|
|
7684
|
+
const SetSelectionByName = 'Viewlet.setSelectionByName';
|
|
7685
|
+
const SetValueByName = 'Viewlet.setValueByName';
|
|
7686
|
+
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
7687
|
+
const SetBounds = 'setBounds';
|
|
7688
|
+
const SetBounds2 = 'Viewlet.setBounds';
|
|
7689
|
+
const SetCss = 'Viewlet.setCss';
|
|
7690
|
+
const SetDom2 = 'Viewlet.setDom2';
|
|
7691
|
+
const SetUid = 'Viewlet.setUid';
|
|
8165
7692
|
|
|
8166
|
-
const
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
height: 100
|
|
8172
|
-
};
|
|
7693
|
+
const renderFull$4 = (oldState, newState) => {
|
|
7694
|
+
const commands = [...newState.commands];
|
|
7695
|
+
// @ts-ignore
|
|
7696
|
+
newState.commands = [];
|
|
7697
|
+
return commands;
|
|
8173
7698
|
};
|
|
8174
7699
|
|
|
8175
|
-
const
|
|
7700
|
+
const render$c = widget => {
|
|
7701
|
+
const commands = renderFull$4(widget.oldState, widget.newState);
|
|
7702
|
+
const wrappedCommands = [];
|
|
8176
7703
|
const {
|
|
8177
|
-
|
|
8178
|
-
} =
|
|
8179
|
-
for (const
|
|
8180
|
-
if (
|
|
8181
|
-
|
|
7704
|
+
uid
|
|
7705
|
+
} = widget.newState;
|
|
7706
|
+
for (const command of commands) {
|
|
7707
|
+
if (command[0] === SetDom2 || command[0] === SetCss || command[0] === AppendToBody || command[0] === SetBounds2 || command[0] === RegisterEventListeners || command[0] === SetSelectionByName || command[0] === SetValueByName || command[0] === SetFocusContext || command[0] === SetUid || command[0] === 'Viewlet.focusSelector') {
|
|
7708
|
+
wrappedCommands.push(command);
|
|
7709
|
+
} else {
|
|
7710
|
+
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
8182
7711
|
}
|
|
8183
7712
|
}
|
|
8184
|
-
return
|
|
7713
|
+
return wrappedCommands;
|
|
8185
7714
|
};
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
return getWidgetState(editor, Completion);
|
|
7715
|
+
const add$7 = widget => {
|
|
7716
|
+
return addWidget$1(widget, 'EditorRename', render$c);
|
|
8189
7717
|
};
|
|
8190
|
-
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
const
|
|
7718
|
+
const remove$7 = widget => {
|
|
7719
|
+
return [['Viewlet.dispose', widget.newState.uid]];
|
|
7720
|
+
};
|
|
7721
|
+
const createFn = key => {
|
|
7722
|
+
const fn = async state => {
|
|
7723
|
+
const {
|
|
7724
|
+
uid
|
|
7725
|
+
} = state;
|
|
7726
|
+
await invoke$3(`Completions.${key}`, uid);
|
|
7727
|
+
const diff = await invoke$3('Completions.diff2', uid);
|
|
7728
|
+
const commands = await invoke$3('Completions.render2', uid, diff);
|
|
7729
|
+
return {
|
|
8200
7730
|
...state,
|
|
8201
|
-
|
|
8202
|
-
...getCompletionDetailBounds(child, borderSize)
|
|
7731
|
+
commands
|
|
8203
7732
|
};
|
|
8204
|
-
return newestState;
|
|
8205
|
-
};
|
|
8206
|
-
return addWidgetToEditor(CompletionDetail, CompletionDetail$1, editor, create, newStateGenerator);
|
|
8207
|
-
};
|
|
8208
|
-
|
|
8209
|
-
const getEdits = async (editor, completionItem) => {
|
|
8210
|
-
const child = getCompletionState(editor);
|
|
8211
|
-
// @ts-ignore
|
|
8212
|
-
const {
|
|
8213
|
-
leadingWord} = child;
|
|
8214
|
-
const word = completionItem.label;
|
|
8215
|
-
const resolvedItem = await resolveCompletion(editor, word, completionItem);
|
|
8216
|
-
const inserted = resolvedItem ? resolvedItem.snippet : word;
|
|
8217
|
-
// TODO type and dispose commands should be sent to renderer process at the same time
|
|
8218
|
-
const {
|
|
8219
|
-
selections
|
|
8220
|
-
} = editor;
|
|
8221
|
-
const [startRowIndex, startColumnIndex] = selections;
|
|
8222
|
-
const leadingWordLength = leadingWord.length;
|
|
8223
|
-
const replaceRange$1 = new Uint32Array([startRowIndex, startColumnIndex - leadingWordLength, startRowIndex, startColumnIndex]);
|
|
8224
|
-
const changes = replaceRange(editor, replaceRange$1, [inserted], '');
|
|
8225
|
-
return changes;
|
|
8226
|
-
};
|
|
8227
|
-
const select = async (editor, completionItem) => {
|
|
8228
|
-
const changes = await getEdits(editor, completionItem);
|
|
8229
|
-
const index = editor.widgets.indexOf
|
|
8230
|
-
// ViewletModuleId.EditorCompletion
|
|
8231
|
-
();
|
|
8232
|
-
if (index !== -1) {
|
|
8233
|
-
editor.widgets.splice(index, 1);
|
|
8234
|
-
editor.completionState = None$1;
|
|
8235
|
-
editor.completionUid = 0;
|
|
8236
|
-
}
|
|
8237
|
-
// TODO dispose completion widget
|
|
8238
|
-
// TODO apply edit in editor worker instead of asking renderer worker
|
|
8239
|
-
// await RendererWorker.invoke('Viewlet.dispose', state.uid)
|
|
8240
|
-
const {
|
|
8241
|
-
widgets
|
|
8242
|
-
} = editor;
|
|
8243
|
-
const newWidgets = removeEditorWidget(widgets, Completion);
|
|
8244
|
-
const intermediateEditor = await applyEdit(editor, changes);
|
|
8245
|
-
return {
|
|
8246
|
-
...intermediateEditor,
|
|
8247
|
-
widgets: newWidgets
|
|
8248
7733
|
};
|
|
7734
|
+
return fn;
|
|
8249
7735
|
};
|
|
8250
|
-
const
|
|
8251
|
-
const
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
}
|
|
8255
|
-
const {
|
|
8256
|
-
items
|
|
8257
|
-
} = child;
|
|
8258
|
-
if (index === -1) {
|
|
8259
|
-
return editor;
|
|
8260
|
-
}
|
|
8261
|
-
if (index > items.length) {
|
|
8262
|
-
throw new Error('index too large');
|
|
8263
|
-
}
|
|
8264
|
-
const actualIndex = index;
|
|
8265
|
-
const completionItem = items[actualIndex];
|
|
8266
|
-
return select(editor, completionItem);
|
|
8267
|
-
};
|
|
8268
|
-
|
|
8269
|
-
const selectCurrent = editor => {
|
|
8270
|
-
const child = getCompletionState(editor);
|
|
8271
|
-
if (!child) {
|
|
8272
|
-
return editor;
|
|
7736
|
+
const createFns = keys => {
|
|
7737
|
+
const fns = Object.create(null);
|
|
7738
|
+
for (const key of keys) {
|
|
7739
|
+
fns[key] = createFn(key);
|
|
8273
7740
|
}
|
|
8274
|
-
|
|
8275
|
-
focusedIndex
|
|
8276
|
-
} = child;
|
|
8277
|
-
return selectIndex(editor, focusedIndex);
|
|
8278
|
-
};
|
|
8279
|
-
|
|
8280
|
-
const getCompletionDetailState = editor => {
|
|
8281
|
-
return getWidgetState(editor, CompletionDetail);
|
|
7741
|
+
return fns;
|
|
8282
7742
|
};
|
|
7743
|
+
const {
|
|
7744
|
+
focusFirst,
|
|
7745
|
+
focusIndex: focusIndex$1,
|
|
7746
|
+
focusLast,
|
|
7747
|
+
focusNext: focusNext$1,
|
|
7748
|
+
focusPrevious,
|
|
7749
|
+
handleEditorBlur,
|
|
7750
|
+
handleEditorClick,
|
|
7751
|
+
handleEditorDeleteLeft: handleEditorDeleteLeft$1,
|
|
7752
|
+
handleEditorType: handleEditorType$1,
|
|
7753
|
+
openDetails,
|
|
7754
|
+
selectCurrent,
|
|
7755
|
+
selectIndex,
|
|
7756
|
+
toggleDetails,
|
|
7757
|
+
closeDetails,
|
|
7758
|
+
handleWheel,
|
|
7759
|
+
close
|
|
7760
|
+
} = createFns(['handleEditorType', 'focusFirst', 'focusNext', 'focusPrevious', 'focusLast', 'handleEditorDeleteLeft', 'openDetails', 'focusIndex', 'handleEditorBlur', 'handleEditorClick', 'openDetails', 'selectCurrent', 'selectIndex', 'toggleDetails', 'closeDetails', 'handleWheel', 'close']);
|
|
8283
7761
|
|
|
8284
|
-
const
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
7762
|
+
const EditorCompletionWidget = {
|
|
7763
|
+
__proto__: null,
|
|
7764
|
+
add: add$7,
|
|
7765
|
+
close,
|
|
7766
|
+
closeDetails,
|
|
7767
|
+
focusFirst,
|
|
7768
|
+
focusIndex: focusIndex$1,
|
|
7769
|
+
focusLast,
|
|
7770
|
+
focusNext: focusNext$1,
|
|
7771
|
+
focusPrevious,
|
|
7772
|
+
handleEditorBlur,
|
|
7773
|
+
handleEditorClick,
|
|
7774
|
+
handleEditorDeleteLeft: handleEditorDeleteLeft$1,
|
|
7775
|
+
handleEditorType: handleEditorType$1,
|
|
7776
|
+
handleWheel,
|
|
7777
|
+
openDetails,
|
|
7778
|
+
remove: remove$7,
|
|
7779
|
+
render: render$c,
|
|
7780
|
+
selectCurrent,
|
|
7781
|
+
selectIndex,
|
|
7782
|
+
toggleDetails
|
|
8290
7783
|
};
|
|
8291
7784
|
|
|
8292
7785
|
const loadContent = async (editorUid, state, position) => {
|
|
@@ -8331,22 +7824,16 @@ const handleSashPointerUp = (state, eventX, eventY) => {
|
|
|
8331
7824
|
const CodeGeneratorInput$1 = 'CodeGeneratorInput';
|
|
8332
7825
|
const CodeGeneratorMessage = 'CodeGeneratorMessage';
|
|
8333
7826
|
const CodeGeneratorWidget = 'CodeGeneratorWidget';
|
|
8334
|
-
const ColoredMaskIcon = 'ColoredMaskIcon';
|
|
8335
7827
|
const DiagnosticError = 'DiagnosticError';
|
|
8336
7828
|
const DiagnosticWarning = 'DiagnosticWarning';
|
|
8337
7829
|
const CompletionDetailCloseButton = 'CompletionDetailCloseButton';
|
|
8338
7830
|
const CompletionDetailContent = 'CompletionDetailContent';
|
|
8339
7831
|
const Diagnostic = 'Diagnostic';
|
|
8340
|
-
const EditorCompletionItem = 'EditorCompletionItem';
|
|
8341
|
-
const EditorCompletionItemDeprecated = 'EditorCompletionItemDeprecated';
|
|
8342
|
-
const EditorCompletionItemFocused = 'EditorCompletionItemFocused';
|
|
8343
|
-
const EditorCompletionItemHighlight = 'EditorCompletionItemHighlight';
|
|
8344
7832
|
const EditorCursor = 'EditorCursor';
|
|
8345
7833
|
const EditorRow = 'EditorRow';
|
|
8346
7834
|
const EditorSelection = 'EditorSelection';
|
|
8347
7835
|
const EditorSourceActions = 'EditorSourceActions';
|
|
8348
7836
|
const EditorSourceActionsList = 'EditorSourceActionsList';
|
|
8349
|
-
const FileIcon = 'FileIcon';
|
|
8350
7837
|
const HoverDisplayString = 'HoverDisplayString';
|
|
8351
7838
|
const HoverDocumentation = 'HoverDocumentation';
|
|
8352
7839
|
const HoverEditorRow = 'HoverEditorRow';
|
|
@@ -8355,7 +7842,6 @@ const HoverProblemDetail = 'HoverProblemDetail';
|
|
|
8355
7842
|
const HoverProblemMessage = 'HoverProblemMessage';
|
|
8356
7843
|
const IconClose = 'IconClose';
|
|
8357
7844
|
const InputBox = 'InputBox';
|
|
8358
|
-
const Label = 'Label';
|
|
8359
7845
|
const MaskIcon = 'MaskIcon';
|
|
8360
7846
|
const MaskIconSymbolFile = 'MaskIconSymbolFile';
|
|
8361
7847
|
const SourceActionHeading = 'SourceActionHeading';
|
|
@@ -8383,7 +7869,6 @@ const Div = 4;
|
|
|
8383
7869
|
const Input = 6;
|
|
8384
7870
|
const Span = 8;
|
|
8385
7871
|
const Text = 12;
|
|
8386
|
-
const Img = 17;
|
|
8387
7872
|
|
|
8388
7873
|
const text = data => {
|
|
8389
7874
|
return {
|
|
@@ -8469,21 +7954,6 @@ const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
|
|
|
8469
7954
|
return dom;
|
|
8470
7955
|
};
|
|
8471
7956
|
|
|
8472
|
-
const AppendToBody = 'Viewlet.appendToBody';
|
|
8473
|
-
const Focus = 'focus';
|
|
8474
|
-
const RegisterEventListeners = 'Viewlet.registerEventListeners';
|
|
8475
|
-
const SetSelectionByName = 'Viewlet.setSelectionByName';
|
|
8476
|
-
const SetValueByName = 'Viewlet.setValueByName';
|
|
8477
|
-
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
8478
|
-
const SetBounds = 'setBounds';
|
|
8479
|
-
const SetBounds2 = 'Viewlet.setBounds';
|
|
8480
|
-
const SetContentHeight = 'setContentHeight';
|
|
8481
|
-
const SetCss = 'Viewlet.setCss';
|
|
8482
|
-
const SetDom2 = 'Viewlet.setDom2';
|
|
8483
|
-
const SetNegativeMargin = 'setNegativeMargin';
|
|
8484
|
-
const SetScrollBar = 'setScrollBar';
|
|
8485
|
-
const SetUid = 'Viewlet.setUid';
|
|
8486
|
-
|
|
8487
7957
|
const renderHoverDom = {
|
|
8488
7958
|
isEqual(oldState, newState) {
|
|
8489
7959
|
return oldState.lineInfos === newState.lineInfos && oldState.documentation === newState.documentation && oldState.diagnostics === newState.diagnostics;
|
|
@@ -8493,7 +7963,7 @@ const renderHoverDom = {
|
|
|
8493
7963
|
return [/* method */SetDom2, dom];
|
|
8494
7964
|
}
|
|
8495
7965
|
};
|
|
8496
|
-
const renderBounds$
|
|
7966
|
+
const renderBounds$3 = {
|
|
8497
7967
|
isEqual(oldState, newState) {
|
|
8498
7968
|
return oldState.x === newState.x && oldState.y === newState.y;
|
|
8499
7969
|
},
|
|
@@ -8507,10 +7977,10 @@ const renderBounds$4 = {
|
|
|
8507
7977
|
return [SetBounds, x, y, width, height];
|
|
8508
7978
|
}
|
|
8509
7979
|
};
|
|
8510
|
-
const render$
|
|
7980
|
+
const render$b = [renderHoverDom, renderBounds$3];
|
|
8511
7981
|
const renderHover = (oldState, newState) => {
|
|
8512
7982
|
const commands = [];
|
|
8513
|
-
for (const item of render$
|
|
7983
|
+
for (const item of render$b) {
|
|
8514
7984
|
if (!item.isEqual(oldState, newState)) {
|
|
8515
7985
|
commands.push(item.apply(oldState, newState));
|
|
8516
7986
|
}
|
|
@@ -8536,39 +8006,19 @@ const focusNext = state => {
|
|
|
8536
8006
|
return focusIndex(state, nextIndex);
|
|
8537
8007
|
};
|
|
8538
8008
|
|
|
8539
|
-
const
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
});
|
|
8552
|
-
const rpc = await MessagePortRpcParent.create({
|
|
8553
|
-
commandMap: {},
|
|
8554
|
-
messagePort: port2,
|
|
8555
|
-
isMessagePortOpen: true
|
|
8556
|
-
});
|
|
8557
|
-
port2.start();
|
|
8558
|
-
await rpc.invoke('Completions.initialize');
|
|
8559
|
-
return rpc;
|
|
8560
|
-
};
|
|
8561
|
-
|
|
8562
|
-
let workerPromise;
|
|
8563
|
-
const getOrCreate = () => {
|
|
8564
|
-
if (!workerPromise) {
|
|
8565
|
-
workerPromise = launchCompletionWorker();
|
|
8009
|
+
const getWidgetInvoke = widgetId => {
|
|
8010
|
+
switch (widgetId) {
|
|
8011
|
+
case ColorPicker:
|
|
8012
|
+
return invoke$6;
|
|
8013
|
+
case Completion:
|
|
8014
|
+
return invoke$3;
|
|
8015
|
+
case Find:
|
|
8016
|
+
return invoke$2;
|
|
8017
|
+
case Rename:
|
|
8018
|
+
return invoke$4;
|
|
8019
|
+
default:
|
|
8020
|
+
return undefined;
|
|
8566
8021
|
}
|
|
8567
|
-
return workerPromise;
|
|
8568
|
-
};
|
|
8569
|
-
const invoke = async (method, ...params) => {
|
|
8570
|
-
const worker = await getOrCreate();
|
|
8571
|
-
return await worker.invoke(method, ...params);
|
|
8572
8022
|
};
|
|
8573
8023
|
|
|
8574
8024
|
const updateWidget = (editor, widgetId, newState) => {
|
|
@@ -8591,20 +8041,8 @@ const updateWidget = (editor, widgetId, newState) => {
|
|
|
8591
8041
|
};
|
|
8592
8042
|
};
|
|
8593
8043
|
|
|
8594
|
-
const getInvoke = widgetId => {
|
|
8595
|
-
switch (widgetId) {
|
|
8596
|
-
case ColorPicker:
|
|
8597
|
-
return invoke$6;
|
|
8598
|
-
case Completion:
|
|
8599
|
-
return invoke;
|
|
8600
|
-
case Find:
|
|
8601
|
-
return invoke$4;
|
|
8602
|
-
default:
|
|
8603
|
-
return undefined;
|
|
8604
|
-
}
|
|
8605
|
-
};
|
|
8606
8044
|
const executeWidgetCommand = async (editor, name, method, _uid, widgetId, ...params) => {
|
|
8607
|
-
const invoke =
|
|
8045
|
+
const invoke = getWidgetInvoke(widgetId);
|
|
8608
8046
|
const actualMethod = method.slice(name.length + 1);
|
|
8609
8047
|
const widget = editor.widgets.find(widget => widget.id === widgetId);
|
|
8610
8048
|
if (!widget) {
|
|
@@ -8625,7 +8063,7 @@ const executeWidgetCommand = async (editor, name, method, _uid, widgetId, ...par
|
|
|
8625
8063
|
}
|
|
8626
8064
|
const diff = await invoke(`${name}.diff2`, uid);
|
|
8627
8065
|
const commands = await invoke(`${name}.render2`, uid, diff);
|
|
8628
|
-
const childIndex =
|
|
8066
|
+
const childIndex = editor.widgets.findIndex(isWidget);
|
|
8629
8067
|
if (childIndex === -1) {
|
|
8630
8068
|
return latestEditor;
|
|
8631
8069
|
}
|
|
@@ -8634,10 +8072,41 @@ const executeWidgetCommand = async (editor, name, method, _uid, widgetId, ...par
|
|
|
8634
8072
|
...childWidget.newState,
|
|
8635
8073
|
commands
|
|
8636
8074
|
};
|
|
8637
|
-
const newEditor = updateWidget(
|
|
8075
|
+
const newEditor = updateWidget(latestEditor, widgetId, newState);
|
|
8638
8076
|
return newEditor;
|
|
8639
8077
|
};
|
|
8640
8078
|
|
|
8079
|
+
const RE_WORD = /[\w\-]+$/;
|
|
8080
|
+
const getWordAtOffset = editor => {
|
|
8081
|
+
const {
|
|
8082
|
+
lines,
|
|
8083
|
+
selections
|
|
8084
|
+
} = editor;
|
|
8085
|
+
const rowIndex = selections[0];
|
|
8086
|
+
const columnIndex = selections[1];
|
|
8087
|
+
const line = lines[rowIndex];
|
|
8088
|
+
const part = line.slice(0, columnIndex);
|
|
8089
|
+
const wordMatch = part.match(RE_WORD);
|
|
8090
|
+
if (wordMatch) {
|
|
8091
|
+
return wordMatch[0];
|
|
8092
|
+
}
|
|
8093
|
+
return '';
|
|
8094
|
+
};
|
|
8095
|
+
|
|
8096
|
+
const FocusEditor = 12;
|
|
8097
|
+
const FocusEditorCompletions = 9;
|
|
8098
|
+
const FocusEditorRename = 11;
|
|
8099
|
+
const FocusEditorText = 12;
|
|
8100
|
+
const FocusFindWidget = 16;
|
|
8101
|
+
const FocusSourceActions = 38;
|
|
8102
|
+
const FocusFindWidgetReplace = 43;
|
|
8103
|
+
const FocusFindWidgetReplaceButton = 46;
|
|
8104
|
+
const FocusFindWidgetReplaceAllButton = 47;
|
|
8105
|
+
const FocusFindWidgetCloseButton = 48;
|
|
8106
|
+
const FocusFindWidgetNextMatchButton = 49;
|
|
8107
|
+
const FocusFindWidgetPreviousMatchButton = 50;
|
|
8108
|
+
const FocusEditorCodeGenerator = 52;
|
|
8109
|
+
|
|
8641
8110
|
const getPositionAtCursor = editorUid => {
|
|
8642
8111
|
const editor = getEditor(editorUid);
|
|
8643
8112
|
return getPositionAtCursor$1(editor);
|
|
@@ -8673,29 +8142,36 @@ const getSelections2 = editorUid => {
|
|
|
8673
8142
|
} = editor;
|
|
8674
8143
|
return selections;
|
|
8675
8144
|
};
|
|
8676
|
-
const
|
|
8677
|
-
// console.log('close find')
|
|
8145
|
+
const closeWidget2 = async (editorUid, widgetId, widgetName, unsetAdditionalFocus$1) => {
|
|
8678
8146
|
const editor = getEditor(editorUid);
|
|
8147
|
+
const invoke = getWidgetInvoke(widgetId);
|
|
8679
8148
|
const {
|
|
8680
8149
|
widgets
|
|
8681
8150
|
} = editor;
|
|
8682
|
-
const index = widgets.findIndex(widget => widget.id ===
|
|
8151
|
+
const index = widgets.findIndex(widget => widget.id === widgetId);
|
|
8683
8152
|
if (index === -1) {
|
|
8684
8153
|
return;
|
|
8685
8154
|
}
|
|
8686
|
-
|
|
8687
|
-
await invoke$4('FindWidget.dispose', findWidget.newState.uid);
|
|
8155
|
+
await invoke(`${widgetName}.dispose`);
|
|
8688
8156
|
const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
|
|
8689
|
-
// TODO transfer focus to editor
|
|
8690
8157
|
const newEditor = {
|
|
8691
8158
|
...editor,
|
|
8692
8159
|
widgets: newWidgets,
|
|
8693
8160
|
focused: true
|
|
8694
8161
|
};
|
|
8695
8162
|
set$4(editorUid, editor, newEditor);
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8163
|
+
await setFocus(FocusEditorText);
|
|
8164
|
+
if (unsetAdditionalFocus$1) {
|
|
8165
|
+
await unsetAdditionalFocus(unsetAdditionalFocus$1);
|
|
8166
|
+
}
|
|
8167
|
+
};
|
|
8168
|
+
const closeFind2 = async editorUid => {
|
|
8169
|
+
await closeWidget2(editorUid, Find, 'FindWidget', 0);
|
|
8170
|
+
};
|
|
8171
|
+
const applyEdits2 = async (editorUid, edits) => {
|
|
8172
|
+
const editor = getEditor(editorUid);
|
|
8173
|
+
const newEditor = await applyEdit(editor, edits);
|
|
8174
|
+
set$4(editorUid, editor, newEditor);
|
|
8699
8175
|
};
|
|
8700
8176
|
|
|
8701
8177
|
const pending = Object.create(null);
|
|
@@ -8792,20 +8268,6 @@ const CtrlCmd = 1 << 11 >>> 0;
|
|
|
8792
8268
|
const Shift = 1 << 10 >>> 0;
|
|
8793
8269
|
const Alt = 1 << 9 >>> 0;
|
|
8794
8270
|
|
|
8795
|
-
const FocusEditor = 12;
|
|
8796
|
-
const FocusEditorCompletions = 9;
|
|
8797
|
-
const FocusEditorRename = 11;
|
|
8798
|
-
const FocusEditorText = 12;
|
|
8799
|
-
const FocusFindWidget = 16;
|
|
8800
|
-
const FocusSourceActions = 38;
|
|
8801
|
-
const FocusFindWidgetReplace = 43;
|
|
8802
|
-
const FocusFindWidgetReplaceButton = 46;
|
|
8803
|
-
const FocusFindWidgetReplaceAllButton = 47;
|
|
8804
|
-
const FocusFindWidgetCloseButton = 48;
|
|
8805
|
-
const FocusFindWidgetNextMatchButton = 49;
|
|
8806
|
-
const FocusFindWidgetPreviousMatchButton = 50;
|
|
8807
|
-
const FocusEditorCodeGenerator = 52;
|
|
8808
|
-
|
|
8809
8271
|
const getKeyBindings = () => {
|
|
8810
8272
|
return [{
|
|
8811
8273
|
key: Escape,
|
|
@@ -8913,7 +8375,7 @@ const getKeyBindings = () => {
|
|
|
8913
8375
|
when: FocusEditorCompletions
|
|
8914
8376
|
}, {
|
|
8915
8377
|
key: Escape,
|
|
8916
|
-
command: '
|
|
8378
|
+
command: 'EditorCompletion.close',
|
|
8917
8379
|
when: FocusEditorCompletions
|
|
8918
8380
|
}, {
|
|
8919
8381
|
key: End,
|
|
@@ -9346,7 +8808,7 @@ const moveLineUp = editor => {
|
|
|
9346
8808
|
};
|
|
9347
8809
|
|
|
9348
8810
|
const Link$1 = 'Link';
|
|
9349
|
-
const Function
|
|
8811
|
+
const Function = 'Function';
|
|
9350
8812
|
const Parameter = 'Parameter';
|
|
9351
8813
|
const Type = 'Type';
|
|
9352
8814
|
const VariableName = 'VariableName';
|
|
@@ -9405,7 +8867,7 @@ const getDecorationClassName = type => {
|
|
|
9405
8867
|
case Ts3073:
|
|
9406
8868
|
case Ts3077:
|
|
9407
8869
|
case Ts3088:
|
|
9408
|
-
return Function
|
|
8870
|
+
return Function;
|
|
9409
8871
|
case Ts1792:
|
|
9410
8872
|
case Ts1793:
|
|
9411
8873
|
return Parameter;
|
|
@@ -9576,10 +9038,10 @@ const getTokensViewport2 = async (editor, startLineIndex, endLineIndex, syncIncr
|
|
|
9576
9038
|
languageId,
|
|
9577
9039
|
invalidStartIndex
|
|
9578
9040
|
};
|
|
9579
|
-
return invoke$
|
|
9041
|
+
return invoke$1('GetTokensViewport.getTokensViewport', slimEditor, startLineIndex, endLineIndex, hasLinesToSend, id, linesToSend);
|
|
9580
9042
|
}
|
|
9581
9043
|
// TODO only send needed lines of text
|
|
9582
|
-
return invoke$
|
|
9044
|
+
return invoke$1('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex, true, editor.id, editor.lines);
|
|
9583
9045
|
}
|
|
9584
9046
|
return getTokensViewport(editor, startLineIndex, endLineIndex);
|
|
9585
9047
|
};
|
|
@@ -9728,7 +9190,6 @@ const getLineInfoDefault = (line, tokenResults, embeddedResults, decorations, To
|
|
|
9728
9190
|
const decorationType = decorations[++decorationIndex];
|
|
9729
9191
|
// @ts-ignore
|
|
9730
9192
|
decorations[++decorationIndex];
|
|
9731
|
-
// console.log('MATCHING DECORATION', {
|
|
9732
9193
|
// decorationIndex,
|
|
9733
9194
|
// decorationLength,
|
|
9734
9195
|
// decorationType,
|
|
@@ -9936,7 +9397,7 @@ const getIncrementalEdits = async (oldState, newState) => {
|
|
|
9936
9397
|
} = newState;
|
|
9937
9398
|
const oldLine = oldState.lines[rowIndex];
|
|
9938
9399
|
const newLine = lines[rowIndex];
|
|
9939
|
-
const incrementalEdits = await invoke$
|
|
9400
|
+
const incrementalEdits = await invoke$1('TokenizeIncremental.tokenizeIncremental', newState.uid, newState.languageId, oldLine, newLine, rowIndex, newState.minLineY);
|
|
9940
9401
|
if (incrementalEdits && incrementalEdits.length === 1) {
|
|
9941
9402
|
return incrementalEdits;
|
|
9942
9403
|
}
|
|
@@ -9964,7 +9425,7 @@ const getSelectionsVirtualDom = selections => {
|
|
|
9964
9425
|
return dom;
|
|
9965
9426
|
};
|
|
9966
9427
|
|
|
9967
|
-
const addWidget
|
|
9428
|
+
const addWidget = widget => {
|
|
9968
9429
|
const module = get$5(widget.id);
|
|
9969
9430
|
if (!module) {
|
|
9970
9431
|
throw new Error('unsupported widget');
|
|
@@ -10114,7 +9575,7 @@ const renderWidgets = {
|
|
|
10114
9575
|
}
|
|
10115
9576
|
const addCommands = [];
|
|
10116
9577
|
for (const addedWidget of addedWidgets) {
|
|
10117
|
-
const childCommands = addWidget
|
|
9578
|
+
const childCommands = addWidget(addedWidget);
|
|
10118
9579
|
if (childCommands.length > 0) {
|
|
10119
9580
|
addCommands.push(...childCommands);
|
|
10120
9581
|
}
|
|
@@ -10138,7 +9599,7 @@ const renderWidgets = {
|
|
|
10138
9599
|
},
|
|
10139
9600
|
multiple: true
|
|
10140
9601
|
};
|
|
10141
|
-
const render$
|
|
9602
|
+
const render$a = [renderLines, renderSelections, renderScrollBarX, renderScrollBarY, renderFocus$1, renderDecorations, renderGutterInfo, renderWidgets];
|
|
10142
9603
|
const renderEditor = async id => {
|
|
10143
9604
|
const instance = get$4(id);
|
|
10144
9605
|
if (!instance) {
|
|
@@ -10150,7 +9611,7 @@ const renderEditor = async id => {
|
|
|
10150
9611
|
} = instance;
|
|
10151
9612
|
const commands = [];
|
|
10152
9613
|
set$4(id, newState, newState);
|
|
10153
|
-
for (const item of render$
|
|
9614
|
+
for (const item of render$a) {
|
|
10154
9615
|
if (!item.isEqual(oldState, newState)) {
|
|
10155
9616
|
const result = await item.apply(oldState, newState);
|
|
10156
9617
|
// @ts-ignore
|
|
@@ -10216,7 +9677,7 @@ const keep = [
|
|
|
10216
9677
|
// 'ColorPicker.handleSliderPointerDown',
|
|
10217
9678
|
// 'ColorPicker.handleSliderPointerMove',
|
|
10218
9679
|
// 'ColorPicker.loadContent',
|
|
10219
|
-
'Editor.create', 'Editor.getWordAt', 'Editor.getWordBefore', 'Editor.offsetAt', 'Editor.render', 'Editor.getKeyBindings', 'Editor.getPositionAtCursor', 'Editor.getWordAt2', 'Editor.getWordAtOffset2', 'Editor.getLines2', 'Editor.closeFind2', 'Editor.getSelections2', 'Editor.getQuickPickMenuEntries',
|
|
9680
|
+
'Editor.create', 'Editor.getWordAt', 'Editor.getWordBefore', 'Editor.offsetAt', 'Editor.render', 'Editor.getKeyBindings', 'Editor.getPositionAtCursor', 'Editor.getWordAt2', 'Editor.getWordAtOffset2', 'Editor.getWordBefore2', 'Editor.getLines2', 'Editor.applyEdit2', 'Editor.applyEdits2', 'Editor.closeFind2', 'Editor.closeWidget2', 'Editor.getSelections2', 'Editor.getQuickPickMenuEntries',
|
|
10220
9681
|
// 'ColorPicker.render',
|
|
10221
9682
|
'Editor.getText', 'Editor.getSelections', 'Font.ensure', 'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', 'Hover.getHoverInfo', 'Hover.handleSashPointerDown', 'Hover.handleSashPointerMove', 'Hover.handleSashPointerUp', 'Hover.loadContent', 'Hover.render', 'Initialize.initialize', 'ActivateByEvent.activateByEvent'];
|
|
10222
9683
|
|
|
@@ -10300,14 +9761,13 @@ const wrapCommands = commands => {
|
|
|
10300
9761
|
const commandMap = {
|
|
10301
9762
|
'ActivateByEvent.activateByEvent': activateByEvent,
|
|
10302
9763
|
'CodeGenerator.accept': codeGeneratorAccept,
|
|
10303
|
-
'ColorPicker.loadContent': loadContent$
|
|
9764
|
+
'ColorPicker.loadContent': loadContent$2,
|
|
10304
9765
|
'Editor.addCursorAbove': addCursorAbove,
|
|
10305
9766
|
'Editor.addCursorBelow': addCursorBelow,
|
|
10306
9767
|
'Editor.applyEdit': applyEdit,
|
|
10307
9768
|
'Editor.braceCompletion': braceCompletion,
|
|
10308
9769
|
'Editor.cancelSelection': cancelSelection,
|
|
10309
9770
|
'Editor.closeCodeGenerator': closeCodeGenerator,
|
|
10310
|
-
'Editor.closeCompletion': closeCompletion,
|
|
10311
9771
|
'Editor.closeFind': closeFind,
|
|
10312
9772
|
'Editor.closeRename': closeRename,
|
|
10313
9773
|
'Editor.closeSourceAction': closeSourceAction,
|
|
@@ -10342,24 +9802,26 @@ const commandMap = {
|
|
|
10342
9802
|
'Editor.deleteRight': deleteCharacterRight,
|
|
10343
9803
|
'Editor.deleteWordLeft': deleteWordLeft,
|
|
10344
9804
|
'Editor.deleteWordPartLeft': deleteWordPartLeft,
|
|
9805
|
+
'Editor.applyEdit2': applyEdits2,
|
|
9806
|
+
'Editor.closeFind2': closeFind2,
|
|
9807
|
+
'Editor.closeWidget2': closeWidget2,
|
|
10345
9808
|
'Editor.deleteWordPartRight': deleteWordPartRight,
|
|
10346
9809
|
'Editor.deleteWordRight': deleteWordRight,
|
|
10347
9810
|
'Editor.executeWidgetCommand': executeWidgetCommand,
|
|
10348
9811
|
'Editor.findAllReferences': findAllReferences,
|
|
10349
9812
|
'Editor.format': format,
|
|
10350
9813
|
'Editor.getKeyBindings': getKeyBindings,
|
|
9814
|
+
'Editor.getLines2': getLines2,
|
|
10351
9815
|
'Editor.getPositionAtCursor': getPositionAtCursor,
|
|
10352
9816
|
'Editor.getQuickPickMenuEntries': getQuickPickMenuEntries,
|
|
10353
9817
|
'Editor.getSelections': getSelections,
|
|
9818
|
+
'Editor.getSelections2': getSelections2,
|
|
10354
9819
|
'Editor.getText': getText,
|
|
10355
9820
|
'Editor.getWordAt': getWordAt$1,
|
|
10356
9821
|
'Editor.getWordAt2': getWordAt,
|
|
10357
9822
|
'Editor.getWordAtOffset2': getWordAtOffset2,
|
|
10358
|
-
'Editor.getWordBefore2': getWordBefore2,
|
|
10359
9823
|
'Editor.getWordBefore': getWordBefore,
|
|
10360
|
-
'Editor.
|
|
10361
|
-
'Editor.getSelections2': getSelections2,
|
|
10362
|
-
'Editor.closeFind2': closeFind2,
|
|
9824
|
+
'Editor.getWordBefore2': getWordBefore2,
|
|
10363
9825
|
'Editor.goToDefinition': goToDefinition,
|
|
10364
9826
|
'Editor.goToTypeDefinition': goToTypeDefinition,
|
|
10365
9827
|
'Editor.handleBeforeInput': handleBeforeInput,
|
|
@@ -10400,6 +9862,21 @@ const commandMap = {
|
|
|
10400
9862
|
'Editor.openCodeGenerator': openCodeGenerator,
|
|
10401
9863
|
'Editor.openColorPicker': openColorPicker,
|
|
10402
9864
|
'Editor.openCompletion': openCompletion,
|
|
9865
|
+
'EditorCompletion.closeDetails': closeDetails,
|
|
9866
|
+
'EditorCompletion.focusFirst': focusFirst,
|
|
9867
|
+
'EditorCompletion.focusIndex': focusIndex$1,
|
|
9868
|
+
'EditorCompletion.focusNext': focusNext$1,
|
|
9869
|
+
'EditorCompletion.focusPrevious': focusPrevious,
|
|
9870
|
+
'EditorCompletion.handleEditorBlur': handleEditorBlur,
|
|
9871
|
+
'EditorCompletion.handleEditorClick': handleEditorClick,
|
|
9872
|
+
'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$1,
|
|
9873
|
+
'EditorCompletion.handleEditorType': handleEditorType$1,
|
|
9874
|
+
'EditorCompletion.handleWheel': handleWheel,
|
|
9875
|
+
'EditorCompletion.openDetails': openDetails,
|
|
9876
|
+
'EditorCompletion.selectCurrent': selectCurrent,
|
|
9877
|
+
'EditorCompletion.close': close,
|
|
9878
|
+
'EditorCompletion.selectIndex': selectIndex,
|
|
9879
|
+
'EditorCompletion.toggleDetails': toggleDetails,
|
|
10403
9880
|
'Editor.openFind': openFind,
|
|
10404
9881
|
'Editor.openFind2': openFind2,
|
|
10405
9882
|
'Editor.openRename': openRename,
|
|
@@ -10429,7 +9906,7 @@ const commandMap = {
|
|
|
10429
9906
|
'Editor.selectWordRight': selectWordRight,
|
|
10430
9907
|
'Editor.setDecorations': setDecorations,
|
|
10431
9908
|
'Editor.setDelta': setDelta,
|
|
10432
|
-
'Editor.setDeltaY': setDeltaY
|
|
9909
|
+
'Editor.setDeltaY': setDeltaY,
|
|
10433
9910
|
'Editor.setLanguageId': setLanguageId,
|
|
10434
9911
|
'Editor.setSelections': setSelections,
|
|
10435
9912
|
'Editor.showHover': showHover,
|
|
@@ -10446,24 +9923,8 @@ const commandMap = {
|
|
|
10446
9923
|
'Editor.undo': undo,
|
|
10447
9924
|
'Editor.unIndent': editorUnindent,
|
|
10448
9925
|
'Editor.updateDiagnostics': updateDiagnostics,
|
|
10449
|
-
'EditorCompletion.advance': advance,
|
|
10450
|
-
'EditorCompletion.closeDetails': closeDetails,
|
|
10451
|
-
'EditorCompletion.focusFirst': focusFirst,
|
|
10452
|
-
'EditorCompletion.focusIndex': focusIndex$1,
|
|
10453
|
-
'EditorCompletion.focusNext': focusNext$1,
|
|
10454
|
-
'EditorCompletion.focusPrevious': focusPrevious,
|
|
10455
|
-
'EditorCompletion.handleEditorBlur': handleEditorBlur,
|
|
10456
|
-
'EditorCompletion.handleEditorClick': handleEditorClick,
|
|
10457
|
-
'EditorCompletion.handleEditorDeleteLeft': handleEditorDeleteLeft$2,
|
|
10458
|
-
'EditorCompletion.handleEditorType': handleEditorType$2,
|
|
10459
|
-
'EditorCompletion.handleWheel': handleWheel,
|
|
10460
|
-
'EditorCompletion.loadContent': loadContent$2,
|
|
10461
|
-
'EditorCompletion.openDetails': openDetails,
|
|
10462
|
-
'EditorCompletion.selectCurrent': selectCurrent,
|
|
10463
|
-
'EditorCompletion.selectIndex': selectIndex,
|
|
10464
|
-
'EditorCompletion.toggleDetails': toggleDetails,
|
|
10465
9926
|
'EditorSourceActions.focusNext': focusNext,
|
|
10466
|
-
'FindWidget.close': close,
|
|
9927
|
+
'FindWidget.close': close$1,
|
|
10467
9928
|
'FindWidget.loadContent': loadContent$1,
|
|
10468
9929
|
'Font.ensure': ensure,
|
|
10469
9930
|
'Hover.getHoverInfo': getEditorHoverInfo,
|
|
@@ -10523,55 +9984,13 @@ const listen$1 = async ({
|
|
|
10523
9984
|
return ipc;
|
|
10524
9985
|
};
|
|
10525
9986
|
|
|
10526
|
-
const listen = async () => {
|
|
10527
|
-
register(commandMap);
|
|
10528
|
-
const ipc = await listen$1({
|
|
10529
|
-
method: Auto()
|
|
10530
|
-
});
|
|
10531
|
-
handleIpc(ipc);
|
|
10532
|
-
listen$5(ipc);
|
|
10533
|
-
};
|
|
10534
|
-
|
|
10535
|
-
const isFunctional = widgetId => {
|
|
10536
|
-
switch (widgetId) {
|
|
10537
|
-
case ColorPicker:
|
|
10538
|
-
case Rename:
|
|
10539
|
-
case Find:
|
|
10540
|
-
return true;
|
|
10541
|
-
default:
|
|
10542
|
-
return false;
|
|
10543
|
-
}
|
|
10544
|
-
};
|
|
10545
|
-
const addWidget = (widget, id, render) => {
|
|
10546
|
-
const commands = render(widget);
|
|
10547
|
-
// TODO how to generate a unique integer id
|
|
10548
|
-
// that doesn't collide with ids created in renderer worker?
|
|
10549
|
-
// @ts-ignore
|
|
10550
|
-
const {
|
|
10551
|
-
uid
|
|
10552
|
-
} = widget.newState;
|
|
10553
|
-
const allCommands = [];
|
|
10554
|
-
allCommands.push(['Viewlet.createFunctionalRoot', id, uid, isFunctional(widget.id)]);
|
|
10555
|
-
allCommands.push(...commands);
|
|
10556
|
-
if (isFunctional(widget.id)) {
|
|
10557
|
-
allCommands.push(['Viewlet.appendToBody', uid]);
|
|
10558
|
-
} else {
|
|
10559
|
-
allCommands.push(['Viewlet.send', uid, 'appendWidget']);
|
|
10560
|
-
}
|
|
10561
|
-
const focusCommandIndex = allCommands.findIndex(command => {
|
|
10562
|
-
return command[2] === 'focus' || command[0] === 'Viewlet.focusSelector';
|
|
10563
|
-
});
|
|
10564
|
-
// TODO have separate rendering functions, e.g.
|
|
10565
|
-
// 1. renderDom
|
|
10566
|
-
// 2. renderAriaAnnouncement
|
|
10567
|
-
// 3. renderFocus
|
|
10568
|
-
// to ensure that focus is always after the element is added to the dom
|
|
10569
|
-
if (focusCommandIndex !== -1) {
|
|
10570
|
-
const command = allCommands[focusCommandIndex];
|
|
10571
|
-
allCommands.splice(focusCommandIndex, 1);
|
|
10572
|
-
allCommands.push(command);
|
|
10573
|
-
}
|
|
10574
|
-
return allCommands;
|
|
9987
|
+
const listen = async () => {
|
|
9988
|
+
register(commandMap);
|
|
9989
|
+
const ipc = await listen$1({
|
|
9990
|
+
method: Auto()
|
|
9991
|
+
});
|
|
9992
|
+
handleIpc(ipc);
|
|
9993
|
+
listen$5(ipc);
|
|
10575
9994
|
};
|
|
10576
9995
|
|
|
10577
9996
|
const removeWidget = widget => {
|
|
@@ -10610,7 +10029,7 @@ const renderContent$1 = {
|
|
|
10610
10029
|
return [SetDom2, newState.uid, dom];
|
|
10611
10030
|
}
|
|
10612
10031
|
};
|
|
10613
|
-
const renderBounds$
|
|
10032
|
+
const renderBounds$2 = {
|
|
10614
10033
|
isEqual(oldState, newState) {
|
|
10615
10034
|
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
10616
10035
|
},
|
|
@@ -10632,10 +10051,10 @@ const renderFocus = {
|
|
|
10632
10051
|
return [Focus, '.CodeGeneratorInput', newState.focusSource];
|
|
10633
10052
|
}
|
|
10634
10053
|
};
|
|
10635
|
-
const render$
|
|
10636
|
-
const renderFull$
|
|
10054
|
+
const render$9 = [renderContent$1, renderBounds$2, renderFocus];
|
|
10055
|
+
const renderFull$3 = (oldState, newState) => {
|
|
10637
10056
|
const commands = [];
|
|
10638
|
-
for (const item of render$
|
|
10057
|
+
for (const item of render$9) {
|
|
10639
10058
|
if (!item.isEqual(oldState, newState)) {
|
|
10640
10059
|
commands.push(item.apply(oldState, newState));
|
|
10641
10060
|
}
|
|
@@ -10643,8 +10062,8 @@ const renderFull$4 = (oldState, newState) => {
|
|
|
10643
10062
|
return commands;
|
|
10644
10063
|
};
|
|
10645
10064
|
|
|
10646
|
-
const render$
|
|
10647
|
-
const commands = renderFull$
|
|
10065
|
+
const render$8 = widget => {
|
|
10066
|
+
const commands = renderFull$3(widget.oldState, widget.newState);
|
|
10648
10067
|
const wrappedCommands = [];
|
|
10649
10068
|
const {
|
|
10650
10069
|
uid
|
|
@@ -10659,27 +10078,27 @@ const render$a = widget => {
|
|
|
10659
10078
|
}
|
|
10660
10079
|
return wrappedCommands;
|
|
10661
10080
|
};
|
|
10662
|
-
const add$
|
|
10663
|
-
return addWidget(widget, 'EditorCodeGenerator', render$
|
|
10081
|
+
const add$6 = widget => {
|
|
10082
|
+
return addWidget$1(widget, 'EditorCodeGenerator', render$8);
|
|
10664
10083
|
};
|
|
10665
|
-
const remove$
|
|
10084
|
+
const remove$6 = removeWidget;
|
|
10666
10085
|
|
|
10667
10086
|
const EditorCodeGeneratorWidget = {
|
|
10668
10087
|
__proto__: null,
|
|
10669
|
-
add: add$
|
|
10670
|
-
remove: remove$
|
|
10671
|
-
render: render$
|
|
10088
|
+
add: add$6,
|
|
10089
|
+
remove: remove$6,
|
|
10090
|
+
render: render$8
|
|
10672
10091
|
};
|
|
10673
10092
|
|
|
10674
|
-
const renderFull$
|
|
10093
|
+
const renderFull$2 = (oldState, newState) => {
|
|
10675
10094
|
const commands = [...newState.commands];
|
|
10676
10095
|
// @ts-ignore
|
|
10677
10096
|
newState.commands = [];
|
|
10678
10097
|
return commands;
|
|
10679
10098
|
};
|
|
10680
10099
|
|
|
10681
|
-
const render$
|
|
10682
|
-
const commands = renderFull$
|
|
10100
|
+
const render$7 = widget => {
|
|
10101
|
+
const commands = renderFull$2(widget.oldState, widget.newState);
|
|
10683
10102
|
const wrappedCommands = [];
|
|
10684
10103
|
const {
|
|
10685
10104
|
uid
|
|
@@ -10693,18 +10112,18 @@ const render$9 = widget => {
|
|
|
10693
10112
|
}
|
|
10694
10113
|
return wrappedCommands;
|
|
10695
10114
|
};
|
|
10696
|
-
const add$
|
|
10697
|
-
return addWidget(widget, 'ColorPicker', render$
|
|
10115
|
+
const add$5 = widget => {
|
|
10116
|
+
return addWidget$1(widget, 'ColorPicker', render$7);
|
|
10698
10117
|
};
|
|
10699
|
-
const remove$
|
|
10118
|
+
const remove$5 = removeWidget;
|
|
10700
10119
|
const Commands$1 = {};
|
|
10701
10120
|
|
|
10702
10121
|
const EditorColorPickerWidget = {
|
|
10703
10122
|
__proto__: null,
|
|
10704
10123
|
Commands: Commands$1,
|
|
10705
|
-
add: add$
|
|
10706
|
-
remove: remove$
|
|
10707
|
-
render: render$
|
|
10124
|
+
add: add$5,
|
|
10125
|
+
remove: remove$5,
|
|
10126
|
+
render: render$7
|
|
10708
10127
|
};
|
|
10709
10128
|
|
|
10710
10129
|
const getCompletionDetailVirtualDom = content => {
|
|
@@ -10748,7 +10167,7 @@ const renderContent = {
|
|
|
10748
10167
|
return [SetDom2, newState.uid, dom];
|
|
10749
10168
|
}
|
|
10750
10169
|
};
|
|
10751
|
-
const renderBounds$
|
|
10170
|
+
const renderBounds$1 = {
|
|
10752
10171
|
isEqual(oldState, newState) {
|
|
10753
10172
|
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
10754
10173
|
},
|
|
@@ -10762,13 +10181,29 @@ const renderBounds$2 = {
|
|
|
10762
10181
|
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
10763
10182
|
}
|
|
10764
10183
|
};
|
|
10765
|
-
const render$
|
|
10766
|
-
const renderFull$
|
|
10767
|
-
return renderParts(render$
|
|
10184
|
+
const render$6 = [renderContent, renderBounds$1];
|
|
10185
|
+
const renderFull$1 = (oldState, newState) => {
|
|
10186
|
+
return renderParts(render$6, oldState, newState);
|
|
10768
10187
|
};
|
|
10769
10188
|
|
|
10770
|
-
const
|
|
10771
|
-
const
|
|
10189
|
+
const getWidgetState = (editor, id) => {
|
|
10190
|
+
const {
|
|
10191
|
+
widgets
|
|
10192
|
+
} = editor;
|
|
10193
|
+
for (const widget of widgets) {
|
|
10194
|
+
if (widget.id === id) {
|
|
10195
|
+
return widget.newState;
|
|
10196
|
+
}
|
|
10197
|
+
}
|
|
10198
|
+
return undefined;
|
|
10199
|
+
};
|
|
10200
|
+
|
|
10201
|
+
const getCompletionState = editor => {
|
|
10202
|
+
return getWidgetState(editor, Completion);
|
|
10203
|
+
};
|
|
10204
|
+
|
|
10205
|
+
const render$5 = widget => {
|
|
10206
|
+
const commands = renderFull$1(widget.oldState, widget.newState);
|
|
10772
10207
|
const wrappedCommands = [];
|
|
10773
10208
|
const {
|
|
10774
10209
|
uid
|
|
@@ -10782,11 +10217,11 @@ const render$7 = widget => {
|
|
|
10782
10217
|
}
|
|
10783
10218
|
return wrappedCommands;
|
|
10784
10219
|
};
|
|
10785
|
-
const add$
|
|
10786
|
-
return addWidget(widget, 'EditorCompletionDetails', render$
|
|
10220
|
+
const add$4 = widget => {
|
|
10221
|
+
return addWidget$1(widget, 'EditorCompletionDetails', render$5);
|
|
10787
10222
|
};
|
|
10788
|
-
const remove$
|
|
10789
|
-
const handleEditorType
|
|
10223
|
+
const remove$4 = removeWidget;
|
|
10224
|
+
const handleEditorType = (editor, state) => {
|
|
10790
10225
|
const completionState = getCompletionState(editor);
|
|
10791
10226
|
if (!completionState) {
|
|
10792
10227
|
return editor;
|
|
@@ -10800,7 +10235,7 @@ const handleEditorType$1 = (editor, state) => {
|
|
|
10800
10235
|
x: detailX
|
|
10801
10236
|
};
|
|
10802
10237
|
};
|
|
10803
|
-
const handleEditorDeleteLeft
|
|
10238
|
+
const handleEditorDeleteLeft = (editor, state) => {
|
|
10804
10239
|
const completionState = getCompletionState(editor);
|
|
10805
10240
|
if (!completionState) {
|
|
10806
10241
|
return editor;
|
|
@@ -10816,357 +10251,6 @@ const handleEditorDeleteLeft$1 = (editor, state) => {
|
|
|
10816
10251
|
};
|
|
10817
10252
|
|
|
10818
10253
|
const EditorCompletionDetailWidget = {
|
|
10819
|
-
__proto__: null,
|
|
10820
|
-
add: add$5,
|
|
10821
|
-
handleEditorDeleteLeft: handleEditorDeleteLeft$1,
|
|
10822
|
-
handleEditorType: handleEditorType$1,
|
|
10823
|
-
remove: remove$5,
|
|
10824
|
-
render: render$7
|
|
10825
|
-
};
|
|
10826
|
-
|
|
10827
|
-
const None = 'none';
|
|
10828
|
-
const Option = 'option';
|
|
10829
|
-
|
|
10830
|
-
const getFileIconVirtualDom = icon => {
|
|
10831
|
-
return {
|
|
10832
|
-
type: Img,
|
|
10833
|
-
className: FileIcon,
|
|
10834
|
-
src: icon,
|
|
10835
|
-
role: None,
|
|
10836
|
-
childCount: 0
|
|
10837
|
-
};
|
|
10838
|
-
};
|
|
10839
|
-
|
|
10840
|
-
const getIconDom = (fileIcon, symbolName) => {
|
|
10841
|
-
if (fileIcon) {
|
|
10842
|
-
return getFileIconVirtualDom(fileIcon);
|
|
10843
|
-
}
|
|
10844
|
-
return {
|
|
10845
|
-
type: Div,
|
|
10846
|
-
className: `${ColoredMaskIcon} ${symbolName}`,
|
|
10847
|
-
childCount: 0
|
|
10848
|
-
};
|
|
10849
|
-
};
|
|
10850
|
-
|
|
10851
|
-
const label1 = {
|
|
10852
|
-
type: Div,
|
|
10853
|
-
className: Label,
|
|
10854
|
-
childCount: 1
|
|
10855
|
-
};
|
|
10856
|
-
const completionHighlight = {
|
|
10857
|
-
type: Span,
|
|
10858
|
-
className: EditorCompletionItemHighlight,
|
|
10859
|
-
childCount: 1
|
|
10860
|
-
};
|
|
10861
|
-
const getHighlightedLabelDom = (label, highlights) => {
|
|
10862
|
-
if (highlights.length === 0) {
|
|
10863
|
-
return [label1, text(label)];
|
|
10864
|
-
}
|
|
10865
|
-
const dom = [];
|
|
10866
|
-
const labelDom = {
|
|
10867
|
-
type: Div,
|
|
10868
|
-
className: Label,
|
|
10869
|
-
childCount: 0
|
|
10870
|
-
};
|
|
10871
|
-
dom.push(labelDom);
|
|
10872
|
-
let position = 0;
|
|
10873
|
-
for (let i = 0; i < highlights.length; i += 2) {
|
|
10874
|
-
const highlightStart = highlights[i];
|
|
10875
|
-
const highlightEnd = highlights[i + 1];
|
|
10876
|
-
if (position < highlightStart) {
|
|
10877
|
-
const beforeText = label.slice(position, highlightStart);
|
|
10878
|
-
labelDom.childCount++;
|
|
10879
|
-
dom.push(text(beforeText));
|
|
10880
|
-
}
|
|
10881
|
-
const highlightText = label.slice(highlightStart, highlightEnd);
|
|
10882
|
-
labelDom.childCount++;
|
|
10883
|
-
dom.push(completionHighlight, text(highlightText));
|
|
10884
|
-
position = highlightEnd;
|
|
10885
|
-
}
|
|
10886
|
-
if (position < label.length) {
|
|
10887
|
-
const afterText = label.slice(position);
|
|
10888
|
-
labelDom.childCount++;
|
|
10889
|
-
dom.push(text(afterText));
|
|
10890
|
-
}
|
|
10891
|
-
return dom;
|
|
10892
|
-
};
|
|
10893
|
-
|
|
10894
|
-
const getCompletionItemVirtualDom = visibleItem => {
|
|
10895
|
-
const {
|
|
10896
|
-
top,
|
|
10897
|
-
label,
|
|
10898
|
-
symbolName,
|
|
10899
|
-
highlights,
|
|
10900
|
-
focused,
|
|
10901
|
-
deprecated,
|
|
10902
|
-
fileIcon
|
|
10903
|
-
} = visibleItem;
|
|
10904
|
-
let className = EditorCompletionItem;
|
|
10905
|
-
if (focused) {
|
|
10906
|
-
className += ' ' + EditorCompletionItemFocused;
|
|
10907
|
-
}
|
|
10908
|
-
if (deprecated) {
|
|
10909
|
-
className += ' ' + EditorCompletionItemDeprecated;
|
|
10910
|
-
}
|
|
10911
|
-
return [{
|
|
10912
|
-
type: Div,
|
|
10913
|
-
role: Option,
|
|
10914
|
-
className,
|
|
10915
|
-
top,
|
|
10916
|
-
childCount: 2
|
|
10917
|
-
}, getIconDom(fileIcon, symbolName), ...getHighlightedLabelDom(label, highlights)];
|
|
10918
|
-
};
|
|
10919
|
-
|
|
10920
|
-
const getCompletionItemsVirtualDom = visibleItems => {
|
|
10921
|
-
if (visibleItems.length === 0) {
|
|
10922
|
-
return [{
|
|
10923
|
-
type: Div,
|
|
10924
|
-
childCount: 1
|
|
10925
|
-
}, text(noResults())];
|
|
10926
|
-
}
|
|
10927
|
-
const root = {
|
|
10928
|
-
type: Div,
|
|
10929
|
-
childCount: visibleItems.length
|
|
10930
|
-
};
|
|
10931
|
-
const dom = [root, ...visibleItems.flatMap(getCompletionItemVirtualDom)];
|
|
10932
|
-
return dom;
|
|
10933
|
-
};
|
|
10934
|
-
|
|
10935
|
-
const Property = 1;
|
|
10936
|
-
const Value = 2;
|
|
10937
|
-
const Function = 3;
|
|
10938
|
-
const Variable = 4;
|
|
10939
|
-
const Keyword = 5;
|
|
10940
|
-
const Folder = 6;
|
|
10941
|
-
const File = 7;
|
|
10942
|
-
const Field = 8;
|
|
10943
|
-
|
|
10944
|
-
const SymbolProperty = 'SymbolProperty';
|
|
10945
|
-
const SymbolValue = 'SymbolValue';
|
|
10946
|
-
const SymbolFunction = 'SymbolFunction';
|
|
10947
|
-
const SymbolVariable = 'SymbolVariable';
|
|
10948
|
-
const SymbolKeyword = 'SymbolKeyword';
|
|
10949
|
-
const SymbolDefault = 'SymbolDefault';
|
|
10950
|
-
const SymbolField = 'SymbolField';
|
|
10951
|
-
const SymbolNone = '';
|
|
10952
|
-
|
|
10953
|
-
const getSymbolName = kind => {
|
|
10954
|
-
switch (kind) {
|
|
10955
|
-
case Property:
|
|
10956
|
-
return SymbolProperty;
|
|
10957
|
-
case Value:
|
|
10958
|
-
return SymbolValue;
|
|
10959
|
-
case Function:
|
|
10960
|
-
return SymbolFunction;
|
|
10961
|
-
case Variable:
|
|
10962
|
-
return SymbolVariable;
|
|
10963
|
-
case Keyword:
|
|
10964
|
-
return SymbolKeyword;
|
|
10965
|
-
case Field:
|
|
10966
|
-
return SymbolField;
|
|
10967
|
-
case File:
|
|
10968
|
-
return SymbolNone;
|
|
10969
|
-
default:
|
|
10970
|
-
return SymbolDefault;
|
|
10971
|
-
}
|
|
10972
|
-
};
|
|
10973
|
-
|
|
10974
|
-
// TODO
|
|
10975
|
-
const getCompletionFileIcon = kind => {
|
|
10976
|
-
switch (kind) {
|
|
10977
|
-
case File:
|
|
10978
|
-
return EmptyString$1;
|
|
10979
|
-
case Folder:
|
|
10980
|
-
return EmptyString$1;
|
|
10981
|
-
default:
|
|
10982
|
-
return EmptyString$1;
|
|
10983
|
-
}
|
|
10984
|
-
};
|
|
10985
|
-
|
|
10986
|
-
const getHighlights = item => {
|
|
10987
|
-
const {
|
|
10988
|
-
matches
|
|
10989
|
-
} = item;
|
|
10990
|
-
return matches.slice(1);
|
|
10991
|
-
};
|
|
10992
|
-
|
|
10993
|
-
const getLabel = item => {
|
|
10994
|
-
return item.label;
|
|
10995
|
-
};
|
|
10996
|
-
const getVisibleIem = (item, itemHeight, leadingWord, i, focusedIndex) => {
|
|
10997
|
-
return {
|
|
10998
|
-
label: getLabel(item),
|
|
10999
|
-
symbolName: getSymbolName(item.kind),
|
|
11000
|
-
top: i * itemHeight,
|
|
11001
|
-
highlights: getHighlights(item),
|
|
11002
|
-
focused: i === focusedIndex,
|
|
11003
|
-
deprecated: item.flags & Deprecated,
|
|
11004
|
-
fileIcon: getCompletionFileIcon(item.kind)
|
|
11005
|
-
};
|
|
11006
|
-
};
|
|
11007
|
-
|
|
11008
|
-
const getVisibleItems = (filteredItems, itemHeight, leadingWord, minLineY, maxLineY, focusedIndex) => {
|
|
11009
|
-
const visibleItems = [];
|
|
11010
|
-
for (let i = minLineY; i < maxLineY; i++) {
|
|
11011
|
-
const filteredItem = filteredItems[i];
|
|
11012
|
-
visibleItems.push(getVisibleIem(filteredItem, itemHeight, leadingWord, i, focusedIndex));
|
|
11013
|
-
}
|
|
11014
|
-
return visibleItems;
|
|
11015
|
-
};
|
|
11016
|
-
|
|
11017
|
-
const renderItems = {
|
|
11018
|
-
isEqual(oldState, newState) {
|
|
11019
|
-
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex;
|
|
11020
|
-
},
|
|
11021
|
-
apply(oldState, newState) {
|
|
11022
|
-
const visibleItems = getVisibleItems(newState.items, newState.itemHeight, newState.leadingWord, newState.minLineY, newState.maxLineY, newState.focusedIndex);
|
|
11023
|
-
const dom = getCompletionItemsVirtualDom(visibleItems);
|
|
11024
|
-
return ['setDom', dom];
|
|
11025
|
-
}
|
|
11026
|
-
};
|
|
11027
|
-
const renderBounds$1 = {
|
|
11028
|
-
isEqual(oldState, newState) {
|
|
11029
|
-
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.x === newState.x && oldState.y === newState.y;
|
|
11030
|
-
},
|
|
11031
|
-
apply(oldState, newState) {
|
|
11032
|
-
const {
|
|
11033
|
-
x,
|
|
11034
|
-
y,
|
|
11035
|
-
width,
|
|
11036
|
-
height
|
|
11037
|
-
} = newState;
|
|
11038
|
-
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
11039
|
-
}
|
|
11040
|
-
};
|
|
11041
|
-
const renderHeight = {
|
|
11042
|
-
isEqual(oldState, newState) {
|
|
11043
|
-
return oldState.items.length === newState.items.length;
|
|
11044
|
-
},
|
|
11045
|
-
apply(oldState, newState) {
|
|
11046
|
-
const {
|
|
11047
|
-
itemHeight
|
|
11048
|
-
} = newState;
|
|
11049
|
-
const contentHeight = newState.items.length * itemHeight;
|
|
11050
|
-
return [/* method */SetContentHeight, /* contentHeight */contentHeight];
|
|
11051
|
-
}
|
|
11052
|
-
};
|
|
11053
|
-
const renderNegativeMargin = {
|
|
11054
|
-
isEqual(oldState, newState) {
|
|
11055
|
-
return oldState.deltaY === newState.deltaY;
|
|
11056
|
-
},
|
|
11057
|
-
apply(oldState, newState) {
|
|
11058
|
-
return [/* method */SetNegativeMargin, /* negativeMargin */-newState.deltaY];
|
|
11059
|
-
}
|
|
11060
|
-
};
|
|
11061
|
-
const renderScrollBar = {
|
|
11062
|
-
isEqual(oldState, newState) {
|
|
11063
|
-
return oldState.negativeMargin === newState.negativeMargin && oldState.deltaY === newState.deltaY && oldState.height === newState.height && oldState.finalDeltaY === newState.finalDeltaY && oldState.items.length === newState.items.length;
|
|
11064
|
-
},
|
|
11065
|
-
apply(oldState, newState) {
|
|
11066
|
-
const total = newState.items.length;
|
|
11067
|
-
const contentHeight = total * newState.itemHeight;
|
|
11068
|
-
const scrollBarHeight = getScrollBarSize(newState.height, contentHeight, newState.minimumSliderSize);
|
|
11069
|
-
const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, scrollBarHeight);
|
|
11070
|
-
return [/* method */SetScrollBar, /* scrollBarY */scrollBarY, /* scrollBarHeight */scrollBarHeight];
|
|
11071
|
-
}
|
|
11072
|
-
};
|
|
11073
|
-
const render$6 = [renderItems, renderBounds$1, renderHeight, renderNegativeMargin, renderScrollBar];
|
|
11074
|
-
const renderCompletion = (oldState, newState) => {
|
|
11075
|
-
const commands = [];
|
|
11076
|
-
for (const item of render$6) {
|
|
11077
|
-
if (!item.isEqual(oldState, newState)) {
|
|
11078
|
-
commands.push(item.apply(oldState, newState));
|
|
11079
|
-
}
|
|
11080
|
-
}
|
|
11081
|
-
return commands;
|
|
11082
|
-
};
|
|
11083
|
-
|
|
11084
|
-
const render$5 = widget => {
|
|
11085
|
-
const commands = renderCompletion(widget.oldState, widget.newState);
|
|
11086
|
-
const wrappedCommands = [];
|
|
11087
|
-
const {
|
|
11088
|
-
uid
|
|
11089
|
-
} = widget.newState;
|
|
11090
|
-
for (const command of commands) {
|
|
11091
|
-
wrappedCommands.push(['Viewlet.send', uid, ...command]);
|
|
11092
|
-
}
|
|
11093
|
-
return wrappedCommands;
|
|
11094
|
-
};
|
|
11095
|
-
const add$4 = widget => {
|
|
11096
|
-
const commands = render$5(widget);
|
|
11097
|
-
const id = 'EditorCompletion';
|
|
11098
|
-
// TODO how to generate a unique integer id
|
|
11099
|
-
// that doesn't collide with ids created in renderer worker?
|
|
11100
|
-
const {
|
|
11101
|
-
uid
|
|
11102
|
-
} = widget.newState;
|
|
11103
|
-
const allCommands = [];
|
|
11104
|
-
allCommands.push(['Viewlet.create', id, uid]);
|
|
11105
|
-
allCommands.push(...commands);
|
|
11106
|
-
return allCommands;
|
|
11107
|
-
};
|
|
11108
|
-
const remove$4 = removeWidget;
|
|
11109
|
-
const handleEditorType = (editor, state) => {
|
|
11110
|
-
const {
|
|
11111
|
-
unfilteredItems,
|
|
11112
|
-
itemHeight,
|
|
11113
|
-
maxHeight
|
|
11114
|
-
} = state;
|
|
11115
|
-
const {
|
|
11116
|
-
x,
|
|
11117
|
-
y,
|
|
11118
|
-
rowIndex,
|
|
11119
|
-
columnIndex
|
|
11120
|
-
} = getPositionAtCursor$1(editor);
|
|
11121
|
-
const wordAtOffset = getWordBefore(editor, rowIndex, columnIndex);
|
|
11122
|
-
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
11123
|
-
const newMinLineY = 0;
|
|
11124
|
-
const newMaxLineY = Math.min(items.length, 8);
|
|
11125
|
-
const height = getListHeight(items.length, itemHeight, maxHeight);
|
|
11126
|
-
const finalDeltaY = items.length * itemHeight - height;
|
|
11127
|
-
return {
|
|
11128
|
-
...state,
|
|
11129
|
-
items,
|
|
11130
|
-
x,
|
|
11131
|
-
y,
|
|
11132
|
-
minLineY: newMinLineY,
|
|
11133
|
-
maxLineY: newMaxLineY,
|
|
11134
|
-
leadingWord: wordAtOffset,
|
|
11135
|
-
height,
|
|
11136
|
-
finalDeltaY
|
|
11137
|
-
};
|
|
11138
|
-
};
|
|
11139
|
-
const handleEditorDeleteLeft = (editor, state) => {
|
|
11140
|
-
const {
|
|
11141
|
-
unfilteredItems,
|
|
11142
|
-
itemHeight,
|
|
11143
|
-
maxHeight
|
|
11144
|
-
} = state;
|
|
11145
|
-
const {
|
|
11146
|
-
x,
|
|
11147
|
-
y,
|
|
11148
|
-
rowIndex,
|
|
11149
|
-
columnIndex
|
|
11150
|
-
} = getPositionAtCursor$1(editor);
|
|
11151
|
-
const wordAtOffset = getWordBefore(editor, rowIndex, columnIndex);
|
|
11152
|
-
if (!wordAtOffset) {
|
|
11153
|
-
return undefined;
|
|
11154
|
-
}
|
|
11155
|
-
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
11156
|
-
const newMaxLineY = Math.min(items.length, 8);
|
|
11157
|
-
const height = getListHeight(items.length, itemHeight, maxHeight);
|
|
11158
|
-
return {
|
|
11159
|
-
...state,
|
|
11160
|
-
items,
|
|
11161
|
-
x,
|
|
11162
|
-
y,
|
|
11163
|
-
maxLineY: newMaxLineY,
|
|
11164
|
-
leadingWord: wordAtOffset,
|
|
11165
|
-
height
|
|
11166
|
-
};
|
|
11167
|
-
};
|
|
11168
|
-
|
|
11169
|
-
const EditorCompletionWidget = {
|
|
11170
10254
|
__proto__: null,
|
|
11171
10255
|
add: add$4,
|
|
11172
10256
|
handleEditorDeleteLeft,
|
|
@@ -11175,7 +10259,7 @@ const EditorCompletionWidget = {
|
|
|
11175
10259
|
render: render$5
|
|
11176
10260
|
};
|
|
11177
10261
|
|
|
11178
|
-
const renderFull
|
|
10262
|
+
const renderFull = (oldState, newState) => {
|
|
11179
10263
|
const commands = [...newState.commands];
|
|
11180
10264
|
// @ts-ignore
|
|
11181
10265
|
newState.commands = [];
|
|
@@ -11183,7 +10267,7 @@ const renderFull$1 = (oldState, newState) => {
|
|
|
11183
10267
|
};
|
|
11184
10268
|
|
|
11185
10269
|
const render$4 = widget => {
|
|
11186
|
-
const commands = renderFull
|
|
10270
|
+
const commands = renderFull(widget.oldState, widget.newState);
|
|
11187
10271
|
const wrappedCommands = [];
|
|
11188
10272
|
const {
|
|
11189
10273
|
uid
|
|
@@ -11198,7 +10282,7 @@ const render$4 = widget => {
|
|
|
11198
10282
|
return wrappedCommands;
|
|
11199
10283
|
};
|
|
11200
10284
|
const add$3 = widget => {
|
|
11201
|
-
return addWidget(widget, 'FindWidget', render$4);
|
|
10285
|
+
return addWidget$1(widget, 'FindWidget', render$4);
|
|
11202
10286
|
};
|
|
11203
10287
|
const remove$3 = widget => {
|
|
11204
10288
|
return [['Viewlet.dispose', widget.newState.uid]];
|
|
@@ -11229,7 +10313,7 @@ const render$3 = widget => {
|
|
|
11229
10313
|
return wrappedCommands;
|
|
11230
10314
|
};
|
|
11231
10315
|
const add$2 = widget => {
|
|
11232
|
-
return addWidget(widget, 'EditorHover', render$3);
|
|
10316
|
+
return addWidget$1(widget, 'EditorHover', render$3);
|
|
11233
10317
|
};
|
|
11234
10318
|
const remove$2 = removeWidget;
|
|
11235
10319
|
|
|
@@ -11240,15 +10324,8 @@ const EditorHoverWidget = {
|
|
|
11240
10324
|
render: render$3
|
|
11241
10325
|
};
|
|
11242
10326
|
|
|
11243
|
-
const renderFull = (oldState, newState) => {
|
|
11244
|
-
const commands = [...newState.commands];
|
|
11245
|
-
// @ts-ignore
|
|
11246
|
-
newState.commands = [];
|
|
11247
|
-
return commands;
|
|
11248
|
-
};
|
|
11249
|
-
|
|
11250
10327
|
const render$2 = widget => {
|
|
11251
|
-
const commands = renderFull(widget.oldState, widget.newState);
|
|
10328
|
+
const commands = renderFull$4(widget.oldState, widget.newState);
|
|
11252
10329
|
const wrappedCommands = [];
|
|
11253
10330
|
const {
|
|
11254
10331
|
uid
|
|
@@ -11263,7 +10340,7 @@ const render$2 = widget => {
|
|
|
11263
10340
|
return wrappedCommands;
|
|
11264
10341
|
};
|
|
11265
10342
|
const add$1 = widget => {
|
|
11266
|
-
return addWidget(widget, 'EditorRename', render$2);
|
|
10343
|
+
return addWidget$1(widget, 'EditorRename', render$2);
|
|
11267
10344
|
};
|
|
11268
10345
|
const remove$1 = removeWidget;
|
|
11269
10346
|
|
|
@@ -11399,7 +10476,7 @@ const render = widget => {
|
|
|
11399
10476
|
return wrappedCommands;
|
|
11400
10477
|
};
|
|
11401
10478
|
const add = widget => {
|
|
11402
|
-
return addWidget(widget, 'EditorSourceActions', render);
|
|
10479
|
+
return addWidget$1(widget, 'EditorSourceActions', render);
|
|
11403
10480
|
};
|
|
11404
10481
|
const remove = removeWidget;
|
|
11405
10482
|
|