@lvce-editor/editor-worker 18.3.0 → 18.5.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 +697 -103
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -553,7 +553,7 @@ const execute$1 = (command, ...args) => {
|
|
|
553
553
|
|
|
554
554
|
const Two$1 = '2.0';
|
|
555
555
|
const callbacks = Object.create(null);
|
|
556
|
-
const get$
|
|
556
|
+
const get$9 = id => {
|
|
557
557
|
return callbacks[id];
|
|
558
558
|
};
|
|
559
559
|
const remove$9 = id => {
|
|
@@ -702,7 +702,7 @@ const warn$1 = (...args) => {
|
|
|
702
702
|
console.warn(...args);
|
|
703
703
|
};
|
|
704
704
|
const resolve = (id, response) => {
|
|
705
|
-
const fn = get$
|
|
705
|
+
const fn = get$9(id);
|
|
706
706
|
if (!fn) {
|
|
707
707
|
console.log(response);
|
|
708
708
|
warn$1(`callback ${id} may already be disposed`);
|
|
@@ -886,9 +886,9 @@ const create$h = (id, method, params) => {
|
|
|
886
886
|
return message;
|
|
887
887
|
};
|
|
888
888
|
|
|
889
|
-
let id
|
|
889
|
+
let id = 0;
|
|
890
890
|
const create$g = () => {
|
|
891
|
-
return ++id
|
|
891
|
+
return ++id;
|
|
892
892
|
};
|
|
893
893
|
|
|
894
894
|
const registerPromise = map => {
|
|
@@ -1084,6 +1084,16 @@ const create$b = async ({
|
|
|
1084
1084
|
return rpc;
|
|
1085
1085
|
};
|
|
1086
1086
|
|
|
1087
|
+
const Text$1 = 12;
|
|
1088
|
+
const Reference = 100;
|
|
1089
|
+
|
|
1090
|
+
const AltKey = 'event.altKey';
|
|
1091
|
+
const Button = 'event.button';
|
|
1092
|
+
const ClientX = 'event.clientX';
|
|
1093
|
+
const ClientY = 'event.clientY';
|
|
1094
|
+
const DeltaMode = 'event.deltaMode';
|
|
1095
|
+
const DeltaY = 'event.deltaY';
|
|
1096
|
+
|
|
1087
1097
|
const Backspace = 1;
|
|
1088
1098
|
const Tab$1 = 2;
|
|
1089
1099
|
const Enter = 3;
|
|
@@ -1147,11 +1157,14 @@ const IconThemeWorker = 7009;
|
|
|
1147
1157
|
const MarkdownWorker = 300;
|
|
1148
1158
|
const OpenerWorker = 4561;
|
|
1149
1159
|
const RendererWorker$1 = 1;
|
|
1150
|
-
const TextMeasurementWorker = 7011;
|
|
1151
1160
|
|
|
1161
|
+
const FocusSelector = 'Viewlet.focusSelector';
|
|
1162
|
+
const SetCss$1 = 'Viewlet.setCss';
|
|
1152
1163
|
const SetFocusContext$1 = 'Viewlet.setFocusContext';
|
|
1164
|
+
const SetPatches = 'Viewlet.setPatches';
|
|
1153
1165
|
|
|
1154
1166
|
const FocusEditorText$1 = 12;
|
|
1167
|
+
const FocusExplorer = 13;
|
|
1155
1168
|
|
|
1156
1169
|
const createMockRpc = ({
|
|
1157
1170
|
commandMap
|
|
@@ -1177,7 +1190,7 @@ const rpcs = Object.create(null);
|
|
|
1177
1190
|
const set$f = (id, rpc) => {
|
|
1178
1191
|
rpcs[id] = rpc;
|
|
1179
1192
|
};
|
|
1180
|
-
const get$
|
|
1193
|
+
const get$8 = id => {
|
|
1181
1194
|
return rpcs[id];
|
|
1182
1195
|
};
|
|
1183
1196
|
const remove$8 = id => {
|
|
@@ -1188,18 +1201,18 @@ const remove$8 = id => {
|
|
|
1188
1201
|
const create$a = rpcId => {
|
|
1189
1202
|
return {
|
|
1190
1203
|
async dispose() {
|
|
1191
|
-
const rpc = get$
|
|
1204
|
+
const rpc = get$8(rpcId);
|
|
1192
1205
|
await rpc.dispose();
|
|
1193
1206
|
},
|
|
1194
1207
|
// @ts-ignore
|
|
1195
1208
|
invoke(method, ...params) {
|
|
1196
|
-
const rpc = get$
|
|
1209
|
+
const rpc = get$8(rpcId);
|
|
1197
1210
|
// @ts-ignore
|
|
1198
1211
|
return rpc.invoke(method, ...params);
|
|
1199
1212
|
},
|
|
1200
1213
|
// @ts-ignore
|
|
1201
1214
|
invokeAndTransfer(method, ...params) {
|
|
1202
|
-
const rpc = get$
|
|
1215
|
+
const rpc = get$8(rpcId);
|
|
1203
1216
|
// @ts-ignore
|
|
1204
1217
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1205
1218
|
},
|
|
@@ -1262,6 +1275,9 @@ const {
|
|
|
1262
1275
|
invoke: invoke$e,
|
|
1263
1276
|
set: set$d
|
|
1264
1277
|
} = create$a(ExtensionManagementWorker);
|
|
1278
|
+
const getLanguages$1 = (platform, assetDir) => {
|
|
1279
|
+
return invoke$e('Extensions.getLanguages', platform, assetDir);
|
|
1280
|
+
};
|
|
1265
1281
|
|
|
1266
1282
|
const {
|
|
1267
1283
|
dispose: dispose$2,
|
|
@@ -1555,7 +1571,7 @@ const setExtensionsSearchValue = async searchValue => {
|
|
|
1555
1571
|
const openExternal$1 = async uri => {
|
|
1556
1572
|
await invoke$d('Open.openExternal', uri);
|
|
1557
1573
|
};
|
|
1558
|
-
const openUrl = async uri => {
|
|
1574
|
+
const openUrl$1 = async uri => {
|
|
1559
1575
|
await invoke$d('Open.openUrl', uri);
|
|
1560
1576
|
};
|
|
1561
1577
|
const getAllPreferences = async () => {
|
|
@@ -1625,7 +1641,7 @@ const RendererWorker = {
|
|
|
1625
1641
|
openExternal: openExternal$1,
|
|
1626
1642
|
openNativeFolder,
|
|
1627
1643
|
openUri,
|
|
1628
|
-
openUrl,
|
|
1644
|
+
openUrl: openUrl$1,
|
|
1629
1645
|
openWidget,
|
|
1630
1646
|
readClipBoardText,
|
|
1631
1647
|
readFile,
|
|
@@ -1679,14 +1695,18 @@ const {
|
|
|
1679
1695
|
invoke: invoke$c,
|
|
1680
1696
|
set: set$b
|
|
1681
1697
|
} = create$a(OpenerWorker);
|
|
1698
|
+
const openUrl = async (url, platform) => {
|
|
1699
|
+
return invoke$c('Open.openUrl', url, platform);
|
|
1700
|
+
};
|
|
1682
1701
|
|
|
1683
1702
|
const {
|
|
1703
|
+
invoke: invoke$b,
|
|
1684
1704
|
set: set$a
|
|
1685
1705
|
} = create$a(IconThemeWorker);
|
|
1686
1706
|
|
|
1687
1707
|
const {
|
|
1688
1708
|
dispose: dispose$1,
|
|
1689
|
-
invoke: invoke$
|
|
1709
|
+
invoke: invoke$a,
|
|
1690
1710
|
invokeAndTransfer,
|
|
1691
1711
|
set: set$9
|
|
1692
1712
|
} = create$a(MarkdownWorker);
|
|
@@ -1694,7 +1714,7 @@ const {
|
|
|
1694
1714
|
const SyntaxHighlightingWorker = {
|
|
1695
1715
|
__proto__: null,
|
|
1696
1716
|
dispose: dispose$1,
|
|
1697
|
-
invoke: invoke$
|
|
1717
|
+
invoke: invoke$a,
|
|
1698
1718
|
invokeAndTransfer,
|
|
1699
1719
|
set: set$9
|
|
1700
1720
|
};
|
|
@@ -1715,12 +1735,12 @@ const createLazyRpc = rpcId => {
|
|
|
1715
1735
|
return {
|
|
1716
1736
|
async invoke(method, ...params) {
|
|
1717
1737
|
await ensureRpc();
|
|
1718
|
-
const rpc = get$
|
|
1738
|
+
const rpc = get$8(rpcId);
|
|
1719
1739
|
return rpc.invoke(method, ...params);
|
|
1720
1740
|
},
|
|
1721
1741
|
async invokeAndTransfer(method, ...params) {
|
|
1722
1742
|
await ensureRpc();
|
|
1723
|
-
const rpc = get$
|
|
1743
|
+
const rpc = get$8(rpcId);
|
|
1724
1744
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1725
1745
|
},
|
|
1726
1746
|
setFactory(value) {
|
|
@@ -1823,7 +1843,7 @@ const activateByEvent = async (event, assetDir, platform) => {
|
|
|
1823
1843
|
string(event);
|
|
1824
1844
|
// Assert.string(assetDir)
|
|
1825
1845
|
// Assert.number(platform)
|
|
1826
|
-
await
|
|
1846
|
+
await activateByEvent$1(event, assetDir, platform);
|
|
1827
1847
|
};
|
|
1828
1848
|
|
|
1829
1849
|
const codeGeneratorAccept = state => {
|
|
@@ -1866,7 +1886,7 @@ const getOrCreate$3 = () => {
|
|
|
1866
1886
|
}
|
|
1867
1887
|
return workerPromise$3;
|
|
1868
1888
|
};
|
|
1869
|
-
const invoke$
|
|
1889
|
+
const invoke$9 = async (method, ...params) => {
|
|
1870
1890
|
const worker = await getOrCreate$3();
|
|
1871
1891
|
return await worker.invoke(method, ...params);
|
|
1872
1892
|
};
|
|
@@ -1879,10 +1899,10 @@ const loadContent$3 = async (state, parentUid) => {
|
|
|
1879
1899
|
x,
|
|
1880
1900
|
y
|
|
1881
1901
|
} = state;
|
|
1882
|
-
await invoke$
|
|
1883
|
-
await invoke$
|
|
1884
|
-
const diff = await invoke$
|
|
1885
|
-
const commands = await invoke$
|
|
1902
|
+
await invoke$9('ColorPicker.create', uid, x, y, width, height, parentUid);
|
|
1903
|
+
await invoke$9('ColorPicker.loadContent', uid);
|
|
1904
|
+
const diff = await invoke$9('ColorPicker.diff2', uid);
|
|
1905
|
+
const commands = await invoke$9('ColorPicker.render2', uid, diff);
|
|
1886
1906
|
return {
|
|
1887
1907
|
...state,
|
|
1888
1908
|
commands
|
|
@@ -1890,8 +1910,11 @@ const loadContent$3 = async (state, parentUid) => {
|
|
|
1890
1910
|
};
|
|
1891
1911
|
|
|
1892
1912
|
const {
|
|
1913
|
+
get: get$7,
|
|
1893
1914
|
getCommandIds,
|
|
1915
|
+
registerCommands,
|
|
1894
1916
|
set: set$8,
|
|
1917
|
+
wrapCommand: wrapCommand$1,
|
|
1895
1918
|
wrapGetter
|
|
1896
1919
|
} = create$9();
|
|
1897
1920
|
|
|
@@ -1938,6 +1961,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1938
1961
|
highlightedLine: -1,
|
|
1939
1962
|
id,
|
|
1940
1963
|
incrementalEdits: emptyIncrementalEdits,
|
|
1964
|
+
initial: true,
|
|
1941
1965
|
invalidStartIndex: 0,
|
|
1942
1966
|
isAutoClosingBracketsEnabled: false,
|
|
1943
1967
|
isAutoClosingQuotesEnabled: false,
|
|
@@ -2045,7 +2069,7 @@ const get$5 = id => {
|
|
|
2045
2069
|
number(id);
|
|
2046
2070
|
return editors[id];
|
|
2047
2071
|
};
|
|
2048
|
-
const getKeys$
|
|
2072
|
+
const getKeys$2 = () => {
|
|
2049
2073
|
return Object.keys(editors);
|
|
2050
2074
|
};
|
|
2051
2075
|
const set$6 = (id, oldEditor, newEditor) => {
|
|
@@ -2254,7 +2278,7 @@ const getEnabled$1 = () => {
|
|
|
2254
2278
|
};
|
|
2255
2279
|
|
|
2256
2280
|
const {
|
|
2257
|
-
invoke: invoke$
|
|
2281
|
+
invoke: invoke$8,
|
|
2258
2282
|
set: set$5
|
|
2259
2283
|
} = SyntaxHighlightingWorker;
|
|
2260
2284
|
|
|
@@ -2290,7 +2314,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
2290
2314
|
}
|
|
2291
2315
|
if (getEnabled$1()) {
|
|
2292
2316
|
// @ts-ignore
|
|
2293
|
-
const tokenMap = await invoke$
|
|
2317
|
+
const tokenMap = await invoke$8('Tokenizer.load', languageId, tokenizePath);
|
|
2294
2318
|
set$3(languageId, tokenMap);
|
|
2295
2319
|
return;
|
|
2296
2320
|
}
|
|
@@ -2466,13 +2490,13 @@ const getTokensViewport2 = async (editor, startLineIndex, endLineIndex, syncIncr
|
|
|
2466
2490
|
invalidStartIndex,
|
|
2467
2491
|
languageId
|
|
2468
2492
|
};
|
|
2469
|
-
return invoke$
|
|
2493
|
+
return invoke$8('GetTokensViewport.getTokensViewport', slimEditor,
|
|
2470
2494
|
// @ts-ignore
|
|
2471
2495
|
startLineIndex, endLineIndex, hasLinesToSend, id, linesToSend);
|
|
2472
2496
|
}
|
|
2473
2497
|
// TODO only send needed lines of text
|
|
2474
2498
|
// @ts-ignore
|
|
2475
|
-
return invoke$
|
|
2499
|
+
return invoke$8('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex, true, editor.id, editor.lines);
|
|
2476
2500
|
}
|
|
2477
2501
|
return getTokensViewport(editor, startLineIndex, endLineIndex);
|
|
2478
2502
|
};
|
|
@@ -3176,7 +3200,7 @@ const getIncrementalEdits = async (oldState, newState) => {
|
|
|
3176
3200
|
const oldLine = oldState.lines[rowIndex];
|
|
3177
3201
|
const newLine = lines[rowIndex];
|
|
3178
3202
|
// @ts-ignore
|
|
3179
|
-
const incrementalEdits = await invoke$
|
|
3203
|
+
const incrementalEdits = await invoke$8(
|
|
3180
3204
|
// @ts-ignore
|
|
3181
3205
|
'TokenizeIncremental.tokenizeIncremental', newState.uid,
|
|
3182
3206
|
// @ts-ignore
|
|
@@ -3354,7 +3378,7 @@ const notifyListeners = async (listenerType, method, ...params) => {
|
|
|
3354
3378
|
// Notify all listeners in parallel
|
|
3355
3379
|
const notifications = rpcIds.map(async rpcId => {
|
|
3356
3380
|
try {
|
|
3357
|
-
const rpc = get$
|
|
3381
|
+
const rpc = get$8(rpcId);
|
|
3358
3382
|
if (rpc) {
|
|
3359
3383
|
await rpc.invoke(method, ...params);
|
|
3360
3384
|
}
|
|
@@ -3375,11 +3399,11 @@ const splitLines = lines => {
|
|
|
3375
3399
|
};
|
|
3376
3400
|
|
|
3377
3401
|
const {
|
|
3378
|
-
invoke: invoke$
|
|
3402
|
+
invoke: invoke$7} = RendererWorker;
|
|
3379
3403
|
|
|
3380
3404
|
const notifyTabModifiedStatusChange = async uri => {
|
|
3381
3405
|
try {
|
|
3382
|
-
await invoke$
|
|
3406
|
+
await invoke$7('Main.handleModifiedStatusChange', uri, true);
|
|
3383
3407
|
} catch {
|
|
3384
3408
|
// ignore
|
|
3385
3409
|
}
|
|
@@ -3415,13 +3439,8 @@ const measureTextWidthFast = async (text, charWidth) => {
|
|
|
3415
3439
|
return text.length * charWidth;
|
|
3416
3440
|
};
|
|
3417
3441
|
|
|
3418
|
-
const {
|
|
3419
|
-
invoke: invoke$7,
|
|
3420
|
-
setFactory: setFactory$1
|
|
3421
|
-
} = createLazyRpc(TextMeasurementWorker);
|
|
3422
|
-
|
|
3423
3442
|
const measureTextWidthSlow = async (text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
|
|
3424
|
-
const width = await invoke$
|
|
3443
|
+
const width = await invoke$b('TextMeasurement.measureTextWidth', text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
|
|
3425
3444
|
return width;
|
|
3426
3445
|
};
|
|
3427
3446
|
|
|
@@ -4072,7 +4091,7 @@ const getLanguageId$1 = (uri, languages) => {
|
|
|
4072
4091
|
const getLanguages = async (platform, assetDir) => {
|
|
4073
4092
|
number(platform);
|
|
4074
4093
|
string(assetDir);
|
|
4075
|
-
const languages = await
|
|
4094
|
+
const languages = await getLanguages$1(platform, assetDir);
|
|
4076
4095
|
return languages;
|
|
4077
4096
|
};
|
|
4078
4097
|
|
|
@@ -4081,7 +4100,7 @@ const measureCharacterWidth = async (fontWeight, fontSize, fontFamily, letterSpa
|
|
|
4081
4100
|
};
|
|
4082
4101
|
|
|
4083
4102
|
const get$1 = async key => {
|
|
4084
|
-
const value = await
|
|
4103
|
+
const value = await getPreference(key);
|
|
4085
4104
|
return value;
|
|
4086
4105
|
};
|
|
4087
4106
|
|
|
@@ -4391,6 +4410,46 @@ const createEditor = async ({
|
|
|
4391
4410
|
});
|
|
4392
4411
|
};
|
|
4393
4412
|
|
|
4413
|
+
const isEqual$2 = (oldState, newState) => {
|
|
4414
|
+
return oldState.itemHeight === newState.itemHeight;
|
|
4415
|
+
};
|
|
4416
|
+
|
|
4417
|
+
const isEqual$1 = (oldState, newState) => {
|
|
4418
|
+
return oldState.focused === newState.focused && oldState.focus === newState.focus;
|
|
4419
|
+
};
|
|
4420
|
+
|
|
4421
|
+
const isEqual = (oldState, newState) => {
|
|
4422
|
+
return oldState.lines === newState.lines && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial;
|
|
4423
|
+
};
|
|
4424
|
+
|
|
4425
|
+
const RenderFocus = 6;
|
|
4426
|
+
const RenderFocusContext = 7;
|
|
4427
|
+
const RenderCss = 11;
|
|
4428
|
+
const RenderIncremental = 12;
|
|
4429
|
+
|
|
4430
|
+
const modules = [isEqual, isEqual$1, isEqual$1, isEqual$2];
|
|
4431
|
+
const numbers = [RenderIncremental, RenderFocus, RenderFocusContext, RenderCss];
|
|
4432
|
+
|
|
4433
|
+
const diff = (oldState, newState) => {
|
|
4434
|
+
const diffResult = [];
|
|
4435
|
+
for (let i = 0; i < modules.length; i++) {
|
|
4436
|
+
const fn = modules[i];
|
|
4437
|
+
if (!fn(oldState, newState)) {
|
|
4438
|
+
diffResult.push(numbers[i]);
|
|
4439
|
+
}
|
|
4440
|
+
}
|
|
4441
|
+
return diffResult;
|
|
4442
|
+
};
|
|
4443
|
+
|
|
4444
|
+
const diff2 = uid => {
|
|
4445
|
+
const {
|
|
4446
|
+
newState,
|
|
4447
|
+
oldState
|
|
4448
|
+
} = get$7(uid);
|
|
4449
|
+
const result = diff(oldState, newState);
|
|
4450
|
+
return result;
|
|
4451
|
+
};
|
|
4452
|
+
|
|
4394
4453
|
// @ts-ignore
|
|
4395
4454
|
const getNewSelections$c = selections => {
|
|
4396
4455
|
const newSelections = [];
|
|
@@ -5095,7 +5154,7 @@ const compositionEnd = (editor, data) => {
|
|
|
5095
5154
|
const writeText = async text => {
|
|
5096
5155
|
try {
|
|
5097
5156
|
string(text);
|
|
5098
|
-
await
|
|
5157
|
+
await writeClipBoardText(text);
|
|
5099
5158
|
} catch (error) {
|
|
5100
5159
|
throw new VError(error, 'Failed to write text to clipboard');
|
|
5101
5160
|
}
|
|
@@ -6055,7 +6114,7 @@ const goTo = async ({
|
|
|
6055
6114
|
startColumnIndex: definition.startColumnIndex,
|
|
6056
6115
|
startRowIndex: definition.startRowIndex
|
|
6057
6116
|
};
|
|
6058
|
-
await
|
|
6117
|
+
await openUri(uri, true, context);
|
|
6059
6118
|
return editor;
|
|
6060
6119
|
} catch (error) {
|
|
6061
6120
|
// TODO if editor is already disposed at this point, do nothing
|
|
@@ -6205,8 +6264,7 @@ const setPosition$1 = position => {
|
|
|
6205
6264
|
};
|
|
6206
6265
|
|
|
6207
6266
|
const openExternal = async (url, platform) => {
|
|
6208
|
-
|
|
6209
|
-
await invoke$c('Open.openUrl', url, platform);
|
|
6267
|
+
await openUrl(url, platform);
|
|
6210
6268
|
};
|
|
6211
6269
|
|
|
6212
6270
|
// TODO first change cursor position, then run go to definition
|
|
@@ -7325,18 +7383,18 @@ const launchFindWidgetWorker = async () => {
|
|
|
7325
7383
|
const rpcId = 9002;
|
|
7326
7384
|
const launch = async () => {
|
|
7327
7385
|
// TODO race condition
|
|
7328
|
-
if (get$
|
|
7386
|
+
if (get$8(rpcId)) {
|
|
7329
7387
|
return;
|
|
7330
7388
|
}
|
|
7331
7389
|
const rpc = await launchFindWidgetWorker();
|
|
7332
7390
|
set$f(rpcId, rpc);
|
|
7333
7391
|
};
|
|
7334
7392
|
const invoke$3 = async (method, ...params) => {
|
|
7335
|
-
const rpc = get$
|
|
7393
|
+
const rpc = get$8(rpcId);
|
|
7336
7394
|
return await rpc.invoke(method, ...params);
|
|
7337
7395
|
};
|
|
7338
7396
|
const dispose = async () => {
|
|
7339
|
-
const rpc = get$
|
|
7397
|
+
const rpc = get$8(rpcId);
|
|
7340
7398
|
remove$8(rpcId);
|
|
7341
7399
|
if (rpc) {
|
|
7342
7400
|
await rpc.dispose();
|
|
@@ -7495,8 +7553,7 @@ const pasteText = (editor, text) => {
|
|
|
7495
7553
|
};
|
|
7496
7554
|
|
|
7497
7555
|
const paste = async editor => {
|
|
7498
|
-
|
|
7499
|
-
const text = await invoke$d('ClipBoard.readText');
|
|
7556
|
+
const text = await readClipBoardText();
|
|
7500
7557
|
string(text);
|
|
7501
7558
|
return pasteText(editor, text);
|
|
7502
7559
|
};
|
|
@@ -7656,7 +7713,7 @@ const saveUntitledFile = async (uri, content, platform) => {
|
|
|
7656
7713
|
return;
|
|
7657
7714
|
}
|
|
7658
7715
|
await invoke$d('FileSystem.writeFile', filePath, content);
|
|
7659
|
-
await
|
|
7716
|
+
await handleWorkspaceRefresh();
|
|
7660
7717
|
await invoke$d('Main.handleUriChange', uri, filePath);
|
|
7661
7718
|
return filePath;
|
|
7662
7719
|
};
|
|
@@ -9372,7 +9429,7 @@ const addWidget$1 = (widget, id, render) => {
|
|
|
9372
9429
|
const getWidgetInvoke = widgetId => {
|
|
9373
9430
|
switch (widgetId) {
|
|
9374
9431
|
case ColorPicker$1:
|
|
9375
|
-
return invoke$
|
|
9432
|
+
return invoke$9;
|
|
9376
9433
|
case Completion:
|
|
9377
9434
|
return invoke$4;
|
|
9378
9435
|
case Find:
|
|
@@ -10278,7 +10335,7 @@ const getDiagnostics$1 = async editorUid => {
|
|
|
10278
10335
|
};
|
|
10279
10336
|
|
|
10280
10337
|
const ensure = async (fontName, fontUrl) => {
|
|
10281
|
-
await invoke$
|
|
10338
|
+
await invoke$b('TextMeasurement.ensureFont', fontName, fontUrl);
|
|
10282
10339
|
};
|
|
10283
10340
|
|
|
10284
10341
|
const getKeyBindings = () => {
|
|
@@ -10637,8 +10694,8 @@ const getKeyBindings = () => {
|
|
|
10637
10694
|
}];
|
|
10638
10695
|
};
|
|
10639
10696
|
|
|
10640
|
-
const getKeys = () => {
|
|
10641
|
-
return getKeys$
|
|
10697
|
+
const getKeys$1 = () => {
|
|
10698
|
+
return getKeys$2();
|
|
10642
10699
|
};
|
|
10643
10700
|
|
|
10644
10701
|
/**
|
|
@@ -10723,7 +10780,7 @@ const getDiagnostics = editor => {
|
|
|
10723
10780
|
const getProblems = async () => {
|
|
10724
10781
|
// TODO maybe combine querying diagnostics for problems view with diagnostics for editor
|
|
10725
10782
|
// or query the diagnostics for the problems view directtly from the extension host worker
|
|
10726
|
-
const keys = getKeys$
|
|
10783
|
+
const keys = getKeys$2();
|
|
10727
10784
|
const editors = keys.map(key => {
|
|
10728
10785
|
const numericKey = parseInt(key);
|
|
10729
10786
|
const editor = get$5(numericKey);
|
|
@@ -10935,7 +10992,7 @@ const hotReload = async () => {
|
|
|
10935
10992
|
isReloading = true;
|
|
10936
10993
|
|
|
10937
10994
|
// TODO use getEditors
|
|
10938
|
-
const keys = getKeys$
|
|
10995
|
+
const keys = getKeys$2();
|
|
10939
10996
|
const savedStates = await saveWidgetState(keys);
|
|
10940
10997
|
await relaunchWorkers();
|
|
10941
10998
|
const newEditors = await restoreWidgetState(keys, savedStates);
|
|
@@ -10950,7 +11007,7 @@ const hotReload = async () => {
|
|
|
10950
11007
|
};
|
|
10951
11008
|
|
|
10952
11009
|
const sendMessagePortToExtensionHostWorker2 = async (port, initialCommand, rpcId) => {
|
|
10953
|
-
await
|
|
11010
|
+
await sendMessagePortToExtensionHostWorker(port, rpcId);
|
|
10954
11011
|
};
|
|
10955
11012
|
|
|
10956
11013
|
const createExtensionHostRpc = async () => {
|
|
@@ -10996,7 +11053,7 @@ const initializeExtensionManagementWorker = async () => {
|
|
|
10996
11053
|
}
|
|
10997
11054
|
};
|
|
10998
11055
|
|
|
10999
|
-
const send$
|
|
11056
|
+
const send$1 = port => {
|
|
11000
11057
|
// @ts-ignore
|
|
11001
11058
|
return sendMessagePortToOpenerWorker(port);
|
|
11002
11059
|
};
|
|
@@ -11004,7 +11061,7 @@ const initializeOpenerWorker = async () => {
|
|
|
11004
11061
|
try {
|
|
11005
11062
|
const rpc = await create$f({
|
|
11006
11063
|
commandMap: {},
|
|
11007
|
-
send: send$
|
|
11064
|
+
send: send$1
|
|
11008
11065
|
});
|
|
11009
11066
|
set$b(rpc);
|
|
11010
11067
|
} catch {
|
|
@@ -11014,10 +11071,9 @@ const initializeOpenerWorker = async () => {
|
|
|
11014
11071
|
|
|
11015
11072
|
const sendMessagePortToSyntaxHighlightingWorker = async port => {
|
|
11016
11073
|
try {
|
|
11017
|
-
await
|
|
11018
|
-
// @ts-ignore
|
|
11019
|
-
'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
|
|
11074
|
+
await sendMessagePortToSyntaxHighlightingWorker$1(port);
|
|
11020
11075
|
} catch {
|
|
11076
|
+
// deprecated
|
|
11021
11077
|
await invokeAndTransfer$1(
|
|
11022
11078
|
// @ts-ignore
|
|
11023
11079
|
'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
|
|
@@ -11047,19 +11103,15 @@ const initializeSyntaxHighlighting = async (syntaxHighlightingEnabled, syncIncre
|
|
|
11047
11103
|
}
|
|
11048
11104
|
};
|
|
11049
11105
|
|
|
11050
|
-
const send
|
|
11106
|
+
const send = port => {
|
|
11051
11107
|
return sendMessagePortToTextMeasurementWorker(port);
|
|
11052
11108
|
};
|
|
11053
11109
|
const initializeTextMeasurementWorker = async () => {
|
|
11054
|
-
|
|
11055
|
-
|
|
11056
|
-
|
|
11057
|
-
|
|
11058
|
-
|
|
11059
|
-
set$a(rpc);
|
|
11060
|
-
} catch {
|
|
11061
|
-
// ignore
|
|
11062
|
-
}
|
|
11110
|
+
const rpc = await create$f({
|
|
11111
|
+
commandMap: {},
|
|
11112
|
+
send
|
|
11113
|
+
});
|
|
11114
|
+
set$a(rpc);
|
|
11063
11115
|
};
|
|
11064
11116
|
|
|
11065
11117
|
const launchCompletionWorker = async () => {
|
|
@@ -11075,29 +11127,138 @@ const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
|
|
|
11075
11127
|
await Promise.all([initializeSyntaxHighlighting(syntaxHighlightingEnabled, syncIncremental), initializeExtensionHost(), initializeExtensionManagementWorker(), initializeTextMeasurementWorker(), initializeOpenerWorker()]);
|
|
11076
11128
|
};
|
|
11077
11129
|
|
|
11078
|
-
const
|
|
11079
|
-
|
|
11080
|
-
|
|
11081
|
-
|
|
11130
|
+
const kLineHeight = 'editor.lineHeight';
|
|
11131
|
+
const kFontSize = 'editor.fontSize';
|
|
11132
|
+
const kFontFamily = 'editor.fontFamily';
|
|
11133
|
+
const kTabSize = 'editor.tabSize';
|
|
11134
|
+
const kLineNumbers = 'editor.lineNumbers';
|
|
11135
|
+
const kDiagnostics = 'editor.diagnostics';
|
|
11136
|
+
const kQuickSuggestions = 'editor.quickSuggestions';
|
|
11137
|
+
const kAutoClosingQuotes = 'editor.autoClosingQuotes';
|
|
11138
|
+
const kAutoClosingBrackets = 'editor.autoclosingBrackets';
|
|
11139
|
+
const kFontWeight = 'editor.fontWeight';
|
|
11140
|
+
const isAutoClosingBracketsEnabled = async () => {
|
|
11141
|
+
return Boolean(await get$1(kAutoClosingBrackets));
|
|
11142
|
+
};
|
|
11143
|
+
const isAutoClosingQuotesEnabled = async () => {
|
|
11144
|
+
return Boolean(await get$1(kAutoClosingQuotes));
|
|
11145
|
+
};
|
|
11146
|
+
const isQuickSuggestionsEnabled = async () => {
|
|
11147
|
+
return Boolean(await get$1(kQuickSuggestions));
|
|
11148
|
+
};
|
|
11149
|
+
const isAutoClosingTagsEnabled = async () => {
|
|
11150
|
+
return true;
|
|
11151
|
+
};
|
|
11152
|
+
const getRowHeight = async () => {
|
|
11153
|
+
return (await get$1(kLineHeight)) || 20;
|
|
11154
|
+
};
|
|
11155
|
+
const getFontSize = async () => {
|
|
11156
|
+
return (await get$1(kFontSize)) || 15; // TODO find out if it is possible to use all numeric values for settings for efficiency, maybe settings could be an array
|
|
11157
|
+
};
|
|
11158
|
+
const getFontFamily = async () => {
|
|
11159
|
+
return (await get$1(kFontFamily)) || 'Fira Code';
|
|
11160
|
+
};
|
|
11161
|
+
const getLetterSpacing = async () => {
|
|
11162
|
+
{
|
|
11163
|
+
return 0;
|
|
11164
|
+
}
|
|
11165
|
+
};
|
|
11166
|
+
const getTabSize = async () => {
|
|
11167
|
+
return (await get$1(kTabSize)) || 2;
|
|
11168
|
+
};
|
|
11169
|
+
const getLineNumbers = async () => {
|
|
11170
|
+
return (await get$1(kLineNumbers)) ?? false;
|
|
11171
|
+
};
|
|
11172
|
+
const getCompletionTriggerCharacters = async () => {
|
|
11173
|
+
return ['.', '/'];
|
|
11174
|
+
};
|
|
11175
|
+
const diagnosticsEnabled = async () => {
|
|
11176
|
+
return (await get$1(kDiagnostics)) ?? false;
|
|
11177
|
+
};
|
|
11178
|
+
const getFontWeight = async () => {
|
|
11179
|
+
return (await get$1(kFontWeight)) ?? 400;
|
|
11180
|
+
};
|
|
11181
|
+
|
|
11182
|
+
const getEditorPreferences = async () => {
|
|
11183
|
+
const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, rowHeight, tabSize, letterSpacing, completionTriggerCharacters] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters()]);
|
|
11184
|
+
return {
|
|
11185
|
+
completionTriggerCharacters,
|
|
11186
|
+
diagnosticsEnabled: diagnosticsEnabled$1,
|
|
11082
11187
|
fontFamily,
|
|
11083
11188
|
fontSize,
|
|
11084
11189
|
fontWeight,
|
|
11085
|
-
|
|
11190
|
+
isAutoClosingBracketsEnabled: isAutoClosingBracketsEnabled$1,
|
|
11191
|
+
isAutoClosingQuotesEnabled: isAutoClosingQuotesEnabled$1,
|
|
11192
|
+
isAutoClosingTagsEnabled: isAutoClosingTagsEnabled$1,
|
|
11193
|
+
isQuickSuggestionsEnabled: isQuickSuggestionsEnabled$1,
|
|
11086
11194
|
letterSpacing,
|
|
11195
|
+
lineNumbers,
|
|
11196
|
+
rowHeight,
|
|
11197
|
+
tabSize
|
|
11198
|
+
};
|
|
11199
|
+
};
|
|
11200
|
+
|
|
11201
|
+
const getTokenizePath = (languages, languageId) => {
|
|
11202
|
+
for (const language of languages) {
|
|
11203
|
+
if (language?.id === languageId) {
|
|
11204
|
+
return language.tokenize || '';
|
|
11205
|
+
}
|
|
11206
|
+
}
|
|
11207
|
+
return '';
|
|
11208
|
+
};
|
|
11209
|
+
const loadContent = async (state, savedState) => {
|
|
11210
|
+
const {
|
|
11211
|
+
assetDir,
|
|
11212
|
+
height,
|
|
11213
|
+
id,
|
|
11087
11214
|
platform,
|
|
11088
11215
|
uri,
|
|
11089
11216
|
width,
|
|
11090
11217
|
x,
|
|
11091
11218
|
y
|
|
11092
11219
|
} = state;
|
|
11220
|
+
const {
|
|
11221
|
+
completionTriggerCharacters,
|
|
11222
|
+
diagnosticsEnabled,
|
|
11223
|
+
fontFamily,
|
|
11224
|
+
fontSize,
|
|
11225
|
+
fontWeight,
|
|
11226
|
+
isAutoClosingBracketsEnabled,
|
|
11227
|
+
isAutoClosingQuotesEnabled,
|
|
11228
|
+
isAutoClosingTagsEnabled,
|
|
11229
|
+
isQuickSuggestionsEnabled,
|
|
11230
|
+
letterSpacing,
|
|
11231
|
+
lineNumbers,
|
|
11232
|
+
rowHeight,
|
|
11233
|
+
tabSize
|
|
11234
|
+
} = await getEditorPreferences();
|
|
11093
11235
|
// TODO support overwriting language id by setting it explicitly or via settings
|
|
11094
11236
|
const charWidth = await measureCharacterWidth(fontWeight, fontSize, fontFamily, letterSpacing);
|
|
11095
11237
|
const languages = await getLanguages(platform, assetDir);
|
|
11096
|
-
const
|
|
11238
|
+
const computedLanguageId = getLanguageId$1(uri, languages);
|
|
11239
|
+
const tokenizePath = getTokenizePath(languages, computedLanguageId);
|
|
11240
|
+
await loadTokenizer(computedLanguageId, tokenizePath);
|
|
11241
|
+
const tokenizer = getTokenizer(computedLanguageId);
|
|
11242
|
+
const newTokenizerId = state.tokenizerId + 1;
|
|
11243
|
+
set$2(newTokenizerId, tokenizer);
|
|
11097
11244
|
const newEditor0 = {
|
|
11098
11245
|
...state,
|
|
11099
11246
|
charWidth,
|
|
11100
|
-
|
|
11247
|
+
completionTriggerCharacters,
|
|
11248
|
+
diagnosticsEnabled,
|
|
11249
|
+
fontFamily,
|
|
11250
|
+
fontSize,
|
|
11251
|
+
fontWeight,
|
|
11252
|
+
isAutoClosingBracketsEnabled,
|
|
11253
|
+
isAutoClosingQuotesEnabled,
|
|
11254
|
+
isAutoClosingTagsEnabled,
|
|
11255
|
+
isQuickSuggestionsEnabled,
|
|
11256
|
+
languageId: computedLanguageId,
|
|
11257
|
+
letterSpacing,
|
|
11258
|
+
lineNumbers,
|
|
11259
|
+
rowHeight,
|
|
11260
|
+
tabSize,
|
|
11261
|
+
tokenizerId: newTokenizerId
|
|
11101
11262
|
};
|
|
11102
11263
|
const content = await readFile(uri);
|
|
11103
11264
|
|
|
@@ -11128,7 +11289,7 @@ const loadContent = async (state, savedState) => {
|
|
|
11128
11289
|
// TODO only sync when needed
|
|
11129
11290
|
// e.g. it might not always be necessary to send text to extension host worker
|
|
11130
11291
|
// @ts-ignore
|
|
11131
|
-
await invoke$6(TextDocumentSyncFull, uri, id,
|
|
11292
|
+
await invoke$6(TextDocumentSyncFull, uri, id, computedLanguageId, content);
|
|
11132
11293
|
|
|
11133
11294
|
// TODO await promise
|
|
11134
11295
|
if (diagnosticsEnabled) {
|
|
@@ -11138,7 +11299,8 @@ const loadContent = async (state, savedState) => {
|
|
|
11138
11299
|
const completionsOnType = Boolean(completionsOnTypeRaw);
|
|
11139
11300
|
const newEditor5 = {
|
|
11140
11301
|
...newEditor4,
|
|
11141
|
-
completionsOnType
|
|
11302
|
+
completionsOnType,
|
|
11303
|
+
initial: false
|
|
11142
11304
|
};
|
|
11143
11305
|
return newEditor5;
|
|
11144
11306
|
};
|
|
@@ -11209,6 +11371,319 @@ const registerListener = (listenerType, rpcId) => {
|
|
|
11209
11371
|
registerListener$1(listenerType, rpcId);
|
|
11210
11372
|
};
|
|
11211
11373
|
|
|
11374
|
+
const getCss = itemHeight => {
|
|
11375
|
+
return `:root {
|
|
11376
|
+
--ActivityBarItemHeight: var(--${itemHeight}px);
|
|
11377
|
+
}
|
|
11378
|
+
`;
|
|
11379
|
+
};
|
|
11380
|
+
|
|
11381
|
+
const renderCss = (oldState, newState) => {
|
|
11382
|
+
const {
|
|
11383
|
+
itemHeight,
|
|
11384
|
+
uid
|
|
11385
|
+
} = newState;
|
|
11386
|
+
const css = getCss(itemHeight);
|
|
11387
|
+
return [SetCss$1, uid, css];
|
|
11388
|
+
};
|
|
11389
|
+
|
|
11390
|
+
const renderFocus$2 = (oldState, newState) => {
|
|
11391
|
+
const selector = '.EditorInput';
|
|
11392
|
+
return [FocusSelector, newState.uid, selector];
|
|
11393
|
+
};
|
|
11394
|
+
|
|
11395
|
+
const renderFocusContext$1 = (oldState, newState) => {
|
|
11396
|
+
return [SetFocusContext$1, newState.uid, FocusExplorer];
|
|
11397
|
+
};
|
|
11398
|
+
|
|
11399
|
+
const SetText = 1;
|
|
11400
|
+
const Replace = 2;
|
|
11401
|
+
const SetAttribute = 3;
|
|
11402
|
+
const RemoveAttribute = 4;
|
|
11403
|
+
const Add = 6;
|
|
11404
|
+
const NavigateChild = 7;
|
|
11405
|
+
const NavigateParent = 8;
|
|
11406
|
+
const RemoveChild = 9;
|
|
11407
|
+
const NavigateSibling = 10;
|
|
11408
|
+
const SetReferenceNodeUid = 11;
|
|
11409
|
+
|
|
11410
|
+
const isKey = key => {
|
|
11411
|
+
return key !== 'type' && key !== 'childCount';
|
|
11412
|
+
};
|
|
11413
|
+
|
|
11414
|
+
const getKeys = node => {
|
|
11415
|
+
const keys = Object.keys(node).filter(isKey);
|
|
11416
|
+
return keys;
|
|
11417
|
+
};
|
|
11418
|
+
|
|
11419
|
+
const arrayToTree = nodes => {
|
|
11420
|
+
const result = [];
|
|
11421
|
+
let i = 0;
|
|
11422
|
+
while (i < nodes.length) {
|
|
11423
|
+
const node = nodes[i];
|
|
11424
|
+
const {
|
|
11425
|
+
children,
|
|
11426
|
+
nodesConsumed
|
|
11427
|
+
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
11428
|
+
result.push({
|
|
11429
|
+
node,
|
|
11430
|
+
children
|
|
11431
|
+
});
|
|
11432
|
+
i += 1 + nodesConsumed;
|
|
11433
|
+
}
|
|
11434
|
+
return result;
|
|
11435
|
+
};
|
|
11436
|
+
const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
11437
|
+
if (childCount === 0) {
|
|
11438
|
+
return {
|
|
11439
|
+
children: [],
|
|
11440
|
+
nodesConsumed: 0
|
|
11441
|
+
};
|
|
11442
|
+
}
|
|
11443
|
+
const children = [];
|
|
11444
|
+
let i = startIndex;
|
|
11445
|
+
let remaining = childCount;
|
|
11446
|
+
let totalConsumed = 0;
|
|
11447
|
+
while (remaining > 0 && i < nodes.length) {
|
|
11448
|
+
const node = nodes[i];
|
|
11449
|
+
const nodeChildCount = node.childCount || 0;
|
|
11450
|
+
const {
|
|
11451
|
+
children: nodeChildren,
|
|
11452
|
+
nodesConsumed
|
|
11453
|
+
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
11454
|
+
children.push({
|
|
11455
|
+
node,
|
|
11456
|
+
children: nodeChildren
|
|
11457
|
+
});
|
|
11458
|
+
const nodeSize = 1 + nodesConsumed;
|
|
11459
|
+
i += nodeSize;
|
|
11460
|
+
totalConsumed += nodeSize;
|
|
11461
|
+
remaining--;
|
|
11462
|
+
}
|
|
11463
|
+
return {
|
|
11464
|
+
children,
|
|
11465
|
+
nodesConsumed: totalConsumed
|
|
11466
|
+
};
|
|
11467
|
+
};
|
|
11468
|
+
|
|
11469
|
+
const compareNodes = (oldNode, newNode) => {
|
|
11470
|
+
const patches = [];
|
|
11471
|
+
// Check if node type changed - return null to signal incompatible nodes
|
|
11472
|
+
// (caller should handle this with a Replace operation)
|
|
11473
|
+
if (oldNode.type !== newNode.type) {
|
|
11474
|
+
return null;
|
|
11475
|
+
}
|
|
11476
|
+
// Handle reference nodes - special handling for uid changes
|
|
11477
|
+
if (oldNode.type === Reference) {
|
|
11478
|
+
if (oldNode.uid !== newNode.uid) {
|
|
11479
|
+
patches.push({
|
|
11480
|
+
type: SetReferenceNodeUid,
|
|
11481
|
+
uid: newNode.uid
|
|
11482
|
+
});
|
|
11483
|
+
}
|
|
11484
|
+
return patches;
|
|
11485
|
+
}
|
|
11486
|
+
// Handle text nodes
|
|
11487
|
+
if (oldNode.type === Text$1 && newNode.type === Text$1) {
|
|
11488
|
+
if (oldNode.text !== newNode.text) {
|
|
11489
|
+
patches.push({
|
|
11490
|
+
type: SetText,
|
|
11491
|
+
value: newNode.text
|
|
11492
|
+
});
|
|
11493
|
+
}
|
|
11494
|
+
return patches;
|
|
11495
|
+
}
|
|
11496
|
+
// Compare attributes
|
|
11497
|
+
const oldKeys = getKeys(oldNode);
|
|
11498
|
+
const newKeys = getKeys(newNode);
|
|
11499
|
+
// Check for attribute changes
|
|
11500
|
+
for (const key of newKeys) {
|
|
11501
|
+
if (oldNode[key] !== newNode[key]) {
|
|
11502
|
+
patches.push({
|
|
11503
|
+
type: SetAttribute,
|
|
11504
|
+
key,
|
|
11505
|
+
value: newNode[key]
|
|
11506
|
+
});
|
|
11507
|
+
}
|
|
11508
|
+
}
|
|
11509
|
+
// Check for removed attributes
|
|
11510
|
+
for (const key of oldKeys) {
|
|
11511
|
+
if (!(key in newNode)) {
|
|
11512
|
+
patches.push({
|
|
11513
|
+
type: RemoveAttribute,
|
|
11514
|
+
key
|
|
11515
|
+
});
|
|
11516
|
+
}
|
|
11517
|
+
}
|
|
11518
|
+
return patches;
|
|
11519
|
+
};
|
|
11520
|
+
|
|
11521
|
+
const treeToArray = node => {
|
|
11522
|
+
const result = [node.node];
|
|
11523
|
+
for (const child of node.children) {
|
|
11524
|
+
result.push(...treeToArray(child));
|
|
11525
|
+
}
|
|
11526
|
+
return result;
|
|
11527
|
+
};
|
|
11528
|
+
|
|
11529
|
+
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
11530
|
+
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
11531
|
+
// Track where we are: -1 means at parent, >= 0 means at child index
|
|
11532
|
+
let currentChildIndex = -1;
|
|
11533
|
+
// Collect indices of children to remove (we'll add these patches at the end in reverse order)
|
|
11534
|
+
const indicesToRemove = [];
|
|
11535
|
+
for (let i = 0; i < maxLength; i++) {
|
|
11536
|
+
const oldNode = oldChildren[i];
|
|
11537
|
+
const newNode = newChildren[i];
|
|
11538
|
+
if (!oldNode && !newNode) {
|
|
11539
|
+
continue;
|
|
11540
|
+
}
|
|
11541
|
+
if (!oldNode) {
|
|
11542
|
+
// Add new node - we should be at the parent
|
|
11543
|
+
if (currentChildIndex >= 0) {
|
|
11544
|
+
// Navigate back to parent
|
|
11545
|
+
patches.push({
|
|
11546
|
+
type: NavigateParent
|
|
11547
|
+
});
|
|
11548
|
+
currentChildIndex = -1;
|
|
11549
|
+
}
|
|
11550
|
+
// Flatten the entire subtree so renderInternal can handle it
|
|
11551
|
+
const flatNodes = treeToArray(newNode);
|
|
11552
|
+
patches.push({
|
|
11553
|
+
type: Add,
|
|
11554
|
+
nodes: flatNodes
|
|
11555
|
+
});
|
|
11556
|
+
} else if (newNode) {
|
|
11557
|
+
// Compare nodes to see if we need any patches
|
|
11558
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
11559
|
+
// If nodePatches is null, the node types are incompatible - need to replace
|
|
11560
|
+
if (nodePatches === null) {
|
|
11561
|
+
// Navigate to this child
|
|
11562
|
+
if (currentChildIndex === -1) {
|
|
11563
|
+
patches.push({
|
|
11564
|
+
type: NavigateChild,
|
|
11565
|
+
index: i
|
|
11566
|
+
});
|
|
11567
|
+
currentChildIndex = i;
|
|
11568
|
+
} else if (currentChildIndex !== i) {
|
|
11569
|
+
patches.push({
|
|
11570
|
+
type: NavigateSibling,
|
|
11571
|
+
index: i
|
|
11572
|
+
});
|
|
11573
|
+
currentChildIndex = i;
|
|
11574
|
+
}
|
|
11575
|
+
// Replace the entire subtree
|
|
11576
|
+
const flatNodes = treeToArray(newNode);
|
|
11577
|
+
patches.push({
|
|
11578
|
+
type: Replace,
|
|
11579
|
+
nodes: flatNodes
|
|
11580
|
+
});
|
|
11581
|
+
// After replace, we're at the new element (same position)
|
|
11582
|
+
continue;
|
|
11583
|
+
}
|
|
11584
|
+
// Check if we need to recurse into children
|
|
11585
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
11586
|
+
// Only navigate to this element if we need to do something
|
|
11587
|
+
if (nodePatches.length > 0 || hasChildrenToCompare) {
|
|
11588
|
+
// Navigate to this child if not already there
|
|
11589
|
+
if (currentChildIndex === -1) {
|
|
11590
|
+
patches.push({
|
|
11591
|
+
type: NavigateChild,
|
|
11592
|
+
index: i
|
|
11593
|
+
});
|
|
11594
|
+
currentChildIndex = i;
|
|
11595
|
+
} else if (currentChildIndex !== i) {
|
|
11596
|
+
patches.push({
|
|
11597
|
+
type: NavigateSibling,
|
|
11598
|
+
index: i
|
|
11599
|
+
});
|
|
11600
|
+
currentChildIndex = i;
|
|
11601
|
+
}
|
|
11602
|
+
// Apply node patches (these apply to the current element, not children)
|
|
11603
|
+
if (nodePatches.length > 0) {
|
|
11604
|
+
patches.push(...nodePatches);
|
|
11605
|
+
}
|
|
11606
|
+
// Compare children recursively
|
|
11607
|
+
if (hasChildrenToCompare) {
|
|
11608
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
11609
|
+
}
|
|
11610
|
+
}
|
|
11611
|
+
} else {
|
|
11612
|
+
// Remove old node - collect the index for later removal
|
|
11613
|
+
indicesToRemove.push(i);
|
|
11614
|
+
}
|
|
11615
|
+
}
|
|
11616
|
+
// Navigate back to parent if we ended at a child
|
|
11617
|
+
if (currentChildIndex >= 0) {
|
|
11618
|
+
patches.push({
|
|
11619
|
+
type: NavigateParent
|
|
11620
|
+
});
|
|
11621
|
+
currentChildIndex = -1;
|
|
11622
|
+
}
|
|
11623
|
+
// Add remove patches in reverse order (highest index first)
|
|
11624
|
+
// This ensures indices remain valid as we remove
|
|
11625
|
+
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
11626
|
+
patches.push({
|
|
11627
|
+
type: RemoveChild,
|
|
11628
|
+
index: indicesToRemove[j]
|
|
11629
|
+
});
|
|
11630
|
+
}
|
|
11631
|
+
};
|
|
11632
|
+
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
11633
|
+
// At the root level (path.length === 0), we're already AT the element
|
|
11634
|
+
// So we compare the root node directly, then compare its children
|
|
11635
|
+
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
11636
|
+
const oldNode = oldTree[0];
|
|
11637
|
+
const newNode = newTree[0];
|
|
11638
|
+
// Compare root nodes
|
|
11639
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
11640
|
+
// If nodePatches is null, the root node types are incompatible - need to replace
|
|
11641
|
+
if (nodePatches === null) {
|
|
11642
|
+
const flatNodes = treeToArray(newNode);
|
|
11643
|
+
patches.push({
|
|
11644
|
+
type: Replace,
|
|
11645
|
+
nodes: flatNodes
|
|
11646
|
+
});
|
|
11647
|
+
return;
|
|
11648
|
+
}
|
|
11649
|
+
if (nodePatches.length > 0) {
|
|
11650
|
+
patches.push(...nodePatches);
|
|
11651
|
+
}
|
|
11652
|
+
// Compare children
|
|
11653
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
11654
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
11655
|
+
}
|
|
11656
|
+
} else {
|
|
11657
|
+
// Non-root level or multiple root elements - use the regular comparison
|
|
11658
|
+
diffChildren(oldTree, newTree, patches);
|
|
11659
|
+
}
|
|
11660
|
+
};
|
|
11661
|
+
|
|
11662
|
+
const removeTrailingNavigationPatches = patches => {
|
|
11663
|
+
// Find the last non-navigation patch
|
|
11664
|
+
let lastNonNavigationIndex = -1;
|
|
11665
|
+
for (let i = patches.length - 1; i >= 0; i--) {
|
|
11666
|
+
const patch = patches[i];
|
|
11667
|
+
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
|
|
11668
|
+
lastNonNavigationIndex = i;
|
|
11669
|
+
break;
|
|
11670
|
+
}
|
|
11671
|
+
}
|
|
11672
|
+
// Return patches up to and including the last non-navigation patch
|
|
11673
|
+
return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
|
|
11674
|
+
};
|
|
11675
|
+
|
|
11676
|
+
const diffTree = (oldNodes, newNodes) => {
|
|
11677
|
+
// Step 1: Convert flat arrays to tree structures
|
|
11678
|
+
const oldTree = arrayToTree(oldNodes);
|
|
11679
|
+
const newTree = arrayToTree(newNodes);
|
|
11680
|
+
// Step 3: Compare the trees
|
|
11681
|
+
const patches = [];
|
|
11682
|
+
diffTrees(oldTree, newTree, patches, []);
|
|
11683
|
+
// Remove trailing navigation patches since they serve no purpose
|
|
11684
|
+
return removeTrailingNavigationPatches(patches);
|
|
11685
|
+
};
|
|
11686
|
+
|
|
11212
11687
|
const getCursorsVirtualDom = cursors => {
|
|
11213
11688
|
const dom = [];
|
|
11214
11689
|
for (const translate of cursors) {
|
|
@@ -11324,6 +11799,133 @@ const getSelectionsVirtualDom = selections => {
|
|
|
11324
11799
|
return dom;
|
|
11325
11800
|
};
|
|
11326
11801
|
|
|
11802
|
+
const getEditorVirtualDom = ({
|
|
11803
|
+
cursorInfos = [],
|
|
11804
|
+
diagnostics = [],
|
|
11805
|
+
differences,
|
|
11806
|
+
gutterInfos = [],
|
|
11807
|
+
highlightedLine = -1,
|
|
11808
|
+
lineNumbers = true,
|
|
11809
|
+
scrollBarDiagnostics = [],
|
|
11810
|
+
selectionInfos = [],
|
|
11811
|
+
textInfos
|
|
11812
|
+
}) => {
|
|
11813
|
+
const cursorInfosArray = [...cursorInfos];
|
|
11814
|
+
const diagnosticsArray = [...diagnostics];
|
|
11815
|
+
const gutterInfosArray = [...gutterInfos];
|
|
11816
|
+
const scrollBarDiagnosticsArray = [...scrollBarDiagnostics];
|
|
11817
|
+
const rowsDom = getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine);
|
|
11818
|
+
const cursorsDom = getCursorsVirtualDom(cursorInfosArray);
|
|
11819
|
+
const selectionsDom = getSelectionsVirtualDom(selectionInfos);
|
|
11820
|
+
const diagnosticsDom = getDiagnosticsVirtualDom(diagnosticsArray);
|
|
11821
|
+
const gutterDom = getEditorGutterVirtualDom(gutterInfosArray);
|
|
11822
|
+
const scrollBarDiagnosticsDom = getDiagnosticsVirtualDom(scrollBarDiagnosticsArray);
|
|
11823
|
+
return [{
|
|
11824
|
+
childCount: 2,
|
|
11825
|
+
className: 'Viewlet Editor',
|
|
11826
|
+
role: 'code',
|
|
11827
|
+
type: Div
|
|
11828
|
+
}, {
|
|
11829
|
+
childCount: gutterInfosArray.length,
|
|
11830
|
+
className: 'Gutter',
|
|
11831
|
+
type: Div
|
|
11832
|
+
}, ...gutterDom, {
|
|
11833
|
+
childCount: 4,
|
|
11834
|
+
className: 'EditorContent',
|
|
11835
|
+
type: Div
|
|
11836
|
+
}, {
|
|
11837
|
+
childCount: 4,
|
|
11838
|
+
className: 'EditorLayers',
|
|
11839
|
+
type: Div
|
|
11840
|
+
}, {
|
|
11841
|
+
childCount: selectionsDom.length,
|
|
11842
|
+
className: 'Selections',
|
|
11843
|
+
type: Div
|
|
11844
|
+
}, ...selectionsDom, {
|
|
11845
|
+
childCount: textInfos.length,
|
|
11846
|
+
className: 'EditorRows',
|
|
11847
|
+
type: Div
|
|
11848
|
+
}, ...rowsDom, {
|
|
11849
|
+
childCount: cursorsDom.length,
|
|
11850
|
+
className: 'LayerCursor',
|
|
11851
|
+
type: Div
|
|
11852
|
+
}, ...cursorsDom, {
|
|
11853
|
+
childCount: diagnosticsDom.length,
|
|
11854
|
+
className: 'LayerDiagnostics',
|
|
11855
|
+
type: Div
|
|
11856
|
+
}, ...diagnosticsDom, {
|
|
11857
|
+
childCount: scrollBarDiagnosticsDom.length,
|
|
11858
|
+
className: 'EditorScrollBarDiagnostics',
|
|
11859
|
+
type: Div
|
|
11860
|
+
}, ...scrollBarDiagnosticsDom, {
|
|
11861
|
+
childCount: 1,
|
|
11862
|
+
className: 'ScrollBar ScrollBarVertical',
|
|
11863
|
+
type: Div
|
|
11864
|
+
}, {
|
|
11865
|
+
childCount: 0,
|
|
11866
|
+
className: 'ScrollBarThumb ScrollBarThumbVertical',
|
|
11867
|
+
type: Div
|
|
11868
|
+
}, {
|
|
11869
|
+
childCount: 1,
|
|
11870
|
+
className: 'ScrollBar ScrollBarHorizontal',
|
|
11871
|
+
type: Div
|
|
11872
|
+
}, {
|
|
11873
|
+
childCount: 0,
|
|
11874
|
+
className: 'ScrollBarThumb ScrollBarThumbHorizontal',
|
|
11875
|
+
type: Div
|
|
11876
|
+
}];
|
|
11877
|
+
};
|
|
11878
|
+
|
|
11879
|
+
const getDom = state => {
|
|
11880
|
+
if (state.initial && state.textInfos.length === 0) {
|
|
11881
|
+
return [];
|
|
11882
|
+
}
|
|
11883
|
+
return getEditorVirtualDom(state);
|
|
11884
|
+
};
|
|
11885
|
+
const renderIncremental = (oldState, newState) => {
|
|
11886
|
+
const oldDom = getDom(oldState);
|
|
11887
|
+
const newDom = getDom(newState);
|
|
11888
|
+
const patches = diffTree(oldDom, newDom);
|
|
11889
|
+
return [SetPatches, newState.uid, patches];
|
|
11890
|
+
};
|
|
11891
|
+
|
|
11892
|
+
const getRenderer = diffType => {
|
|
11893
|
+
switch (diffType) {
|
|
11894
|
+
case RenderCss:
|
|
11895
|
+
return renderCss;
|
|
11896
|
+
case RenderFocus:
|
|
11897
|
+
return renderFocus$2;
|
|
11898
|
+
case RenderFocusContext:
|
|
11899
|
+
return renderFocusContext$1;
|
|
11900
|
+
case RenderIncremental:
|
|
11901
|
+
return renderIncremental;
|
|
11902
|
+
default:
|
|
11903
|
+
throw new Error('unknown renderer');
|
|
11904
|
+
}
|
|
11905
|
+
};
|
|
11906
|
+
|
|
11907
|
+
const applyRender = (oldState, newState, diffResult) => {
|
|
11908
|
+
const commands = [];
|
|
11909
|
+
for (const item of diffResult) {
|
|
11910
|
+
const fn = getRenderer(item);
|
|
11911
|
+
const result = fn(oldState, newState);
|
|
11912
|
+
if (result.length > 0) {
|
|
11913
|
+
commands.push(result);
|
|
11914
|
+
}
|
|
11915
|
+
}
|
|
11916
|
+
return commands;
|
|
11917
|
+
};
|
|
11918
|
+
|
|
11919
|
+
const render2 = (uid, diffResult) => {
|
|
11920
|
+
const {
|
|
11921
|
+
newState,
|
|
11922
|
+
oldState
|
|
11923
|
+
} = get$7(uid);
|
|
11924
|
+
set$8(uid, newState, newState);
|
|
11925
|
+
const commands = applyRender(oldState, newState, diffResult);
|
|
11926
|
+
return commands;
|
|
11927
|
+
};
|
|
11928
|
+
|
|
11327
11929
|
const addWidget = widget => {
|
|
11328
11930
|
const module = get$6(widget.id);
|
|
11329
11931
|
if (!module) {
|
|
@@ -11551,7 +12153,7 @@ const renderEventListeners = () => {
|
|
|
11551
12153
|
params: ['handleFocus']
|
|
11552
12154
|
}, {
|
|
11553
12155
|
name: HandleMouseMove,
|
|
11554
|
-
params: ['handleInput',
|
|
12156
|
+
params: ['handleInput', ClientX, ClientY, AltKey]
|
|
11555
12157
|
}, {
|
|
11556
12158
|
name: HandleBlur,
|
|
11557
12159
|
params: ['handleBlur']
|
|
@@ -11573,11 +12175,11 @@ const renderEventListeners = () => {
|
|
|
11573
12175
|
preventDefault: true
|
|
11574
12176
|
}, {
|
|
11575
12177
|
name: HandleWheel,
|
|
11576
|
-
params: ['setDelta',
|
|
11577
|
-
|
|
12178
|
+
params: ['setDelta', DeltaMode, DeltaY],
|
|
12179
|
+
passive: true
|
|
11578
12180
|
}, {
|
|
11579
12181
|
name: HandleContextMenu,
|
|
11580
|
-
params: ['handleContextMenu',
|
|
12182
|
+
params: ['handleContextMenu', Button, ClientX, ClientY],
|
|
11581
12183
|
preventDefault: true
|
|
11582
12184
|
}];
|
|
11583
12185
|
};
|
|
@@ -11607,7 +12209,7 @@ const unregisterListener = (listenerType, rpcId) => {
|
|
|
11607
12209
|
};
|
|
11608
12210
|
|
|
11609
12211
|
const invoke = async (method, ...params) => {
|
|
11610
|
-
const worker = get$
|
|
12212
|
+
const worker = get$8(DebugWorker);
|
|
11611
12213
|
return worker.invoke(method, ...params);
|
|
11612
12214
|
};
|
|
11613
12215
|
|
|
@@ -11617,7 +12219,7 @@ const getDebugHighlight = async debugId => {
|
|
|
11617
12219
|
};
|
|
11618
12220
|
|
|
11619
12221
|
const getKey = () => {
|
|
11620
|
-
const keys = getKeys$
|
|
12222
|
+
const keys = getKeys$2();
|
|
11621
12223
|
return parseInt(keys[0]);
|
|
11622
12224
|
};
|
|
11623
12225
|
const updateDebugInfo = async debugId => {
|
|
@@ -11715,13 +12317,14 @@ const commandMap = {
|
|
|
11715
12317
|
'Editor.deleteWordPartLeft': wrapCommand(deleteWordPartLeft),
|
|
11716
12318
|
'Editor.deleteWordPartRight': wrapCommand(deleteWordPartRight),
|
|
11717
12319
|
'Editor.deleteWordRight': wrapCommand(deleteWordRight),
|
|
12320
|
+
'Editor.diff2': diff2,
|
|
11718
12321
|
'Editor.executeWidgetCommand': wrapCommand(executeWidgetCommand),
|
|
11719
12322
|
'Editor.findAllReferences': wrapCommand(findAllReferences$1),
|
|
11720
12323
|
'Editor.format': wrapCommand(format),
|
|
11721
12324
|
'Editor.getCommandIds': getCommandIds,
|
|
11722
12325
|
'Editor.getDiagnostics': getDiagnostics$1,
|
|
11723
12326
|
'Editor.getKeyBindings': getKeyBindings,
|
|
11724
|
-
'Editor.getKeys': getKeys,
|
|
12327
|
+
'Editor.getKeys': getKeys$1,
|
|
11725
12328
|
'Editor.getLanguageId': getLanguageId,
|
|
11726
12329
|
'Editor.getLines2': getLines2,
|
|
11727
12330
|
'Editor.getMenuEntries': getMenuEntries,
|
|
@@ -11773,7 +12376,7 @@ const commandMap = {
|
|
|
11773
12376
|
'Editor.indendLess': wrapCommand(indentLess),
|
|
11774
12377
|
'Editor.indentMore': wrapCommand(indentMore),
|
|
11775
12378
|
'Editor.insertLineBreak': wrapCommand(insertLineBreak),
|
|
11776
|
-
'Editor.loadContent': loadContent,
|
|
12379
|
+
'Editor.loadContent': wrapCommand$1(loadContent),
|
|
11777
12380
|
'Editor.moveLineDown': wrapCommand(moveLineDown),
|
|
11778
12381
|
'Editor.moveLineUp': wrapCommand(moveLineUp),
|
|
11779
12382
|
'Editor.moveRectangleSelection': wrapCommand(moveRectangleSelection),
|
|
@@ -11791,6 +12394,7 @@ const commandMap = {
|
|
|
11791
12394
|
'Editor.paste': wrapCommand(paste),
|
|
11792
12395
|
'Editor.pasteText': wrapCommand(pasteText),
|
|
11793
12396
|
'Editor.render': renderEditor,
|
|
12397
|
+
'Editor.render2': render2,
|
|
11794
12398
|
'Editor.renderEventListeners': renderEventListeners,
|
|
11795
12399
|
'Editor.replaceRange': wrapCommand(replaceRange),
|
|
11796
12400
|
'Editor.rerender': wrapCommand(rerender),
|
|
@@ -11911,25 +12515,15 @@ const commandMap = {
|
|
|
11911
12515
|
'Listener.unregister': unregisterListener,
|
|
11912
12516
|
'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker': sendMessagePortToExtensionHostWorker2
|
|
11913
12517
|
};
|
|
11914
|
-
|
|
11915
|
-
|
|
11916
|
-
|
|
11917
|
-
|
|
11918
|
-
};
|
|
11919
|
-
const createTextMeasurementWorkerRpc = async () => {
|
|
11920
|
-
try {
|
|
11921
|
-
const rpc = await create$c({
|
|
11922
|
-
commandMap: {},
|
|
11923
|
-
send
|
|
11924
|
-
});
|
|
11925
|
-
return rpc;
|
|
11926
|
-
} catch (error) {
|
|
11927
|
-
throw new VError(error, `Failed to create text measurement worker rpc`);
|
|
12518
|
+
for (const [key, value] of Object.entries(commandMap)) {
|
|
12519
|
+
if (key.startsWith('Editor.')) {
|
|
12520
|
+
// @ts-ignore
|
|
12521
|
+
commandMap['EditorText' + key.slice('Editor'.length)] = value;
|
|
11928
12522
|
}
|
|
11929
|
-
}
|
|
12523
|
+
}
|
|
11930
12524
|
|
|
11931
12525
|
const listen = async () => {
|
|
11932
|
-
|
|
12526
|
+
registerCommands(commandMap);
|
|
11933
12527
|
const rpc = await create$b({
|
|
11934
12528
|
commandMap: commandMap
|
|
11935
12529
|
});
|