@lvce-editor/editor-worker 19.74.8 → 19.75.1
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/README.md +26 -0
- package/dist/diff-sdk.d.ts +236 -0
- package/dist/diff-sdk.js +20235 -0
- package/dist/editorWorkerMain.js +543 -365
- package/package.json +5 -2
package/dist/editorWorkerMain.js
CHANGED
|
@@ -543,7 +543,7 @@ class CommandNotFoundError extends Error {
|
|
|
543
543
|
}
|
|
544
544
|
}
|
|
545
545
|
const commands = Object.create(null);
|
|
546
|
-
const register = commandMap => {
|
|
546
|
+
const register$1 = commandMap => {
|
|
547
547
|
Object.assign(commands, commandMap);
|
|
548
548
|
};
|
|
549
549
|
const getCommand = key => {
|
|
@@ -1102,7 +1102,7 @@ const create$h = async ({
|
|
|
1102
1102
|
messagePort
|
|
1103
1103
|
}) => {
|
|
1104
1104
|
// TODO create a commandMap per rpc instance
|
|
1105
|
-
register(commandMap);
|
|
1105
|
+
register$1(commandMap);
|
|
1106
1106
|
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
1107
1107
|
isMessagePortOpen,
|
|
1108
1108
|
messagePort
|
|
@@ -1159,7 +1159,7 @@ const create$d = async ({
|
|
|
1159
1159
|
commandMap
|
|
1160
1160
|
}) => {
|
|
1161
1161
|
// TODO create a commandMap per rpc instance
|
|
1162
|
-
register(commandMap);
|
|
1162
|
+
register$1(commandMap);
|
|
1163
1163
|
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
1164
1164
|
handleIpc(ipc);
|
|
1165
1165
|
const rpc = createRpc(ipc);
|
|
@@ -1327,27 +1327,27 @@ const SetPatches = 'Viewlet.setPatches';
|
|
|
1327
1327
|
const FocusEditorText$1 = 12;
|
|
1328
1328
|
|
|
1329
1329
|
const {
|
|
1330
|
-
invoke: invoke$
|
|
1330
|
+
invoke: invoke$k,
|
|
1331
1331
|
set: set$i
|
|
1332
1332
|
} = create$c(DialogWorker);
|
|
1333
1333
|
|
|
1334
1334
|
const {
|
|
1335
|
-
invoke: invoke$
|
|
1335
|
+
invoke: invoke$j,
|
|
1336
1336
|
set: set$h
|
|
1337
1337
|
} = create$c(DragAndDropWorker);
|
|
1338
1338
|
|
|
1339
1339
|
const {
|
|
1340
|
-
invoke: invoke$
|
|
1340
|
+
invoke: invoke$i,
|
|
1341
1341
|
set: set$g
|
|
1342
1342
|
} = create$c(ErrorWorker);
|
|
1343
1343
|
|
|
1344
1344
|
const {
|
|
1345
|
-
invoke: invoke$
|
|
1345
|
+
invoke: invoke$h,
|
|
1346
1346
|
invokeAndTransfer: invokeAndTransfer$2,
|
|
1347
1347
|
set: set$f
|
|
1348
1348
|
} = create$c(ExtensionManagementWorker);
|
|
1349
1349
|
const getLanguages$1 = (platform, assetDir) => {
|
|
1350
|
-
return invoke$
|
|
1350
|
+
return invoke$h('Extensions.getLanguages', platform, assetDir);
|
|
1351
1351
|
};
|
|
1352
1352
|
|
|
1353
1353
|
const createLazyRpc = rpcId => {
|
|
@@ -1424,20 +1424,20 @@ const createLazyRpc = rpcId => {
|
|
|
1424
1424
|
};
|
|
1425
1425
|
|
|
1426
1426
|
const {
|
|
1427
|
-
invoke: invoke$
|
|
1427
|
+
invoke: invoke$g,
|
|
1428
1428
|
set: set$e
|
|
1429
1429
|
} = create$c(OpenerWorker);
|
|
1430
1430
|
const openUrl = async (url, platform) => {
|
|
1431
|
-
return invoke$
|
|
1431
|
+
return invoke$g('Open.openUrl', url, platform);
|
|
1432
1432
|
};
|
|
1433
1433
|
|
|
1434
1434
|
const {
|
|
1435
|
-
invoke: invoke$
|
|
1435
|
+
invoke: invoke$f,
|
|
1436
1436
|
set: set$d
|
|
1437
1437
|
} = create$c(TextMeasurementWorker);
|
|
1438
1438
|
|
|
1439
1439
|
const {
|
|
1440
|
-
invoke: invoke$
|
|
1440
|
+
invoke: invoke$e,
|
|
1441
1441
|
invokeAndTransfer: invokeAndTransfer$1,
|
|
1442
1442
|
set: set$c
|
|
1443
1443
|
} = create$c(RendererWorker);
|
|
@@ -1446,7 +1446,7 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
1446
1446
|
number(menuId);
|
|
1447
1447
|
number(x);
|
|
1448
1448
|
number(y);
|
|
1449
|
-
await invoke$
|
|
1449
|
+
await invoke$e('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1450
1450
|
};
|
|
1451
1451
|
const sendMessagePortToDragAndDropWorker = async port => {
|
|
1452
1452
|
const command = 'DragAndDrop.handleMessagePort';
|
|
@@ -1465,10 +1465,10 @@ const sendMessagePortToErrorWorker = async (port, rpcId) => {
|
|
|
1465
1465
|
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
|
|
1466
1466
|
};
|
|
1467
1467
|
const writeClipBoardText = async text => {
|
|
1468
|
-
await invoke$
|
|
1468
|
+
await invoke$e('ClipBoard.writeText', /* text */text);
|
|
1469
1469
|
};
|
|
1470
1470
|
const readClipBoardText = async () => {
|
|
1471
|
-
return invoke$
|
|
1471
|
+
return invoke$e('ClipBoard.readText');
|
|
1472
1472
|
};
|
|
1473
1473
|
const sendMessagePortToTextMeasurementWorker = async port => {
|
|
1474
1474
|
const command = 'TextMeasurement.handleMessagePort';
|
|
@@ -1479,10 +1479,10 @@ const sendMessagePortToExtensionManagementWorker$1 = async (port, rpcId) => {
|
|
|
1479
1479
|
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
1480
1480
|
};
|
|
1481
1481
|
const getPreference$1 = async key => {
|
|
1482
|
-
return await invoke$
|
|
1482
|
+
return await invoke$e('Preferences.get', key);
|
|
1483
1483
|
};
|
|
1484
1484
|
const openUri = async (uri, focus, options) => {
|
|
1485
|
-
await invoke$
|
|
1485
|
+
await invoke$e('Main.openUri', {
|
|
1486
1486
|
...options,
|
|
1487
1487
|
focus,
|
|
1488
1488
|
uri
|
|
@@ -1493,7 +1493,7 @@ const sendMessagePortToSyntaxHighlightingWorker$1 = async port => {
|
|
|
1493
1493
|
};
|
|
1494
1494
|
|
|
1495
1495
|
const {
|
|
1496
|
-
invoke: invoke$
|
|
1496
|
+
invoke: invoke$d,
|
|
1497
1497
|
set: set$b
|
|
1498
1498
|
} = create$c(MarkdownWorker);
|
|
1499
1499
|
|
|
@@ -1764,7 +1764,7 @@ const activateByEvent = async (event, assetDir, platform) => {
|
|
|
1764
1764
|
string(event);
|
|
1765
1765
|
// Assert.string(assetDir)
|
|
1766
1766
|
// Assert.number(platform)
|
|
1767
|
-
await invoke$
|
|
1767
|
+
await invoke$h('Extensions.activateByEvent', event);
|
|
1768
1768
|
};
|
|
1769
1769
|
|
|
1770
1770
|
const codeGeneratorAccept = state => {
|
|
@@ -2641,7 +2641,7 @@ const getInitialLineState = initialLineState => {
|
|
|
2641
2641
|
return deepCopy(initialLineState);
|
|
2642
2642
|
};
|
|
2643
2643
|
|
|
2644
|
-
const state$
|
|
2644
|
+
const state$f = {
|
|
2645
2645
|
warned: []
|
|
2646
2646
|
};
|
|
2647
2647
|
const flattenTokensArray = tokens => {
|
|
@@ -2653,10 +2653,10 @@ const flattenTokensArray = tokens => {
|
|
|
2653
2653
|
return flattened;
|
|
2654
2654
|
};
|
|
2655
2655
|
const warnDeprecatedArrayReturn = (languageId, fn) => {
|
|
2656
|
-
if (state$
|
|
2656
|
+
if (state$f.warned.includes(fn)) {
|
|
2657
2657
|
return;
|
|
2658
2658
|
}
|
|
2659
|
-
state$
|
|
2659
|
+
state$f.warned.push(fn);
|
|
2660
2660
|
console.warn(`tokenizers without hasArrayReturn=false are deprecated (language ${languageId})`);
|
|
2661
2661
|
};
|
|
2662
2662
|
const safeTokenizeLine = (languageId, tokenizeLine, line, lineStateAtStart, hasArrayReturn) => {
|
|
@@ -2717,38 +2717,38 @@ const TokenizePlainText = {
|
|
|
2717
2717
|
tokenizeLine
|
|
2718
2718
|
};
|
|
2719
2719
|
|
|
2720
|
-
const state$
|
|
2720
|
+
const state$e = {
|
|
2721
2721
|
enabled: false
|
|
2722
2722
|
};
|
|
2723
2723
|
const setEnabled$1 = value => {
|
|
2724
|
-
state$
|
|
2724
|
+
state$e.enabled = value;
|
|
2725
2725
|
};
|
|
2726
2726
|
const getEnabled$1 = () => {
|
|
2727
|
-
return state$
|
|
2727
|
+
return state$e.enabled;
|
|
2728
2728
|
};
|
|
2729
2729
|
|
|
2730
|
-
const invoke$
|
|
2730
|
+
const invoke$c = (...args) => invoke$d(...args);
|
|
2731
2731
|
const set$8 = (...args) => set$b(...args);
|
|
2732
2732
|
|
|
2733
|
-
const state$
|
|
2733
|
+
const state$d = {
|
|
2734
2734
|
pending: Object.create(null),
|
|
2735
2735
|
tokenizePaths: Object.create(null),
|
|
2736
2736
|
tokenizers: Object.create(null)
|
|
2737
2737
|
};
|
|
2738
2738
|
const has = languageId => {
|
|
2739
|
-
return Object.hasOwn(state$
|
|
2739
|
+
return Object.hasOwn(state$d.tokenizers, languageId);
|
|
2740
2740
|
};
|
|
2741
2741
|
const set$7 = (languageId, tokenizer) => {
|
|
2742
|
-
state$
|
|
2742
|
+
state$d.tokenizers[languageId] = tokenizer;
|
|
2743
2743
|
};
|
|
2744
2744
|
const get$6 = languageId => {
|
|
2745
|
-
return state$
|
|
2745
|
+
return state$d.tokenizers[languageId];
|
|
2746
2746
|
};
|
|
2747
2747
|
const setTokenizePath = (languageId, tokenizePath) => {
|
|
2748
|
-
state$
|
|
2748
|
+
state$d.tokenizePaths[languageId] = tokenizePath;
|
|
2749
2749
|
};
|
|
2750
2750
|
const getTokenizePath$1 = languageId => {
|
|
2751
|
-
return state$
|
|
2751
|
+
return state$d.tokenizePaths[languageId] || '';
|
|
2752
2752
|
};
|
|
2753
2753
|
const setTokenizePaths = languages => {
|
|
2754
2754
|
for (const language of languages) {
|
|
@@ -2758,7 +2758,7 @@ const setTokenizePaths = languages => {
|
|
|
2758
2758
|
}
|
|
2759
2759
|
};
|
|
2760
2760
|
const isPending = languageId => {
|
|
2761
|
-
return Object.hasOwn(state$
|
|
2761
|
+
return Object.hasOwn(state$d.pending, languageId);
|
|
2762
2762
|
};
|
|
2763
2763
|
|
|
2764
2764
|
const tokenMaps = Object.create(null);
|
|
@@ -2777,7 +2777,7 @@ const loadTokenizer = async (languageId, tokenizePath) => {
|
|
|
2777
2777
|
setTokenizePath(languageId, tokenizePath);
|
|
2778
2778
|
if (getEnabled$1()) {
|
|
2779
2779
|
// @ts-ignore
|
|
2780
|
-
const tokenMap = await invoke$
|
|
2780
|
+
const tokenMap = await invoke$c('Tokenizer.load', languageId, tokenizePath);
|
|
2781
2781
|
set$6(languageId, tokenMap);
|
|
2782
2782
|
return;
|
|
2783
2783
|
}
|
|
@@ -2811,13 +2811,18 @@ const getTokenizer = languageId => {
|
|
|
2811
2811
|
return TokenizePlainText;
|
|
2812
2812
|
};
|
|
2813
2813
|
|
|
2814
|
-
const tokenizers =
|
|
2815
|
-
const set$5 = (id, value) => {
|
|
2816
|
-
tokenizers[id] = value;
|
|
2817
|
-
};
|
|
2814
|
+
const tokenizers = [TokenizePlainText];
|
|
2818
2815
|
const get$4 = id => {
|
|
2819
2816
|
return tokenizers[id] || TokenizePlainText;
|
|
2820
2817
|
};
|
|
2818
|
+
const register = tokenizer => {
|
|
2819
|
+
const existingId = tokenizers.indexOf(tokenizer);
|
|
2820
|
+
if (existingId !== -1) {
|
|
2821
|
+
return existingId;
|
|
2822
|
+
}
|
|
2823
|
+
tokenizers.push(tokenizer);
|
|
2824
|
+
return tokenizers.length - 1;
|
|
2825
|
+
};
|
|
2821
2826
|
|
|
2822
2827
|
const getEmbeddedTokenization = (langageId, line, embeddedLanguage, embeddedLanguageStart, embeddedLanguageEnd, topContexts, tokenizersToLoad) => {
|
|
2823
2828
|
const embeddedTokenizer = getTokenizer(embeddedLanguage);
|
|
@@ -2973,13 +2978,13 @@ const getTokensViewport2 = async (editor, startLineIndex, endLineIndex, syncIncr
|
|
|
2973
2978
|
invalidStartIndex,
|
|
2974
2979
|
languageId
|
|
2975
2980
|
};
|
|
2976
|
-
return invoke$
|
|
2981
|
+
return invoke$c('GetTokensViewport.getTokensViewport', slimEditor,
|
|
2977
2982
|
// @ts-ignore
|
|
2978
2983
|
startLineIndex, endLineIndex, hasLinesToSend, id, linesToSend);
|
|
2979
2984
|
}
|
|
2980
2985
|
// TODO only send needed lines of text
|
|
2981
2986
|
// @ts-ignore
|
|
2982
|
-
return invoke$
|
|
2987
|
+
return invoke$c('GetTokensViewport.getTokensViewport', editor, startLineIndex, endLineIndex, true, editor.id, editor.lines);
|
|
2983
2988
|
}
|
|
2984
2989
|
return getTokensViewport(editor, startLineIndex, endLineIndex);
|
|
2985
2990
|
};
|
|
@@ -3001,12 +3006,12 @@ const measureTextWidthFast = async (text, charWidth) => {
|
|
|
3001
3006
|
};
|
|
3002
3007
|
|
|
3003
3008
|
const measureTextWidthSlow = async (text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
|
|
3004
|
-
const width = await invoke$
|
|
3009
|
+
const width = await invoke$f('TextMeasurement.measureTextWidth', text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
|
|
3005
3010
|
return width;
|
|
3006
3011
|
};
|
|
3007
3012
|
|
|
3008
3013
|
const measureTextWidthsSlow = async (texts, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
|
|
3009
|
-
return await invoke$
|
|
3014
|
+
return await invoke$f('TextMeasurement.measureTextWidths', texts, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
|
|
3010
3015
|
};
|
|
3011
3016
|
|
|
3012
3017
|
const measureTextWidth = async (text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
|
|
@@ -3243,7 +3248,7 @@ const positionAt = (textDocument, offset) => {
|
|
|
3243
3248
|
const maxTokenizerLoadPasses$1 = 10;
|
|
3244
3249
|
const getGraphemeSegments = async lines => {
|
|
3245
3250
|
try {
|
|
3246
|
-
return await invoke$
|
|
3251
|
+
return await invoke$f('TextMeasurement.getGraphemeSegments', lines);
|
|
3247
3252
|
} catch {
|
|
3248
3253
|
return undefined;
|
|
3249
3254
|
}
|
|
@@ -3709,14 +3714,14 @@ const getVisible$1 = async (editor, syncIncremental) => {
|
|
|
3709
3714
|
};
|
|
3710
3715
|
};
|
|
3711
3716
|
|
|
3712
|
-
const state$
|
|
3717
|
+
const state$c = {
|
|
3713
3718
|
enabled: false
|
|
3714
3719
|
};
|
|
3715
3720
|
const setEnabled = value => {
|
|
3716
|
-
state$
|
|
3721
|
+
state$c.enabled = value;
|
|
3717
3722
|
};
|
|
3718
3723
|
const getEnabled = () => {
|
|
3719
|
-
return state$
|
|
3724
|
+
return state$c.enabled;
|
|
3720
3725
|
};
|
|
3721
3726
|
|
|
3722
3727
|
// TODO this should be in a separate scrolling module
|
|
@@ -3796,7 +3801,7 @@ const getIncrementalEdits = async (oldState, newState) => {
|
|
|
3796
3801
|
return emptyIncrementalEdits;
|
|
3797
3802
|
}
|
|
3798
3803
|
// @ts-ignore
|
|
3799
|
-
const incrementalEdits = await invoke$
|
|
3804
|
+
const incrementalEdits = await invoke$c(
|
|
3800
3805
|
// @ts-ignore
|
|
3801
3806
|
'TokenizeIncremental.tokenizeIncremental', newState.uid,
|
|
3802
3807
|
// @ts-ignore
|
|
@@ -4044,7 +4049,7 @@ const send$2 = (rpcId, rpc, status) => {
|
|
|
4044
4049
|
return delivery.running || start(delivery);
|
|
4045
4050
|
};
|
|
4046
4051
|
|
|
4047
|
-
const state$
|
|
4052
|
+
const state$b = Object.create(null);
|
|
4048
4053
|
|
|
4049
4054
|
/**
|
|
4050
4055
|
* Register a listener for a specific event type
|
|
@@ -4054,13 +4059,13 @@ const state$a = Object.create(null);
|
|
|
4054
4059
|
const registerListener$1 = (listenerType, rpcId) => {
|
|
4055
4060
|
number(listenerType);
|
|
4056
4061
|
number(rpcId);
|
|
4057
|
-
if (!Object.hasOwn(state$
|
|
4058
|
-
state$
|
|
4062
|
+
if (!Object.hasOwn(state$b, listenerType)) {
|
|
4063
|
+
state$b[listenerType] = [];
|
|
4059
4064
|
}
|
|
4060
4065
|
|
|
4061
4066
|
// Avoid duplicate registrations
|
|
4062
|
-
if (!state$
|
|
4063
|
-
state$
|
|
4067
|
+
if (!state$b[listenerType].includes(rpcId)) {
|
|
4068
|
+
state$b[listenerType].push(rpcId);
|
|
4064
4069
|
}
|
|
4065
4070
|
};
|
|
4066
4071
|
|
|
@@ -4075,10 +4080,10 @@ const unregisterListener$1 = (listenerType, rpcId) => {
|
|
|
4075
4080
|
if (listenerType === EditorSelection$1) {
|
|
4076
4081
|
dispose$5(rpcId);
|
|
4077
4082
|
}
|
|
4078
|
-
if (Object.hasOwn(state$
|
|
4079
|
-
const index = state$
|
|
4083
|
+
if (Object.hasOwn(state$b, listenerType)) {
|
|
4084
|
+
const index = state$b[listenerType].indexOf(rpcId);
|
|
4080
4085
|
if (index !== -1) {
|
|
4081
|
-
state$
|
|
4086
|
+
state$b[listenerType].splice(index, 1);
|
|
4082
4087
|
}
|
|
4083
4088
|
}
|
|
4084
4089
|
};
|
|
@@ -4090,7 +4095,7 @@ const unregisterListener$1 = (listenerType, rpcId) => {
|
|
|
4090
4095
|
*/
|
|
4091
4096
|
const getListeners = listenerType => {
|
|
4092
4097
|
number(listenerType);
|
|
4093
|
-
return state$
|
|
4098
|
+
return state$b[listenerType] || [];
|
|
4094
4099
|
};
|
|
4095
4100
|
|
|
4096
4101
|
/**
|
|
@@ -4189,36 +4194,36 @@ const splitLines = lines => {
|
|
|
4189
4194
|
return lines.split('\n');
|
|
4190
4195
|
};
|
|
4191
4196
|
|
|
4192
|
-
const state$
|
|
4197
|
+
const state$a = {};
|
|
4193
4198
|
const create$a = () => create$g({
|
|
4194
4199
|
commandMap: {},
|
|
4195
4200
|
send: port => invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, 'FileSystem.connect')
|
|
4196
4201
|
});
|
|
4197
|
-
const invoke$
|
|
4198
|
-
state$
|
|
4202
|
+
const invoke$b = async (method, ...args) => {
|
|
4203
|
+
state$a.rpcPromise ||= create$a();
|
|
4199
4204
|
let rpc;
|
|
4200
4205
|
try {
|
|
4201
4206
|
const {
|
|
4202
4207
|
rpcPromise
|
|
4203
|
-
} = state$
|
|
4208
|
+
} = state$a;
|
|
4204
4209
|
rpc = await rpcPromise;
|
|
4205
4210
|
} catch (error) {
|
|
4206
|
-
delete state$
|
|
4211
|
+
delete state$a.rpcPromise;
|
|
4207
4212
|
throw error;
|
|
4208
4213
|
}
|
|
4209
4214
|
return rpc.invoke(method, ...args);
|
|
4210
4215
|
};
|
|
4211
4216
|
|
|
4212
|
-
const invoke$
|
|
4213
|
-
return applicationId === undefined ? invoke$
|
|
4217
|
+
const invoke$a = async (applicationId, method, ...args) => {
|
|
4218
|
+
return applicationId === undefined ? invoke$e(method, ...args) : invoke$e('Application.execute', applicationId, method, ...args);
|
|
4214
4219
|
};
|
|
4215
4220
|
const readFile$1 = async (applicationId, uri) => {
|
|
4216
|
-
return applicationId === undefined ? invoke$
|
|
4221
|
+
return applicationId === undefined ? invoke$b('FileSystem.readFile', uri) : invoke$b('ApplicationFileSystem.execute', applicationId, 'readFile', uri);
|
|
4217
4222
|
};
|
|
4218
4223
|
|
|
4219
4224
|
const notifyTabModifiedStatusChange = async (uri, modified, applicationId) => {
|
|
4220
4225
|
try {
|
|
4221
|
-
await invoke$
|
|
4226
|
+
await invoke$a(applicationId, 'Main.handleModifiedStatusChange', uri, modified);
|
|
4222
4227
|
} catch {
|
|
4223
4228
|
// ignore
|
|
4224
4229
|
}
|
|
@@ -4320,7 +4325,7 @@ const transformDiagnostics = (diagnostics, changes) => {
|
|
|
4320
4325
|
});
|
|
4321
4326
|
};
|
|
4322
4327
|
|
|
4323
|
-
const queues = {};
|
|
4328
|
+
const queues$1 = {};
|
|
4324
4329
|
const enqueue = async (uid, callback) => {
|
|
4325
4330
|
const instance = get$8(uid);
|
|
4326
4331
|
if (!instance) {
|
|
@@ -4331,12 +4336,12 @@ const enqueue = async (uid, callback) => {
|
|
|
4331
4336
|
uri
|
|
4332
4337
|
} = instance.newState;
|
|
4333
4338
|
const key = JSON.stringify([applicationId ?? null, uri || uid]);
|
|
4334
|
-
const previous = queues[key];
|
|
4339
|
+
const previous = queues$1[key];
|
|
4335
4340
|
const {
|
|
4336
4341
|
promise,
|
|
4337
4342
|
resolve
|
|
4338
4343
|
} = Promise.withResolvers();
|
|
4339
|
-
queues[key] = promise;
|
|
4344
|
+
queues$1[key] = promise;
|
|
4340
4345
|
if (previous) {
|
|
4341
4346
|
await previous;
|
|
4342
4347
|
}
|
|
@@ -4344,15 +4349,15 @@ const enqueue = async (uid, callback) => {
|
|
|
4344
4349
|
return await callback();
|
|
4345
4350
|
} finally {
|
|
4346
4351
|
resolve();
|
|
4347
|
-
if (queues[key] === promise) {
|
|
4348
|
-
delete queues[key];
|
|
4352
|
+
if (queues$1[key] === promise) {
|
|
4353
|
+
delete queues$1[key];
|
|
4349
4354
|
}
|
|
4350
4355
|
}
|
|
4351
4356
|
};
|
|
4352
4357
|
|
|
4353
4358
|
const logError = async (error, prefix) => {
|
|
4354
|
-
const prettyError = await invoke$
|
|
4355
|
-
await invoke$
|
|
4359
|
+
const prettyError = await invoke$i('Errors.prepare', error);
|
|
4360
|
+
await invoke$i('Errors.print', prettyError, prefix);
|
|
4356
4361
|
};
|
|
4357
4362
|
const logFallback = (error, prefix) => {
|
|
4358
4363
|
if (prefix) {
|
|
@@ -4370,8 +4375,8 @@ const handleError$1 = async (error, prefix = '') => {
|
|
|
4370
4375
|
}
|
|
4371
4376
|
};
|
|
4372
4377
|
|
|
4373
|
-
const invoke$
|
|
4374
|
-
return applicationId === undefined ? invoke$
|
|
4378
|
+
const invoke$9 = async (applicationId, method, ...args) => {
|
|
4379
|
+
return applicationId === undefined ? invoke$h(method, ...args) : invoke$h('Extensions.invokeForApplication', applicationId, method, ...args);
|
|
4375
4380
|
};
|
|
4376
4381
|
const invokeAndTransfer = async (applicationId, method, ...args) => {
|
|
4377
4382
|
return applicationId === undefined ? invokeAndTransfer$2(method, ...args) : invokeAndTransfer$2('Extensions.invokeForApplication', applicationId, method, ...args);
|
|
@@ -4472,7 +4477,7 @@ const getVisibleDiagnostics = async (editor, diagnostics) => {
|
|
|
4472
4477
|
return visibleDiagnostics;
|
|
4473
4478
|
};
|
|
4474
4479
|
|
|
4475
|
-
const invoke$
|
|
4480
|
+
const invoke$8 = (...args) => invoke$e(...args);
|
|
4476
4481
|
|
|
4477
4482
|
/**
|
|
4478
4483
|
* Merges link decorations with diagnostic decorations
|
|
@@ -4532,7 +4537,7 @@ const handleError = async (error, editor) => {
|
|
|
4532
4537
|
};
|
|
4533
4538
|
const notifyDiagnosticsChange = async (uri, applicationId) => {
|
|
4534
4539
|
try {
|
|
4535
|
-
await invoke$
|
|
4540
|
+
await invoke$a(applicationId, 'Layout.handleDiagnosticsChange', uri);
|
|
4536
4541
|
} catch {
|
|
4537
4542
|
// Older renderer workers do not support diagnostics change listeners.
|
|
4538
4543
|
}
|
|
@@ -4586,7 +4591,7 @@ const commitDiagnostics = async (editor, generation, diagnostics, onAccepted) =>
|
|
|
4586
4591
|
set$a(editor.id, latest.oldState, newEditor);
|
|
4587
4592
|
requestDiagnosticSnapshots.set(editor.id, diagnostics);
|
|
4588
4593
|
onAccepted?.();
|
|
4589
|
-
await invoke$
|
|
4594
|
+
await invoke$8('Editor.renderPending', newEditor.id);
|
|
4590
4595
|
await notifyDiagnosticsChange(newEditor.uri, newEditor.applicationId);
|
|
4591
4596
|
return newEditor;
|
|
4592
4597
|
})) ?? editor;
|
|
@@ -5500,7 +5505,7 @@ const execute = async ({
|
|
|
5500
5505
|
return noProviderFoundResult;
|
|
5501
5506
|
}
|
|
5502
5507
|
const textDocument = getTextDocument$2(editor);
|
|
5503
|
-
const result = await invoke$
|
|
5508
|
+
const result = await invoke$9(editor.applicationId, 'Extensions.executeLanguageProvider', kind, method, textDocument, ...args);
|
|
5504
5509
|
if (!result.found) {
|
|
5505
5510
|
return noProviderFoundResult;
|
|
5506
5511
|
}
|
|
@@ -5556,7 +5561,7 @@ const getEditorGutterDecorations = async editor => {
|
|
|
5556
5561
|
uri: editor.uri
|
|
5557
5562
|
};
|
|
5558
5563
|
try {
|
|
5559
|
-
const results = await invoke$
|
|
5564
|
+
const results = await invoke$9(editor.applicationId, 'Extensions.executeProvidersByEvent', 'onEditorGutterDecoration', 'ExtensionApi.executeEditorGutterDecorationProvider', textDocument);
|
|
5560
5565
|
return getProviderDecorations$1(results);
|
|
5561
5566
|
} catch {
|
|
5562
5567
|
return [];
|
|
@@ -5592,7 +5597,7 @@ const getEditorTextDecorations = async editor => {
|
|
|
5592
5597
|
});
|
|
5593
5598
|
}
|
|
5594
5599
|
try {
|
|
5595
|
-
const results = await invoke$
|
|
5600
|
+
const results = await invoke$9(editor.applicationId, 'Extensions.executeProvidersByEvent', 'onEditorTextDecoration', 'ExtensionApi.executeEditorTextDecorationProvider', {
|
|
5596
5601
|
languageId: editor.languageId,
|
|
5597
5602
|
selections,
|
|
5598
5603
|
text: getText$1(editor),
|
|
@@ -5667,7 +5672,7 @@ const getLightBulbRowIndex = async editor => {
|
|
|
5667
5672
|
};
|
|
5668
5673
|
const offset = getOffsetAtCursor$1(editor);
|
|
5669
5674
|
try {
|
|
5670
|
-
const actions = await invoke$
|
|
5675
|
+
const actions = await invoke$9(editor.applicationId, 'Extensions.executeCodeActionProviders', textDocument, offset);
|
|
5671
5676
|
return Array.isArray(actions) && actions.length > 0 ? rowIndex : -1;
|
|
5672
5677
|
} catch {
|
|
5673
5678
|
return -1;
|
|
@@ -6323,14 +6328,14 @@ const launchColorPickerWorker = async () => {
|
|
|
6323
6328
|
return launchWorker(name, url, undefined, getColorPickerWorkerCommandMap());
|
|
6324
6329
|
};
|
|
6325
6330
|
|
|
6326
|
-
const state$
|
|
6331
|
+
const state$9 = {};
|
|
6327
6332
|
const getOrCreate$2 = () => {
|
|
6328
|
-
if (!state$
|
|
6329
|
-
state$
|
|
6333
|
+
if (!state$9.workerPromise) {
|
|
6334
|
+
state$9.workerPromise = launchColorPickerWorker();
|
|
6330
6335
|
}
|
|
6331
|
-
return state$
|
|
6336
|
+
return state$9.workerPromise;
|
|
6332
6337
|
};
|
|
6333
|
-
const invoke$
|
|
6338
|
+
const invoke$7 = async (method, ...params) => {
|
|
6334
6339
|
const worker = await getOrCreate$2();
|
|
6335
6340
|
return await worker.invoke(method, ...params);
|
|
6336
6341
|
};
|
|
@@ -6344,10 +6349,10 @@ const loadContent$3 = async (state, parentUid) => {
|
|
|
6344
6349
|
x,
|
|
6345
6350
|
y
|
|
6346
6351
|
} = state;
|
|
6347
|
-
await invoke$
|
|
6348
|
-
await invoke$
|
|
6349
|
-
const diff = await invoke$
|
|
6350
|
-
const commands = await invoke$
|
|
6352
|
+
await invoke$7('ColorPicker.create', uid, x, y, width, height, parentUid);
|
|
6353
|
+
await invoke$7('ColorPicker.loadContent', uid, toColorPickerValue(value));
|
|
6354
|
+
const diff = await invoke$7('ColorPicker.diff2', uid);
|
|
6355
|
+
const commands = await invoke$7('ColorPicker.render2', uid, diff);
|
|
6351
6356
|
return {
|
|
6352
6357
|
...state,
|
|
6353
6358
|
commands
|
|
@@ -6656,11 +6661,11 @@ const applyLineEndings = (content, endOfLine) => {
|
|
|
6656
6661
|
};
|
|
6657
6662
|
|
|
6658
6663
|
const get$3 = async (key, applicationId) => {
|
|
6659
|
-
const value = applicationId === undefined ? await getPreference$1(key) : await invoke$
|
|
6664
|
+
const value = applicationId === undefined ? await getPreference$1(key) : await invoke$a(applicationId, 'Preferences.get', key);
|
|
6660
6665
|
return value;
|
|
6661
6666
|
};
|
|
6662
6667
|
const update = async settings => {
|
|
6663
|
-
await invoke$
|
|
6668
|
+
await invoke$e('Preferences.update', settings);
|
|
6664
6669
|
};
|
|
6665
6670
|
|
|
6666
6671
|
const createEditor = async ({
|
|
@@ -6853,6 +6858,7 @@ const createEditor = async ({
|
|
|
6853
6858
|
};
|
|
6854
6859
|
|
|
6855
6860
|
const createStandaloneEditor = async ({
|
|
6861
|
+
applicationId,
|
|
6856
6862
|
assetDir,
|
|
6857
6863
|
charWidth,
|
|
6858
6864
|
content,
|
|
@@ -6873,11 +6879,10 @@ const createStandaloneEditor = async ({
|
|
|
6873
6879
|
x,
|
|
6874
6880
|
y
|
|
6875
6881
|
}) => {
|
|
6876
|
-
createEditor2(id, uri, x, y, width, height, platform, assetDir);
|
|
6882
|
+
createEditor2(id, uri, x, y, width, height, platform, assetDir, undefined, undefined, undefined, applicationId);
|
|
6877
6883
|
const createdEditor = get$8(id).newState;
|
|
6878
6884
|
await loadTokenizer(languageId, tokenizePath);
|
|
6879
|
-
const tokenizerId =
|
|
6880
|
-
set$5(tokenizerId, getTokenizer(languageId));
|
|
6885
|
+
const tokenizerId = register(getTokenizer(languageId));
|
|
6881
6886
|
const configuredEditor = {
|
|
6882
6887
|
...createdEditor,
|
|
6883
6888
|
charWidth,
|
|
@@ -6999,7 +7004,7 @@ const diff2 = uid => {
|
|
|
6999
7004
|
|
|
7000
7005
|
const autoSaveDelay = 1000;
|
|
7001
7006
|
const pendingSaves = new Map();
|
|
7002
|
-
const state$
|
|
7007
|
+
const state$8 = {
|
|
7003
7008
|
nextToken: 0
|
|
7004
7009
|
};
|
|
7005
7010
|
const run = async (uid, token, save) => {
|
|
@@ -7010,7 +7015,7 @@ const run = async (uid, token, save) => {
|
|
|
7010
7015
|
};
|
|
7011
7016
|
const schedule$1 = (uid, save) => {
|
|
7012
7017
|
dispose$4(uid);
|
|
7013
|
-
const token = ++state$
|
|
7018
|
+
const token = ++state$8.nextToken;
|
|
7014
7019
|
const timeout = setTimeout(run, autoSaveDelay, uid, token, save);
|
|
7015
7020
|
pendingSaves.set(uid, {
|
|
7016
7021
|
timeout,
|
|
@@ -7043,12 +7048,12 @@ const clear$3 = editorUid => {
|
|
|
7043
7048
|
dismissals$1.delete(editorUid);
|
|
7044
7049
|
}
|
|
7045
7050
|
};
|
|
7046
|
-
const set$
|
|
7051
|
+
const set$5 = (editorUid, dismissal) => {
|
|
7047
7052
|
clear$3(editorUid);
|
|
7048
7053
|
dismissals$1.set(editorUid, dismissal);
|
|
7049
7054
|
};
|
|
7050
7055
|
|
|
7051
|
-
const state$
|
|
7056
|
+
const state$7 = {
|
|
7052
7057
|
editor: undefined,
|
|
7053
7058
|
timeout: -1,
|
|
7054
7059
|
token: 0,
|
|
@@ -7056,29 +7061,29 @@ const state$6 = {
|
|
|
7056
7061
|
y: 0
|
|
7057
7062
|
};
|
|
7058
7063
|
const get$2 = () => {
|
|
7059
|
-
return state$
|
|
7064
|
+
return state$7;
|
|
7060
7065
|
};
|
|
7061
|
-
const set$
|
|
7062
|
-
state$
|
|
7063
|
-
state$
|
|
7064
|
-
state$
|
|
7065
|
-
state$
|
|
7066
|
-
state$
|
|
7066
|
+
const set$4 = (editor, timeout, x, y, token) => {
|
|
7067
|
+
state$7.editor = editor;
|
|
7068
|
+
state$7.timeout = timeout;
|
|
7069
|
+
state$7.token = token;
|
|
7070
|
+
state$7.x = x;
|
|
7071
|
+
state$7.y = y;
|
|
7067
7072
|
};
|
|
7068
7073
|
const clear$2 = editorUid => {
|
|
7069
7074
|
const {
|
|
7070
7075
|
editor,
|
|
7071
7076
|
timeout
|
|
7072
|
-
} = state$
|
|
7077
|
+
} = state$7;
|
|
7073
7078
|
if (editorUid !== undefined && editor?.uid !== editorUid) {
|
|
7074
7079
|
return;
|
|
7075
7080
|
}
|
|
7076
7081
|
if (timeout !== -1) {
|
|
7077
7082
|
clearTimeout(timeout);
|
|
7078
7083
|
}
|
|
7079
|
-
state$
|
|
7080
|
-
state$
|
|
7081
|
-
state$
|
|
7084
|
+
state$7.editor = undefined;
|
|
7085
|
+
state$7.timeout = -1;
|
|
7086
|
+
state$7.token++;
|
|
7082
7087
|
};
|
|
7083
7088
|
|
|
7084
7089
|
const dismissals = new Map();
|
|
@@ -7090,7 +7095,7 @@ const clear$1 = editorUid => {
|
|
|
7090
7095
|
clearTimeout(dismissal.timeout);
|
|
7091
7096
|
dismissals.delete(editorUid);
|
|
7092
7097
|
};
|
|
7093
|
-
const set$
|
|
7098
|
+
const set$3 = (editorUid, dismissal) => {
|
|
7094
7099
|
clear$1(editorUid);
|
|
7095
7100
|
dismissals.set(editorUid, dismissal);
|
|
7096
7101
|
};
|
|
@@ -7170,7 +7175,7 @@ const launchRenameWorker = async () => {
|
|
|
7170
7175
|
};
|
|
7171
7176
|
|
|
7172
7177
|
let workerPromise;
|
|
7173
|
-
const invoke$
|
|
7178
|
+
const invoke$6 = async (method, ...params) => {
|
|
7174
7179
|
// eslint-disable-next-line unicorn/no-top-level-assignment-in-function
|
|
7175
7180
|
workerPromise ||= launchRenameWorker();
|
|
7176
7181
|
const worker = await workerPromise;
|
|
@@ -7194,7 +7199,7 @@ const textAppendPaths = new Map();
|
|
|
7194
7199
|
const get$1 = uid => {
|
|
7195
7200
|
return renderedDoms.get(uid);
|
|
7196
7201
|
};
|
|
7197
|
-
const set$
|
|
7202
|
+
const set$2 = (uid, dom, paths) => {
|
|
7198
7203
|
renderedDoms.set(uid, dom);
|
|
7199
7204
|
setTextAppendPaths(uid, paths);
|
|
7200
7205
|
};
|
|
@@ -7302,7 +7307,7 @@ const disposeEditor = async editorUid => {
|
|
|
7302
7307
|
clearDiagnosticRequestState(editorUid);
|
|
7303
7308
|
dispose$6(editorUid);
|
|
7304
7309
|
try {
|
|
7305
|
-
await invoke$
|
|
7310
|
+
await invoke$a(editor.applicationId, 'Layout.handleDiagnosticsChange', editor.uri);
|
|
7306
7311
|
} catch {
|
|
7307
7312
|
// Older renderer workers do not support diagnostics change listeners.
|
|
7308
7313
|
}
|
|
@@ -7314,11 +7319,11 @@ const disposeEditor = async editorUid => {
|
|
|
7314
7319
|
dispose$1(editorUid);
|
|
7315
7320
|
const pending = [];
|
|
7316
7321
|
if (getEnabled$1()) {
|
|
7317
|
-
pending.push(invoke$
|
|
7322
|
+
pending.push(invoke$c('TextDocument.dispose', editor.id));
|
|
7318
7323
|
}
|
|
7319
7324
|
for (const widget of editor.widgets) {
|
|
7320
7325
|
if (widget.id === ColorPicker$2) {
|
|
7321
|
-
pending.push(invoke$
|
|
7326
|
+
pending.push(invoke$7('ColorPicker.dispose', widget.newState.uid));
|
|
7322
7327
|
}
|
|
7323
7328
|
}
|
|
7324
7329
|
const commands = renderWidgets$1(editor, {
|
|
@@ -7373,6 +7378,29 @@ const hasWidget = (widgets, id) => {
|
|
|
7373
7378
|
return false;
|
|
7374
7379
|
};
|
|
7375
7380
|
|
|
7381
|
+
const getWidgetIndex = (widgets, widgetId, uid) => {
|
|
7382
|
+
return widgets.findIndex(widget => widget.id === widgetId && widget.newState.uid === uid);
|
|
7383
|
+
};
|
|
7384
|
+
const hydrateWidget = (editor, widgetId, uid, newState) => {
|
|
7385
|
+
const widgetIndex = getWidgetIndex(editor.widgets, widgetId, uid);
|
|
7386
|
+
if (widgetIndex === -1) {
|
|
7387
|
+
return editor;
|
|
7388
|
+
}
|
|
7389
|
+
const widget = editor.widgets[widgetIndex];
|
|
7390
|
+
const newWidget = {
|
|
7391
|
+
...widget,
|
|
7392
|
+
newState,
|
|
7393
|
+
oldState: widget.newState
|
|
7394
|
+
};
|
|
7395
|
+
return {
|
|
7396
|
+
...editor,
|
|
7397
|
+
widgets: [...editor.widgets.slice(0, widgetIndex), newWidget, ...editor.widgets.slice(widgetIndex + 1)]
|
|
7398
|
+
};
|
|
7399
|
+
};
|
|
7400
|
+
const getLatestEditor = (uid, fallback) => {
|
|
7401
|
+
const instance = get$8(uid);
|
|
7402
|
+
return instance?.newState || fallback;
|
|
7403
|
+
};
|
|
7376
7404
|
const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGenerator, fullFocus) => {
|
|
7377
7405
|
const {
|
|
7378
7406
|
widgets = []
|
|
@@ -7382,35 +7410,75 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
|
|
|
7382
7410
|
}
|
|
7383
7411
|
const widgetRevision = next(editor.uid);
|
|
7384
7412
|
const widget = factory();
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7413
|
+
const initialState = {
|
|
7414
|
+
...widget.newState,
|
|
7415
|
+
editorUid: editor.uid
|
|
7416
|
+
};
|
|
7417
|
+
const widgetUid = initialState.uid;
|
|
7418
|
+
const stagedWidget = {
|
|
7419
|
+
...widget,
|
|
7420
|
+
newState: initialState
|
|
7421
|
+
};
|
|
7422
|
+
const newWidgets = [...widgets, stagedWidget];
|
|
7423
|
+
const stagedEditor = {
|
|
7424
|
+
...editor,
|
|
7425
|
+
additionalFocus: fullFocus ? 0 : focusKey,
|
|
7426
|
+
focus: fullFocus ? focusKey : FocusEditorText$1,
|
|
7427
|
+
focused: !fullFocus,
|
|
7428
|
+
widgetRevision,
|
|
7429
|
+
widgets: newWidgets
|
|
7430
|
+
};
|
|
7431
|
+
if (fullFocus) {
|
|
7432
|
+
// Staging changes pending state; only rendering may advance the mounted baseline.
|
|
7433
|
+
set$a(editor.uid, get$8(editor.uid)?.oldState || editor, stagedEditor);
|
|
7434
|
+
}
|
|
7435
|
+
const newState = await newStateGenerator(initialState, editor.uid);
|
|
7388
7436
|
if (!newState) {
|
|
7437
|
+
if (get(editor.uid) !== widgetRevision) {
|
|
7438
|
+
return getLatestEditor(editor.uid, editor);
|
|
7439
|
+
}
|
|
7440
|
+
if (fullFocus) {
|
|
7441
|
+
const latestEditor = getLatestEditor(editor.uid, stagedEditor);
|
|
7442
|
+
if (latestEditor === stagedEditor) {
|
|
7443
|
+
set$a(editor.uid, get$8(editor.uid)?.oldState || editor, editor);
|
|
7444
|
+
}
|
|
7445
|
+
return latestEditor === stagedEditor ? editor : latestEditor;
|
|
7446
|
+
}
|
|
7389
7447
|
return editor;
|
|
7390
7448
|
}
|
|
7449
|
+
const latestState = {
|
|
7450
|
+
...newState,
|
|
7451
|
+
editorUid: editor.uid
|
|
7452
|
+
};
|
|
7453
|
+
if (fullFocus) {
|
|
7454
|
+
const currentEditor = getLatestEditor(editor.uid, stagedEditor);
|
|
7455
|
+
// A concurrent editor update based on the pre-staging state can replace the
|
|
7456
|
+
// staged widget list. Restore it only when the original widget list is still
|
|
7457
|
+
// current; a changed list may represent an explicit close.
|
|
7458
|
+
const latestEditor = currentEditor.widgets === editor.widgets ? {
|
|
7459
|
+
...currentEditor,
|
|
7460
|
+
widgets: newWidgets
|
|
7461
|
+
} : currentEditor;
|
|
7462
|
+
const hydratedEditor = hydrateWidget(latestEditor, widgetId, widgetUid, latestState);
|
|
7463
|
+
if (hydratedEditor !== latestEditor) {
|
|
7464
|
+
set$a(editor.uid, get$8(editor.uid)?.oldState || editor, hydratedEditor);
|
|
7465
|
+
}
|
|
7466
|
+
return hydratedEditor;
|
|
7467
|
+
}
|
|
7391
7468
|
if (get(editor.uid) !== widgetRevision) {
|
|
7392
|
-
return
|
|
7469
|
+
return getLatestEditor(editor.uid, editor);
|
|
7393
7470
|
}
|
|
7394
|
-
// @ts-ignore
|
|
7395
|
-
newState.editorUid = editor.uid;
|
|
7396
7471
|
const latestWidget = {
|
|
7397
7472
|
...widget,
|
|
7398
|
-
newState
|
|
7473
|
+
newState: latestState
|
|
7399
7474
|
};
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
...editor,
|
|
7404
|
-
additionalFocus: fullFocus ? 0 : focusKey,
|
|
7405
|
-
focus: fullFocus ? focusKey : FocusEditorText$1,
|
|
7406
|
-
focused: newFocus,
|
|
7407
|
-
widgetRevision,
|
|
7408
|
-
widgets: newWidgets
|
|
7475
|
+
return {
|
|
7476
|
+
...stagedEditor,
|
|
7477
|
+
widgets: [...widgets, latestWidget]
|
|
7409
7478
|
};
|
|
7410
|
-
return newEditor;
|
|
7411
7479
|
};
|
|
7412
7480
|
|
|
7413
|
-
const state$
|
|
7481
|
+
const state$6 = {
|
|
7414
7482
|
configured: false,
|
|
7415
7483
|
lastId: -1,
|
|
7416
7484
|
nextId: 0
|
|
@@ -7418,23 +7486,23 @@ const state$5 = {
|
|
|
7418
7486
|
const configure = (start, end) => {
|
|
7419
7487
|
const {
|
|
7420
7488
|
configured
|
|
7421
|
-
} = state$
|
|
7489
|
+
} = state$6;
|
|
7422
7490
|
if (configured) {
|
|
7423
7491
|
throw new Error('Component id range is already configured');
|
|
7424
7492
|
}
|
|
7425
7493
|
if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start <= 0 || end < start) {
|
|
7426
7494
|
throw new Error('Invalid component id range');
|
|
7427
7495
|
}
|
|
7428
|
-
state$
|
|
7429
|
-
state$
|
|
7430
|
-
state$
|
|
7496
|
+
state$6.nextId = start;
|
|
7497
|
+
state$6.lastId = end;
|
|
7498
|
+
state$6.configured = true;
|
|
7431
7499
|
};
|
|
7432
7500
|
const create$8 = () => {
|
|
7433
7501
|
const {
|
|
7434
7502
|
configured,
|
|
7435
7503
|
lastId,
|
|
7436
7504
|
nextId
|
|
7437
|
-
} = state$
|
|
7505
|
+
} = state$6;
|
|
7438
7506
|
if (!configured) {
|
|
7439
7507
|
// Compatibility with renderer versions that do not assign worker id ranges.
|
|
7440
7508
|
return Math.random();
|
|
@@ -7442,7 +7510,7 @@ const create$8 = () => {
|
|
|
7442
7510
|
if (nextId > lastId) {
|
|
7443
7511
|
throw new Error('Component id range exhausted');
|
|
7444
7512
|
}
|
|
7445
|
-
return state$
|
|
7513
|
+
return state$6.nextId++;
|
|
7446
7514
|
};
|
|
7447
7515
|
|
|
7448
7516
|
const create$7 = () => {
|
|
@@ -7470,7 +7538,7 @@ const create$7 = () => {
|
|
|
7470
7538
|
};
|
|
7471
7539
|
|
|
7472
7540
|
const {
|
|
7473
|
-
invoke: invoke$
|
|
7541
|
+
invoke: invoke$5,
|
|
7474
7542
|
setFactory
|
|
7475
7543
|
} = createLazyRpc(CompletionWorker);
|
|
7476
7544
|
|
|
@@ -7536,7 +7604,7 @@ const updateWidget = (editor, widgetId, newState) => {
|
|
|
7536
7604
|
|
|
7537
7605
|
const disposeCompletion = async uid => {
|
|
7538
7606
|
try {
|
|
7539
|
-
await invoke$
|
|
7607
|
+
await invoke$5('Completions.dispose', uid);
|
|
7540
7608
|
} catch {
|
|
7541
7609
|
// A completion worker may already have disposed this state during shutdown.
|
|
7542
7610
|
}
|
|
@@ -7556,14 +7624,14 @@ const newStateGenerator$4 = async (state, parentUid, markCreated, automatic) =>
|
|
|
7556
7624
|
applicationId,
|
|
7557
7625
|
languageId
|
|
7558
7626
|
} = newState;
|
|
7559
|
-
await invoke$
|
|
7627
|
+
await invoke$5('Completions.create', uid, x, y, width, height, parentUid, languageId, applicationId);
|
|
7560
7628
|
markCreated();
|
|
7561
|
-
await invoke$
|
|
7562
|
-
if (automatic && !(await invoke$
|
|
7629
|
+
await invoke$5('Completions.loadContent', uid, automatic);
|
|
7630
|
+
if (automatic && !(await invoke$5('Completions.hasItems', uid))) {
|
|
7563
7631
|
return undefined;
|
|
7564
7632
|
}
|
|
7565
|
-
const diff = await invoke$
|
|
7566
|
-
const commands = await invoke$
|
|
7633
|
+
const diff = await invoke$5('Completions.diff2', uid);
|
|
7634
|
+
const commands = await invoke$5('Completions.render2', uid, diff);
|
|
7567
7635
|
return {
|
|
7568
7636
|
...state,
|
|
7569
7637
|
automatic,
|
|
@@ -7576,15 +7644,15 @@ const openCompletion = async (editor, automatic = false) => {
|
|
|
7576
7644
|
const {
|
|
7577
7645
|
uid
|
|
7578
7646
|
} = widget.newState;
|
|
7579
|
-
await invoke$
|
|
7647
|
+
await invoke$5('Completions.loadContent', uid, automatic);
|
|
7580
7648
|
if (!isCurrent$1(editor, get$8(editor.uid)?.newState)) {
|
|
7581
7649
|
return get$8(editor.uid)?.newState || editor;
|
|
7582
7650
|
}
|
|
7583
|
-
if (automatic && !(await invoke$
|
|
7651
|
+
if (automatic && !(await invoke$5('Completions.hasItems', uid))) {
|
|
7584
7652
|
return closeCompletion(editor);
|
|
7585
7653
|
}
|
|
7586
|
-
const diff = await invoke$
|
|
7587
|
-
const commands = await invoke$
|
|
7654
|
+
const diff = await invoke$5('Completions.diff2', uid);
|
|
7655
|
+
const commands = await invoke$5('Completions.render2', uid, diff);
|
|
7588
7656
|
return updateWidget(editor, Completion, {
|
|
7589
7657
|
...widget.newState,
|
|
7590
7658
|
automatic,
|
|
@@ -8257,7 +8325,7 @@ const getFormattingEdits = async editor => {
|
|
|
8257
8325
|
text: getText$1(editor),
|
|
8258
8326
|
uri: editor.uri
|
|
8259
8327
|
};
|
|
8260
|
-
return invoke$
|
|
8328
|
+
return invoke$9(editor.applicationId, 'Extensions.executeFormattingProvider', textDocument);
|
|
8261
8329
|
};
|
|
8262
8330
|
|
|
8263
8331
|
const expectedErrorMessage$1 = 'Failed to execute formatting provider: FormattingError:';
|
|
@@ -8500,9 +8568,9 @@ const editorShowMessage = async (editor, rowIndex, columnIndex, message, _isErro
|
|
|
8500
8568
|
widgets: removeEditorWidget(latestEditor.widgets, Message)
|
|
8501
8569
|
};
|
|
8502
8570
|
set$a(editor.uid, latestEditor, editorWithoutMessage);
|
|
8503
|
-
await invoke$
|
|
8571
|
+
await invoke$e('Editor.renderPending', editor.uid);
|
|
8504
8572
|
}, editor.messageDelay ?? defaultMessageDelay);
|
|
8505
|
-
set$
|
|
8573
|
+
set$3(editor.uid, {
|
|
8506
8574
|
timeout
|
|
8507
8575
|
});
|
|
8508
8576
|
}
|
|
@@ -8553,7 +8621,7 @@ const getNewEditor = async (editor, skipFormatting = false) => {
|
|
|
8553
8621
|
};
|
|
8554
8622
|
|
|
8555
8623
|
const isReadonlyFile = async (uri, applicationId) => {
|
|
8556
|
-
return invoke$
|
|
8624
|
+
return invoke$a(applicationId, 'FileSystem.isReadonly', uri);
|
|
8557
8625
|
};
|
|
8558
8626
|
|
|
8559
8627
|
const isUntitledFile = uri => {
|
|
@@ -8561,7 +8629,7 @@ const isUntitledFile = uri => {
|
|
|
8561
8629
|
};
|
|
8562
8630
|
|
|
8563
8631
|
const saveNormalFile = async (uri, content, applicationId) => {
|
|
8564
|
-
await invoke$
|
|
8632
|
+
await invoke$a(applicationId, 'FileSystem.writeFile', uri, content, 'utf8', false);
|
|
8565
8633
|
};
|
|
8566
8634
|
|
|
8567
8635
|
const showFilePicker = async platform => {
|
|
@@ -8569,7 +8637,7 @@ const showFilePicker = async platform => {
|
|
|
8569
8637
|
const {
|
|
8570
8638
|
canceled,
|
|
8571
8639
|
filePath
|
|
8572
|
-
} = await invoke$
|
|
8640
|
+
} = await invoke$g('Open.showSaveDialog', dialogTitle, [], platform);
|
|
8573
8641
|
if (canceled) {
|
|
8574
8642
|
return '';
|
|
8575
8643
|
}
|
|
@@ -8581,8 +8649,8 @@ const saveUntitledFile = async (uri, content, platform, applicationId) => {
|
|
|
8581
8649
|
if (!filePath) {
|
|
8582
8650
|
return;
|
|
8583
8651
|
}
|
|
8584
|
-
await invoke$
|
|
8585
|
-
await invoke$
|
|
8652
|
+
await invoke$a(applicationId, 'FileSystem.writeFile', filePath, content);
|
|
8653
|
+
await invoke$a(applicationId, 'Layout.handleWorkspaceRefresh');
|
|
8586
8654
|
return filePath;
|
|
8587
8655
|
};
|
|
8588
8656
|
|
|
@@ -8592,7 +8660,7 @@ const isPermissionDeniedError = error => {
|
|
|
8592
8660
|
};
|
|
8593
8661
|
const showSaveErrorDialog = async error => {
|
|
8594
8662
|
if (isPermissionDeniedError(error)) {
|
|
8595
|
-
await invoke$
|
|
8663
|
+
await invoke$k('ElectronDialog.showMessageBox', {
|
|
8596
8664
|
buttons: ['OK'],
|
|
8597
8665
|
defaultId: 0,
|
|
8598
8666
|
message: "You don't have permission to save changes to this file.",
|
|
@@ -8601,7 +8669,7 @@ const showSaveErrorDialog = async error => {
|
|
|
8601
8669
|
});
|
|
8602
8670
|
return;
|
|
8603
8671
|
}
|
|
8604
|
-
await invoke$
|
|
8672
|
+
await invoke$k('ElectronDialog.showMessageBox', {
|
|
8605
8673
|
buttons: ['OK'],
|
|
8606
8674
|
defaultId: 0,
|
|
8607
8675
|
detail: error.message,
|
|
@@ -8697,7 +8765,7 @@ const refresh = async request => {
|
|
|
8697
8765
|
return true;
|
|
8698
8766
|
});
|
|
8699
8767
|
if (changed) {
|
|
8700
|
-
await invoke$
|
|
8768
|
+
await invoke$e('Editor.renderPending', snapshot.uid);
|
|
8701
8769
|
}
|
|
8702
8770
|
}
|
|
8703
8771
|
} catch (error) {
|
|
@@ -8768,114 +8836,117 @@ const saveAfterDelay = async (uid, token) => {
|
|
|
8768
8836
|
});
|
|
8769
8837
|
await save(uid);
|
|
8770
8838
|
if (didSave) {
|
|
8771
|
-
await invoke$
|
|
8839
|
+
await invoke$e('Editor.renderPending', uid);
|
|
8772
8840
|
}
|
|
8773
8841
|
};
|
|
8774
8842
|
|
|
8775
8843
|
// TODO wrap commands globally, not per editor
|
|
8776
8844
|
// TODO only store editor state in editor worker, not in renderer worker also
|
|
8777
8845
|
|
|
8778
|
-
const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true) =>
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
newEditor
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
|
|
8838
|
-
|
|
8839
|
-
const
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
8862
|
-
|
|
8863
|
-
|
|
8864
|
-
|
|
8865
|
-
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
|
|
8846
|
+
const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true) => {
|
|
8847
|
+
const command = async (uid, ...args) => {
|
|
8848
|
+
return enqueue(uid, async () => {
|
|
8849
|
+
const oldInstance = get$8(uid);
|
|
8850
|
+
if (!oldInstance) {
|
|
8851
|
+
return undefined;
|
|
8852
|
+
}
|
|
8853
|
+
const state = oldInstance.newState;
|
|
8854
|
+
const {
|
|
8855
|
+
cursorUndoStack,
|
|
8856
|
+
endOfLine,
|
|
8857
|
+
initial,
|
|
8858
|
+
insertSpaces,
|
|
8859
|
+
isSelecting,
|
|
8860
|
+
lifecycle,
|
|
8861
|
+
lines,
|
|
8862
|
+
modified,
|
|
8863
|
+
redoStack,
|
|
8864
|
+
selections,
|
|
8865
|
+
undoStack,
|
|
8866
|
+
uri
|
|
8867
|
+
} = state;
|
|
8868
|
+
const commandResult = await fn(state, ...args);
|
|
8869
|
+
let newEditor = !preservesTypingCoalescing && commandResult.canCoalesceTyping ? {
|
|
8870
|
+
...commandResult,
|
|
8871
|
+
canCoalesceTyping: false
|
|
8872
|
+
} : commandResult;
|
|
8873
|
+
if (lines !== newEditor.lines && newEditor.cursorUndoStack?.length) {
|
|
8874
|
+
newEditor = {
|
|
8875
|
+
...newEditor,
|
|
8876
|
+
cursorUndoStack: []
|
|
8877
|
+
};
|
|
8878
|
+
} else if (selections && newEditor.selections && !isSelecting && newEditor.cursorUndoStack === cursorUndoStack && (!selectionsEqual(selections, newEditor.selections) || newEditor.isSelecting)) {
|
|
8879
|
+
const previousCursorUndoStack = cursorUndoStack || [];
|
|
8880
|
+
newEditor = {
|
|
8881
|
+
...newEditor,
|
|
8882
|
+
cursorUndoStack: [...previousCursorUndoStack.slice(1 - cursorUndoLimit), new Uint32Array(selections)]
|
|
8883
|
+
};
|
|
8884
|
+
}
|
|
8885
|
+
if (state === newEditor || !get$8(uid) || lifecycle?.disposed || get$8(uid).newState.lifecycle !== lifecycle) {
|
|
8886
|
+
return returnState ? newEditor : undefined;
|
|
8887
|
+
}
|
|
8888
|
+
const deferGutterDecorations = !initial && uri === newEditor.uri && lines !== newEditor.lines && Boolean(newEditor.lifecycle);
|
|
8889
|
+
const newEditorWithDerivedState = await updateDerivedState(state, newEditor, deferGutterDecorations);
|
|
8890
|
+
if (!get$8(uid) || lifecycle?.disposed || get$8(uid).newState.lifecycle !== lifecycle) {
|
|
8891
|
+
return returnState ? newEditorWithDerivedState : undefined;
|
|
8892
|
+
}
|
|
8893
|
+
// Another command can commit before the renderer consumes this edit.
|
|
8894
|
+
// Keep its last rendered baseline, including renders completed while we awaited derived state.
|
|
8895
|
+
const renderedState = get$8(uid)?.oldState ?? oldInstance.oldState;
|
|
8896
|
+
set$a(uid, renderedState, newEditorWithDerivedState);
|
|
8897
|
+
await dispose$3();
|
|
8898
|
+
if (editorDiagnosticEffect.isActive(state, newEditorWithDerivedState)) {
|
|
8899
|
+
void editorDiagnosticEffect.apply(newEditorWithDerivedState);
|
|
8900
|
+
}
|
|
8901
|
+
const finalEditor = newEditorWithDerivedState;
|
|
8902
|
+
if (deferGutterDecorations) {
|
|
8903
|
+
schedule(finalEditor);
|
|
8904
|
+
}
|
|
8905
|
+
await notifyEditorStatusChange(state, finalEditor);
|
|
8906
|
+
if (!initial && uri === finalEditor.uri && (endOfLine !== finalEditor.endOfLine || insertSpaces !== finalEditor.insertSpaces || lines !== finalEditor.lines || modified !== finalEditor.modified || redoStack !== finalEditor.redoStack || undoStack !== finalEditor.undoStack)) {
|
|
8907
|
+
for (const key of getKeys$2()) {
|
|
8908
|
+
const otherUid = Number(key);
|
|
8909
|
+
const instance = get$8(otherUid);
|
|
8910
|
+
const editor = instance?.newState;
|
|
8911
|
+
if (otherUid === uid || !instance || !editor || editor.initial || editor.uri !== finalEditor.uri || editor.applicationId !== finalEditor.applicationId) {
|
|
8912
|
+
continue;
|
|
8913
|
+
}
|
|
8914
|
+
const synchronizedEditor = await updateDerivedState(editor, {
|
|
8915
|
+
...editor,
|
|
8916
|
+
decorations: finalEditor.decorations,
|
|
8917
|
+
diagnostics: finalEditor.diagnostics,
|
|
8918
|
+
endOfLine: finalEditor.endOfLine,
|
|
8919
|
+
incrementalEdits: emptyIncrementalEdits,
|
|
8920
|
+
insertSpaces: finalEditor.insertSpaces,
|
|
8921
|
+
invalidStartIndex: Math.min(editor.invalidStartIndex, finalEditor.invalidStartIndex),
|
|
8922
|
+
lines: finalEditor.lines,
|
|
8923
|
+
modified: finalEditor.modified,
|
|
8924
|
+
redoStack: finalEditor.redoStack,
|
|
8925
|
+
undoStack: finalEditor.undoStack,
|
|
8926
|
+
visualDecorations: finalEditor.visualDecorations
|
|
8927
|
+
}, deferGutterDecorations);
|
|
8928
|
+
const latest = get$8(otherUid);
|
|
8929
|
+
if (!latest || editor.lifecycle?.disposed || latest.newState.lifecycle !== editor.lifecycle) {
|
|
8930
|
+
continue;
|
|
8931
|
+
}
|
|
8932
|
+
set$a(otherUid, latest.oldState, synchronizedEditor);
|
|
8933
|
+
if (deferGutterDecorations) {
|
|
8934
|
+
schedule(synchronizedEditor);
|
|
8935
|
+
}
|
|
8936
|
+
if (editorDiagnosticEffect.isActive(editor, synchronizedEditor)) {
|
|
8937
|
+
void editorDiagnosticEffect.apply(synchronizedEditor);
|
|
8938
|
+
}
|
|
8869
8939
|
}
|
|
8870
8940
|
}
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
}
|
|
8941
|
+
if (lines !== finalEditor.lines && !isUntitledFile(finalEditor.uri)) {
|
|
8942
|
+
schedule$1(uid, token => saveAfterDelay(uid, token));
|
|
8943
|
+
} else if (modified && !finalEditor.modified) {
|
|
8944
|
+
dispose$4(uid);
|
|
8945
|
+
}
|
|
8946
|
+
return returnState ? finalEditor : undefined;
|
|
8947
|
+
});
|
|
8948
|
+
};
|
|
8949
|
+
return command;
|
|
8879
8950
|
};
|
|
8880
8951
|
const wrapFocusCommand$1 = (fn, returnState = true) => {
|
|
8881
8952
|
const command = wrapCommand$1((editor, widgetRevision) => {
|
|
@@ -8884,18 +8955,19 @@ const wrapFocusCommand$1 = (fn, returnState = true) => {
|
|
|
8884
8955
|
}
|
|
8885
8956
|
return fn(editor);
|
|
8886
8957
|
}, false, returnState);
|
|
8887
|
-
|
|
8958
|
+
const focusCommand = uid => {
|
|
8888
8959
|
// DOM focus events can arrive while a queued command is still opening a widget.
|
|
8889
8960
|
const widgetRevision = get$8(uid)?.newState.widgetRevision;
|
|
8890
8961
|
return command(uid, widgetRevision);
|
|
8891
8962
|
};
|
|
8963
|
+
return focusCommand;
|
|
8892
8964
|
};
|
|
8893
8965
|
|
|
8894
8966
|
// Mouse positions are replaceable; edits and explicit navigation remain ordered.
|
|
8895
8967
|
// Check before starting provider work and again before committing its result.
|
|
8896
8968
|
const wrapLatestCommand$1 = (fn, returnState = true) => {
|
|
8897
8969
|
const latest = new Map();
|
|
8898
|
-
|
|
8970
|
+
const latestCommand = async (uid, ...args) => {
|
|
8899
8971
|
const token = {};
|
|
8900
8972
|
latest.set(uid, token);
|
|
8901
8973
|
const command = wrapCommand$1(async editor => {
|
|
@@ -8909,12 +8981,13 @@ const wrapLatestCommand$1 = (fn, returnState = true) => {
|
|
|
8909
8981
|
if (latest.get(uid) === token) latest.delete(uid);
|
|
8910
8982
|
}
|
|
8911
8983
|
};
|
|
8984
|
+
return latestCommand;
|
|
8912
8985
|
};
|
|
8913
8986
|
|
|
8914
8987
|
// Optional provider work must not hold the editing queue while another worker responds.
|
|
8915
8988
|
const wrapDeferredCommand$1 = (fn, returnState = true) => {
|
|
8916
8989
|
const apply = wrapCommand$1((editor, snapshot, result) => merge(editor, snapshot, result), false, returnState);
|
|
8917
|
-
|
|
8990
|
+
const deferredCommand = async (uid, ...args) => {
|
|
8918
8991
|
const snapshot = await enqueue(uid, async () => get$8(uid)?.newState);
|
|
8919
8992
|
if (!snapshot) {
|
|
8920
8993
|
return undefined;
|
|
@@ -8922,6 +8995,7 @@ const wrapDeferredCommand$1 = (fn, returnState = true) => {
|
|
|
8922
8995
|
const result = await fn(snapshot, ...args);
|
|
8923
8996
|
return apply(uid, snapshot, result);
|
|
8924
8997
|
};
|
|
8998
|
+
return deferredCommand;
|
|
8925
8999
|
};
|
|
8926
9000
|
|
|
8927
9001
|
// TODO maybe use a separate worker for bulk edits and bulk edit history
|
|
@@ -8994,13 +9068,13 @@ const applyWorkspaceEdit = async (editor, changes) => {
|
|
|
8994
9068
|
currentEditor = await scheduleDocumentAndCursorsSelections(openEditor, textChanges);
|
|
8995
9069
|
} else {
|
|
8996
9070
|
await updateOpenEditor(openEditor.uid, textChanges);
|
|
8997
|
-
await invoke$
|
|
9071
|
+
await invoke$8('Editor.renderPending', openEditor.uid);
|
|
8998
9072
|
}
|
|
8999
9073
|
continue;
|
|
9000
9074
|
}
|
|
9001
9075
|
const text = await readFile$1(editor.applicationId, uri);
|
|
9002
9076
|
const newText = applyEditsToText(text, edits);
|
|
9003
|
-
await invoke$
|
|
9077
|
+
await invoke$a(editor.applicationId, 'FileSystem.writeFile', uri, newText);
|
|
9004
9078
|
}
|
|
9005
9079
|
return currentEditor;
|
|
9006
9080
|
};
|
|
@@ -9477,7 +9551,7 @@ const closeRename = async editor => {
|
|
|
9477
9551
|
return editor;
|
|
9478
9552
|
}
|
|
9479
9553
|
const renameWidget = widgets[renameWidgetIndex];
|
|
9480
|
-
await invoke$
|
|
9554
|
+
await invoke$6('Rename.close', renameWidget.newState.uid);
|
|
9481
9555
|
const latest = get$8(uid);
|
|
9482
9556
|
const {
|
|
9483
9557
|
newState
|
|
@@ -9597,12 +9671,12 @@ const closeColorPicker = editor => {
|
|
|
9597
9671
|
};
|
|
9598
9672
|
};
|
|
9599
9673
|
|
|
9600
|
-
const state$
|
|
9674
|
+
const state$5 = {
|
|
9601
9675
|
compositionText: '',
|
|
9602
9676
|
isComposing: false
|
|
9603
9677
|
};
|
|
9604
9678
|
const compositionStart = (editor, event) => {
|
|
9605
|
-
state$
|
|
9679
|
+
state$5.isComposing = true;
|
|
9606
9680
|
return editor;
|
|
9607
9681
|
};
|
|
9608
9682
|
const getCompositionChanges = (selections, data) => {
|
|
@@ -9612,9 +9686,9 @@ const getCompositionChanges = (selections, data) => {
|
|
|
9612
9686
|
const selectionStartColumn = selections[i + 1];
|
|
9613
9687
|
const selectionEndRow = selections[i + 2];
|
|
9614
9688
|
const selectionEndColumn = selections[i + 3];
|
|
9615
|
-
const startColumnIndex = selectionStartColumn - state$
|
|
9689
|
+
const startColumnIndex = selectionStartColumn - state$5.compositionText.length;
|
|
9616
9690
|
changes.push({
|
|
9617
|
-
deleted: [state$
|
|
9691
|
+
deleted: [state$5.compositionText],
|
|
9618
9692
|
end: {
|
|
9619
9693
|
columnIndex: selectionEndColumn,
|
|
9620
9694
|
rowIndex: selectionEndRow
|
|
@@ -9634,7 +9708,7 @@ const compositionUpdate = (editor, data) => {
|
|
|
9634
9708
|
selections
|
|
9635
9709
|
} = editor;
|
|
9636
9710
|
const changes = getCompositionChanges(selections, data);
|
|
9637
|
-
state$
|
|
9711
|
+
state$5.compositionText = data;
|
|
9638
9712
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
9639
9713
|
};
|
|
9640
9714
|
const compositionEnd = (editor, data) => {
|
|
@@ -9642,8 +9716,8 @@ const compositionEnd = (editor, data) => {
|
|
|
9642
9716
|
selections
|
|
9643
9717
|
} = editor;
|
|
9644
9718
|
const changes = getCompositionChanges(selections, data);
|
|
9645
|
-
state$
|
|
9646
|
-
state$
|
|
9719
|
+
state$5.isComposing = false;
|
|
9720
|
+
state$5.compositionText = '';
|
|
9647
9721
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
9648
9722
|
};
|
|
9649
9723
|
|
|
@@ -10617,7 +10691,7 @@ const deleteWordRight = editor => {
|
|
|
10617
10691
|
|
|
10618
10692
|
const findAllReferences$1 = async editor => {
|
|
10619
10693
|
// @ts-ignore
|
|
10620
|
-
await invoke$
|
|
10694
|
+
await invoke$e('SideBar.show', 'References', /* focus */true);
|
|
10621
10695
|
return editor;
|
|
10622
10696
|
};
|
|
10623
10697
|
|
|
@@ -11215,7 +11289,7 @@ const getEditorLineDecorations = async (editor, rowIndex) => {
|
|
|
11215
11289
|
uri: editor.uri
|
|
11216
11290
|
};
|
|
11217
11291
|
try {
|
|
11218
|
-
const results = await invoke$
|
|
11292
|
+
const results = await invoke$9(editor.applicationId, 'Extensions.executeProvidersByEvent', 'onEditorLineDecoration', 'ExtensionApi.executeEditorLineDecorationProvider', textDocument, rowIndex);
|
|
11219
11293
|
return getProviderDecorations(results, rowIndex);
|
|
11220
11294
|
} catch {
|
|
11221
11295
|
return [];
|
|
@@ -11329,7 +11403,7 @@ const clear = editor => {
|
|
|
11329
11403
|
decorations: filtered
|
|
11330
11404
|
};
|
|
11331
11405
|
};
|
|
11332
|
-
const set = (editor, offset, length) => {
|
|
11406
|
+
const set$1 = (editor, offset, length) => {
|
|
11333
11407
|
if (matches(editor, offset, length)) {
|
|
11334
11408
|
return editor;
|
|
11335
11409
|
}
|
|
@@ -11432,10 +11506,10 @@ const startTextDrag = async (state, x, y) => {
|
|
|
11432
11506
|
}
|
|
11433
11507
|
try {
|
|
11434
11508
|
if (state.textDragId) {
|
|
11435
|
-
await invoke$
|
|
11509
|
+
await invoke$j('DragAndDrop.discardTextDrag', state.textDragId);
|
|
11436
11510
|
}
|
|
11437
11511
|
const text = getText$1(state).slice(startOffset, endOffset);
|
|
11438
|
-
const textDragId = await invoke$
|
|
11512
|
+
const textDragId = await invoke$j('DragAndDrop.createTextDrag', {
|
|
11439
11513
|
endOffset,
|
|
11440
11514
|
sourceUri: state.uri,
|
|
11441
11515
|
startOffset,
|
|
@@ -11522,9 +11596,9 @@ const handleMouseLeave = (viewletUid, editorUidValue) => {
|
|
|
11522
11596
|
widgets: removeEditorWidget(latestEditor.widgets, Hover)
|
|
11523
11597
|
};
|
|
11524
11598
|
set$a(editorUid, latestEditor, newEditor);
|
|
11525
|
-
await invoke$
|
|
11599
|
+
await invoke$e('Editor.renderPending', editorUid);
|
|
11526
11600
|
}, editorHoverDismissDelay);
|
|
11527
|
-
set$
|
|
11601
|
+
set$5(editorUid, {
|
|
11528
11602
|
timeout
|
|
11529
11603
|
});
|
|
11530
11604
|
};
|
|
@@ -11594,7 +11668,7 @@ const handleMouseMoveWithAltKey = async (editor, x, y) => {
|
|
|
11594
11668
|
if (!definition) {
|
|
11595
11669
|
return clear(editor);
|
|
11596
11670
|
}
|
|
11597
|
-
return set(editor, wordOffset, wordLength);
|
|
11671
|
+
return set$1(editor, wordOffset, wordLength);
|
|
11598
11672
|
} catch (error) {
|
|
11599
11673
|
if (isNoDefinitionProviderFoundError(error)) {
|
|
11600
11674
|
return clear(editor);
|
|
@@ -11618,7 +11692,7 @@ const getDiagnosticHoverDetail = ({
|
|
|
11618
11692
|
|
|
11619
11693
|
const measureTextBlockHeight = async (text, fontFamily, fontSize, lineHeight, width) => {
|
|
11620
11694
|
// @ts-ignore
|
|
11621
|
-
return invoke$
|
|
11695
|
+
return invoke$e('MeasureTextHeight.measureTextBlockHeight', text, fontFamily, fontSize, lineHeight, width);
|
|
11622
11696
|
};
|
|
11623
11697
|
|
|
11624
11698
|
const maximumWidth = 600;
|
|
@@ -11696,7 +11770,7 @@ const getTextDocument$1 = editor => {
|
|
|
11696
11770
|
};
|
|
11697
11771
|
const executeIsolatedHoverProvider = async (editor, offset) => {
|
|
11698
11772
|
const textDocument = getTextDocument$1(editor);
|
|
11699
|
-
return invoke$
|
|
11773
|
+
return invoke$9(editor.applicationId, 'Extensions.executeHoverProvider', textDocument, offset);
|
|
11700
11774
|
};
|
|
11701
11775
|
const executeHoverProvider = async (editor, offset) => {
|
|
11702
11776
|
object(editor);
|
|
@@ -11713,10 +11787,10 @@ const getHover = async (editor, offset) => {
|
|
|
11713
11787
|
};
|
|
11714
11788
|
|
|
11715
11789
|
const getVirtualDomFromMarkdown = async markdown => {
|
|
11716
|
-
const html = await invoke$
|
|
11790
|
+
const html = await invoke$8('Markdown.renderMarkdown', markdown, {
|
|
11717
11791
|
linksExternal: true
|
|
11718
11792
|
});
|
|
11719
|
-
return invoke$
|
|
11793
|
+
return invoke$8('Markdown.getVirtualDom', html);
|
|
11720
11794
|
};
|
|
11721
11795
|
|
|
11722
11796
|
const getLineInfo = (line, tokens, TokenMap) => {
|
|
@@ -11932,7 +12006,7 @@ const showHover = async (editor, position, token) => {
|
|
|
11932
12006
|
return;
|
|
11933
12007
|
}
|
|
11934
12008
|
set$a(editor.uid, latestInstance.oldState, newEditor);
|
|
11935
|
-
await invoke$
|
|
12009
|
+
await invoke$e('Editor.renderPending', editor.uid);
|
|
11936
12010
|
};
|
|
11937
12011
|
|
|
11938
12012
|
// TODO several things can happen:
|
|
@@ -11975,7 +12049,7 @@ const handleMouseMove = async (editor, x, y, altKey) => {
|
|
|
11975
12049
|
}
|
|
11976
12050
|
const token = create$8();
|
|
11977
12051
|
const timeout = setTimeout(onHoverIdle, editorWithoutDefinitionLink.hoverDelay ?? 200, token);
|
|
11978
|
-
set$
|
|
12052
|
+
set$4(editorWithoutDefinitionLink, timeout, x, y, token);
|
|
11979
12053
|
return editorWithoutDefinitionLink;
|
|
11980
12054
|
};
|
|
11981
12055
|
|
|
@@ -12024,7 +12098,7 @@ const editorHandleNativeSelectionChange = (editor, range) => {
|
|
|
12024
12098
|
const handlePointerCaptureLost = async editor => {
|
|
12025
12099
|
if (editor.textDragId) {
|
|
12026
12100
|
try {
|
|
12027
|
-
await invoke$
|
|
12101
|
+
await invoke$j('DragAndDrop.discardTextDrag', editor.textDragId);
|
|
12028
12102
|
} catch {
|
|
12029
12103
|
// The pointer state still needs to be reset if the worker is unavailable.
|
|
12030
12104
|
}
|
|
@@ -12194,7 +12268,7 @@ const continueScrollingAndMovingSelection = async editorUid => {
|
|
|
12194
12268
|
return;
|
|
12195
12269
|
}
|
|
12196
12270
|
set$a(editor.uid, editor, derivedEditor);
|
|
12197
|
-
await invoke$
|
|
12271
|
+
await invoke$e('Editor.renderPending', editor.uid);
|
|
12198
12272
|
if (derivedEditor.hasListener) {
|
|
12199
12273
|
requestAnimationFrame(() => continueScrollingAndMovingSelection(editorUid));
|
|
12200
12274
|
}
|
|
@@ -12319,7 +12393,7 @@ const handlePointerUp = async editor => {
|
|
|
12319
12393
|
return resetEditor;
|
|
12320
12394
|
}
|
|
12321
12395
|
try {
|
|
12322
|
-
const data = await invoke$
|
|
12396
|
+
const data = await invoke$j('DragAndDrop.takeTextDrag', editor.textDragId);
|
|
12323
12397
|
if (!data) {
|
|
12324
12398
|
return resetEditor;
|
|
12325
12399
|
}
|
|
@@ -12472,7 +12546,7 @@ const handleTouchEnd = (editor, touchEvent) => {
|
|
|
12472
12546
|
// }
|
|
12473
12547
|
};
|
|
12474
12548
|
|
|
12475
|
-
const state$
|
|
12549
|
+
const state$4 = {
|
|
12476
12550
|
deltaY: 0,
|
|
12477
12551
|
touchOffsetY: 0
|
|
12478
12552
|
};
|
|
@@ -12483,8 +12557,8 @@ const handleTouchStart = (editor, touchEvent) => {
|
|
|
12483
12557
|
return;
|
|
12484
12558
|
}
|
|
12485
12559
|
const firstTouch = touchEvent.touches[0];
|
|
12486
|
-
state$
|
|
12487
|
-
state$
|
|
12560
|
+
state$4.touchOffsetY = firstTouch.y;
|
|
12561
|
+
state$4.deltaY = editor.deltaY;
|
|
12488
12562
|
// const position = EditorPosition.at(editor, firstTouch.x, firstTouch.y)
|
|
12489
12563
|
// EditorMoveSelection.state.position = position
|
|
12490
12564
|
// state.date = Date.now()
|
|
@@ -12524,7 +12598,7 @@ const handleTouchMove = (editor, touchEvent) => {
|
|
|
12524
12598
|
return;
|
|
12525
12599
|
}
|
|
12526
12600
|
const firstTouch = touchEvent.touches[0];
|
|
12527
|
-
const offsetY = state$
|
|
12601
|
+
const offsetY = state$4.deltaY + (state$4.touchOffsetY - firstTouch.y);
|
|
12528
12602
|
setDeltaYFixedValue(editor, offsetY);
|
|
12529
12603
|
};
|
|
12530
12604
|
|
|
@@ -12628,7 +12702,7 @@ const indentMore = editor => {
|
|
|
12628
12702
|
|
|
12629
12703
|
const getLanguageConfiguration = async editor => {
|
|
12630
12704
|
// @ts-ignore
|
|
12631
|
-
return invoke$
|
|
12705
|
+
return invoke$e('Languages.getLanguageConfiguration', {
|
|
12632
12706
|
languageId: editor.languageId,
|
|
12633
12707
|
uri: editor.uri
|
|
12634
12708
|
});
|
|
@@ -12881,14 +12955,14 @@ const addWidget = (widget, id, render) => {
|
|
|
12881
12955
|
};
|
|
12882
12956
|
|
|
12883
12957
|
const setFocus = async focusKey => {
|
|
12884
|
-
await invoke$
|
|
12958
|
+
await invoke$e('Focus.setFocus', focusKey);
|
|
12885
12959
|
};
|
|
12886
12960
|
const unsetAdditionalFocus = async focusKey => {
|
|
12887
12961
|
if (!focusKey) {
|
|
12888
12962
|
return;
|
|
12889
12963
|
}
|
|
12890
12964
|
// @ts-ignore
|
|
12891
|
-
await invoke$
|
|
12965
|
+
await invoke$e('Focus.removeAdditionalFocus', focusKey);
|
|
12892
12966
|
};
|
|
12893
12967
|
|
|
12894
12968
|
const FocusEditor = 12;
|
|
@@ -12958,7 +13032,7 @@ const launch = async () => {
|
|
|
12958
13032
|
const rpc = await launchFindWidgetWorker();
|
|
12959
13033
|
set$j(rpcId, rpc);
|
|
12960
13034
|
};
|
|
12961
|
-
const invoke$
|
|
13035
|
+
const invoke$4 = async (method, ...params) => {
|
|
12962
13036
|
const rpc = get$9(rpcId);
|
|
12963
13037
|
return await rpc.invoke(method, ...params);
|
|
12964
13038
|
};
|
|
@@ -12982,14 +13056,14 @@ const launchHoverWorker = async () => {
|
|
|
12982
13056
|
return rpc;
|
|
12983
13057
|
};
|
|
12984
13058
|
|
|
12985
|
-
const state$
|
|
13059
|
+
const state$3 = {};
|
|
12986
13060
|
const getOrCreate$1 = () => {
|
|
12987
|
-
if (!state$
|
|
12988
|
-
state$
|
|
13061
|
+
if (!state$3.workerPromise) {
|
|
13062
|
+
state$3.workerPromise = launchHoverWorker();
|
|
12989
13063
|
}
|
|
12990
|
-
return state$
|
|
13064
|
+
return state$3.workerPromise;
|
|
12991
13065
|
};
|
|
12992
|
-
const invoke$
|
|
13066
|
+
const invoke$3 = async (method, ...params) => {
|
|
12993
13067
|
const worker = await getOrCreate$1();
|
|
12994
13068
|
return await worker.invoke(method, ...params);
|
|
12995
13069
|
};
|
|
@@ -13002,14 +13076,14 @@ const launchSourceActionWorker = async () => {
|
|
|
13002
13076
|
return rpc;
|
|
13003
13077
|
};
|
|
13004
13078
|
|
|
13005
|
-
const state$
|
|
13079
|
+
const state$2 = {};
|
|
13006
13080
|
const getOrCreate = () => {
|
|
13007
|
-
if (!state$
|
|
13008
|
-
state$
|
|
13081
|
+
if (!state$2.workerPromise) {
|
|
13082
|
+
state$2.workerPromise = launchSourceActionWorker();
|
|
13009
13083
|
}
|
|
13010
|
-
return state$
|
|
13084
|
+
return state$2.workerPromise;
|
|
13011
13085
|
};
|
|
13012
|
-
const invoke$
|
|
13086
|
+
const invoke$2 = async (method, ...params) => {
|
|
13013
13087
|
const worker = await getOrCreate();
|
|
13014
13088
|
return await worker.invoke(method, ...params);
|
|
13015
13089
|
};
|
|
@@ -13017,17 +13091,17 @@ const invoke$1 = async (method, ...params) => {
|
|
|
13017
13091
|
const getWidgetInvoke = widgetId => {
|
|
13018
13092
|
switch (widgetId) {
|
|
13019
13093
|
case ColorPicker$2:
|
|
13020
|
-
return invoke$
|
|
13094
|
+
return invoke$7;
|
|
13021
13095
|
case Completion:
|
|
13022
|
-
return invoke$
|
|
13096
|
+
return invoke$5;
|
|
13023
13097
|
case Find:
|
|
13024
|
-
return invoke$
|
|
13098
|
+
return invoke$4;
|
|
13025
13099
|
case Hover:
|
|
13026
|
-
return invoke$
|
|
13100
|
+
return invoke$3;
|
|
13027
13101
|
case Rename$1:
|
|
13028
|
-
return invoke$
|
|
13102
|
+
return invoke$6;
|
|
13029
13103
|
case SourceAction$1:
|
|
13030
|
-
return invoke$
|
|
13104
|
+
return invoke$2;
|
|
13031
13105
|
default:
|
|
13032
13106
|
return undefined;
|
|
13033
13107
|
}
|
|
@@ -13287,10 +13361,10 @@ const loadContent$2 = async (state, parentUid, savedState) => {
|
|
|
13287
13361
|
y
|
|
13288
13362
|
} = editor;
|
|
13289
13363
|
await launch();
|
|
13290
|
-
await invoke$
|
|
13291
|
-
await invoke$
|
|
13292
|
-
const diff = await invoke$
|
|
13293
|
-
const commands = await invoke$
|
|
13364
|
+
await invoke$4('FindWidget.create', uid, x, y, width, height, parentUid);
|
|
13365
|
+
await invoke$4('FindWidget.loadContent', uid, savedState);
|
|
13366
|
+
const diff = await invoke$4('FindWidget.diff2', uid);
|
|
13367
|
+
const commands = await invoke$4('FindWidget.render2', uid, diff);
|
|
13294
13368
|
return {
|
|
13295
13369
|
...state,
|
|
13296
13370
|
commands
|
|
@@ -13370,10 +13444,10 @@ const newStateGenerator$1 = async (state, parentUid) => {
|
|
|
13370
13444
|
applicationId,
|
|
13371
13445
|
languageId
|
|
13372
13446
|
} = newState;
|
|
13373
|
-
await invoke$
|
|
13374
|
-
await invoke$
|
|
13375
|
-
const diff = await invoke$
|
|
13376
|
-
const commands = await invoke$
|
|
13447
|
+
await invoke$6('Rename.create', uid, x, y, width, height, parentUid, languageId, applicationId);
|
|
13448
|
+
await invoke$6('Rename.loadContent', uid);
|
|
13449
|
+
const diff = await invoke$6('Rename.diff2', uid);
|
|
13450
|
+
const commands = await invoke$6('Rename.render2', uid, diff);
|
|
13377
13451
|
return {
|
|
13378
13452
|
...state,
|
|
13379
13453
|
commands
|
|
@@ -13438,7 +13512,7 @@ const getOrganizeImportEdits = async editor => {
|
|
|
13438
13512
|
text: getText$1(editor),
|
|
13439
13513
|
uri: editor.uri
|
|
13440
13514
|
};
|
|
13441
|
-
const result = await invoke$
|
|
13515
|
+
const result = await invoke$9(editor.applicationId, 'Extensions.executeOrganizeImportsProvider', textDocument);
|
|
13442
13516
|
return result.found ? result.result ?? [] : [];
|
|
13443
13517
|
};
|
|
13444
13518
|
|
|
@@ -13497,11 +13571,11 @@ const writeClipboardImage = async (editor, blob) => {
|
|
|
13497
13571
|
for (let index = 0; index < 1000; index++) {
|
|
13498
13572
|
const fileName = index === 0 ? `image.${extension}` : `image-${index}.${extension}`;
|
|
13499
13573
|
const uri = getImageUri(editor.uri, fileName);
|
|
13500
|
-
if (await invoke$
|
|
13574
|
+
if (await invoke$a(editor.applicationId, 'FileSystem.exists', uri)) {
|
|
13501
13575
|
continue;
|
|
13502
13576
|
}
|
|
13503
13577
|
try {
|
|
13504
|
-
await invoke$
|
|
13578
|
+
await invoke$a(editor.applicationId, 'FileSystem.createFile', uri);
|
|
13505
13579
|
} catch (error) {
|
|
13506
13580
|
if (isFileExistsError(error)) {
|
|
13507
13581
|
continue;
|
|
@@ -13509,14 +13583,14 @@ const writeClipboardImage = async (editor, blob) => {
|
|
|
13509
13583
|
throw error;
|
|
13510
13584
|
}
|
|
13511
13585
|
try {
|
|
13512
|
-
await invoke$
|
|
13586
|
+
await invoke$a(editor.applicationId, 'FileSystem.writeFile', uri, await toBinaryString(blob), 'binary');
|
|
13513
13587
|
return {
|
|
13514
13588
|
fileName,
|
|
13515
13589
|
uri
|
|
13516
13590
|
};
|
|
13517
13591
|
} catch (error) {
|
|
13518
13592
|
try {
|
|
13519
|
-
await invoke$
|
|
13593
|
+
await invoke$a(editor.applicationId, 'FileSystem.remove', uri);
|
|
13520
13594
|
} catch {}
|
|
13521
13595
|
throw error;
|
|
13522
13596
|
}
|
|
@@ -13528,7 +13602,7 @@ const paste = async (editor, pastedText) => {
|
|
|
13528
13602
|
if (editor.languageId === 'markdown') {
|
|
13529
13603
|
let image;
|
|
13530
13604
|
try {
|
|
13531
|
-
image = await invoke$
|
|
13605
|
+
image = await invoke$e('ClipBoard.readImage');
|
|
13532
13606
|
} catch (error) {
|
|
13533
13607
|
imageReadError = error;
|
|
13534
13608
|
}
|
|
@@ -13544,7 +13618,7 @@ const paste = async (editor, pastedText) => {
|
|
|
13544
13618
|
const currentEditor = get$8(editor.uid)?.newState;
|
|
13545
13619
|
if (!currentEditor || currentEditor.uri !== editor.uri || currentEditor.languageId !== 'markdown') {
|
|
13546
13620
|
try {
|
|
13547
|
-
await invoke$
|
|
13621
|
+
await invoke$a(editor.applicationId, 'FileSystem.remove', savedImage.uri);
|
|
13548
13622
|
} catch {}
|
|
13549
13623
|
throw new Error('The Markdown document changed while saving the clipboard image. Paste the image again.');
|
|
13550
13624
|
}
|
|
@@ -14167,13 +14241,9 @@ const setLanguageId = async (editor, languageId, tokenizePath, isExplicit = fals
|
|
|
14167
14241
|
languageId
|
|
14168
14242
|
};
|
|
14169
14243
|
}
|
|
14170
|
-
const {
|
|
14171
|
-
tokenizerId
|
|
14172
|
-
} = editor;
|
|
14173
14244
|
await loadTokenizer(languageId, tokenizePath);
|
|
14174
14245
|
const tokenizer = getTokenizer(languageId);
|
|
14175
|
-
const newTokenizerId =
|
|
14176
|
-
set$5(newTokenizerId, tokenizer);
|
|
14246
|
+
const newTokenizerId = register(tokenizer);
|
|
14177
14247
|
return {
|
|
14178
14248
|
...editor,
|
|
14179
14249
|
explicitLanguageId: isExplicit ? languageId : editor.explicitLanguageId,
|
|
@@ -14285,7 +14355,7 @@ const executeSignatureHelpProvider = async (editor, offset) => {
|
|
|
14285
14355
|
object(editor);
|
|
14286
14356
|
number(offset);
|
|
14287
14357
|
const textDocument = getTextDocument(editor);
|
|
14288
|
-
return invoke$
|
|
14358
|
+
return invoke$9(editor.applicationId, 'Extensions.executeSignatureHelpProvider', textDocument, offset);
|
|
14289
14359
|
};
|
|
14290
14360
|
|
|
14291
14361
|
const getSignatureHelp = async (editor, offset) => {
|
|
@@ -14423,10 +14493,10 @@ const newStateGenerator = async (state, parentUid) => {
|
|
|
14423
14493
|
const {
|
|
14424
14494
|
languageId
|
|
14425
14495
|
} = newState;
|
|
14426
|
-
await invoke$
|
|
14427
|
-
await invoke$
|
|
14428
|
-
const diff = await invoke$
|
|
14429
|
-
const commands = await invoke$
|
|
14496
|
+
await invoke$2('SourceActions.create', uid, x, y, width, height, parentUid, languageId);
|
|
14497
|
+
await invoke$2('SourceActions.loadContent', uid);
|
|
14498
|
+
const diff = await invoke$2('SourceActions.diff2', uid);
|
|
14499
|
+
const commands = await invoke$2('SourceActions.render2', uid, diff);
|
|
14430
14500
|
return {
|
|
14431
14501
|
...state,
|
|
14432
14502
|
commands
|
|
@@ -16041,7 +16111,7 @@ const executeViewletCommand$1 = async (commandMap, uid, commandId, ...args) => {
|
|
|
16041
16111
|
throw new TypeError(`Viewlet command not found: ${commandId}`);
|
|
16042
16112
|
}
|
|
16043
16113
|
await fn(uid, ...args);
|
|
16044
|
-
await invoke$
|
|
16114
|
+
await invoke$e('Viewlet.executeViewletCommand', uid, '__renderPending', false);
|
|
16045
16115
|
};
|
|
16046
16116
|
|
|
16047
16117
|
const executeWidgetCommand = async (editor, name, method, _uid, widgetId, ...params) => {
|
|
@@ -16086,7 +16156,7 @@ const getEditorSourceActions = async editorId => {
|
|
|
16086
16156
|
const {
|
|
16087
16157
|
newState
|
|
16088
16158
|
} = get$8(editorId);
|
|
16089
|
-
const extensions = await invoke$
|
|
16159
|
+
const extensions = await invoke$9(newState.applicationId, 'Extensions.getAllExtensions', newState.assetDir, newState.platform);
|
|
16090
16160
|
return extensions.filter(extension => !extension.disabled).flatMap(extension => extension.codeActions || []).filter(action => action.languageId === newState.languageId);
|
|
16091
16161
|
};
|
|
16092
16162
|
|
|
@@ -16249,7 +16319,7 @@ const getDiagnostics = async editorUid => {
|
|
|
16249
16319
|
};
|
|
16250
16320
|
|
|
16251
16321
|
const ensure = async (fontName, fontUrl) => {
|
|
16252
|
-
await invoke$
|
|
16322
|
+
await invoke$f('TextMeasurement.ensureFont', fontName, fontUrl);
|
|
16253
16323
|
};
|
|
16254
16324
|
|
|
16255
16325
|
const findWidgetFocusContexts = [FindWidget, FocusFindWidgetReplace$1, FocusFindWidgetOptions, FocusFindWidgetToggleReplace, FocusFindWidgetPreviousMatchButton, FocusFindWidgetNextMatchButton, FocusFindWidgetCloseButton, FocusFindWidgetReplaceButton, FocusFindWidgetReplaceAllButton];
|
|
@@ -16908,6 +16978,51 @@ const handleBeforeInput = (editor, inputType, data) => {
|
|
|
16908
16978
|
}
|
|
16909
16979
|
};
|
|
16910
16980
|
|
|
16981
|
+
// These commands have renderer-owned effects in addition to editor state updates.
|
|
16982
|
+
const rendererCommands = new Set(['ColorPicker.handleSliderKeyDown', 'handleFocus', 'handleMouseDown', 'handleUriChange', 'handleWorkspaceRefresh', 'hotReload', 'loadContent', 'loadContentLater', 'refreshGutterDecorationsAll', 'renderPending', 'setLanguageId', 'showOverlayMessage', 'updateDiagnostics']);
|
|
16983
|
+
const createCommandMap = commands => ({
|
|
16984
|
+
async 'Viewlet.executeViewletCommand'(uid, command, ...args) {
|
|
16985
|
+
if (rendererCommands.has(command)) {
|
|
16986
|
+
await invoke$e('Viewlet.executeViewletCommand', uid, command, ...args);
|
|
16987
|
+
return;
|
|
16988
|
+
}
|
|
16989
|
+
const fn = commands[command.includes('.') ? command : `Editor.${command}`];
|
|
16990
|
+
if (typeof fn !== 'function') {
|
|
16991
|
+
throw new TypeError(`Editor event command not found: ${command}`);
|
|
16992
|
+
}
|
|
16993
|
+
const editor = get$8(uid)?.newState;
|
|
16994
|
+
if (!editor) return;
|
|
16995
|
+
await fn(uid, ...args);
|
|
16996
|
+
const current = get$8(uid)?.newState;
|
|
16997
|
+
if (!current || editor.lifecycle?.disposed || current.lifecycle !== editor.lifecycle) return;
|
|
16998
|
+
// The wrapped command has released the document queue before requesting a
|
|
16999
|
+
// render; a diff can now run without waiting on its own command.
|
|
17000
|
+
await invoke$e('Viewlet.requestRender', uid, false);
|
|
17001
|
+
}
|
|
17002
|
+
});
|
|
17003
|
+
|
|
17004
|
+
const state$1 = {
|
|
17005
|
+
rpc: undefined
|
|
17006
|
+
};
|
|
17007
|
+
const isConnected = () => {
|
|
17008
|
+
const {
|
|
17009
|
+
rpc
|
|
17010
|
+
} = state$1;
|
|
17011
|
+
return rpc !== undefined;
|
|
17012
|
+
};
|
|
17013
|
+
const set = value => {
|
|
17014
|
+
state$1.rpc = value;
|
|
17015
|
+
};
|
|
17016
|
+
const invoke$1 = (method, ...params) => {
|
|
17017
|
+
const {
|
|
17018
|
+
rpc
|
|
17019
|
+
} = state$1;
|
|
17020
|
+
if (!rpc) {
|
|
17021
|
+
throw new Error('Editor renderer process is not connected');
|
|
17022
|
+
}
|
|
17023
|
+
return rpc.invoke(method, ...params);
|
|
17024
|
+
};
|
|
17025
|
+
|
|
16911
17026
|
const handleMessagePort = async (port, rpcId) => {
|
|
16912
17027
|
const rpc = await create$e({
|
|
16913
17028
|
commandMap: {},
|
|
@@ -16918,10 +17033,17 @@ const handleMessagePort = async (port, rpcId) => {
|
|
|
16918
17033
|
await initializeListener(rpcId);
|
|
16919
17034
|
}
|
|
16920
17035
|
};
|
|
17036
|
+
const handleDirectMessagePort = async (port, commands) => {
|
|
17037
|
+
const rpc = await create$h({
|
|
17038
|
+
commandMap: createCommandMap(commands),
|
|
17039
|
+
messagePort: port
|
|
17040
|
+
});
|
|
17041
|
+
set(rpc);
|
|
17042
|
+
};
|
|
16921
17043
|
|
|
16922
17044
|
const getBreadcrumbFileIcon = async (uri, applicationId) => {
|
|
16923
17045
|
try {
|
|
16924
|
-
const icon = await invoke$
|
|
17046
|
+
const icon = await invoke$a(applicationId, 'IconTheme.getFileIcon', {
|
|
16925
17047
|
name: decodeURIComponent(uri.split('/').at(-1) || '')
|
|
16926
17048
|
});
|
|
16927
17049
|
return typeof icon === 'string' ? icon : '';
|
|
@@ -17111,7 +17233,7 @@ const getLargeFilePreferences = () => ({
|
|
|
17111
17233
|
|
|
17112
17234
|
const getWorkspaceUri$1 = async applicationId => {
|
|
17113
17235
|
try {
|
|
17114
|
-
return await invoke$
|
|
17236
|
+
return await invoke$a(applicationId, 'Workspace.getPath');
|
|
17115
17237
|
} catch {
|
|
17116
17238
|
return '';
|
|
17117
17239
|
}
|
|
@@ -17124,9 +17246,9 @@ const updateFindWidget = async state => {
|
|
|
17124
17246
|
const {
|
|
17125
17247
|
uid
|
|
17126
17248
|
} = widget.newState;
|
|
17127
|
-
await invoke$
|
|
17128
|
-
const diff = await invoke$
|
|
17129
|
-
const commands = await invoke$
|
|
17249
|
+
await invoke$4('FindWidget.handleSettingsChanged', uid);
|
|
17250
|
+
const diff = await invoke$4('FindWidget.diff2', uid);
|
|
17251
|
+
const commands = await invoke$4('FindWidget.render2', uid, diff);
|
|
17130
17252
|
return updateWidget(state, Find, {
|
|
17131
17253
|
...widget.newState,
|
|
17132
17254
|
commands
|
|
@@ -17221,7 +17343,7 @@ const getWidgetHotReloadDescriptor = widgetId => {
|
|
|
17221
17343
|
switch (widgetId) {
|
|
17222
17344
|
case Find:
|
|
17223
17345
|
return {
|
|
17224
|
-
invoke: invoke$
|
|
17346
|
+
invoke: invoke$4,
|
|
17225
17347
|
name: 'FindWidget'
|
|
17226
17348
|
};
|
|
17227
17349
|
default:
|
|
@@ -17351,7 +17473,7 @@ const hotReload = async () => {
|
|
|
17351
17473
|
|
|
17352
17474
|
// TODO ask renderer worker to rerender all editors
|
|
17353
17475
|
// @ts-ignore
|
|
17354
|
-
await invoke$
|
|
17476
|
+
await invoke$e(`Editor.rerender`);
|
|
17355
17477
|
} finally {
|
|
17356
17478
|
state.isReloading = false;
|
|
17357
17479
|
}
|
|
@@ -17431,7 +17553,7 @@ const isExcludedFromFileCache = uri => {
|
|
|
17431
17553
|
return fileName === '.env' || fileName.startsWith('.env.');
|
|
17432
17554
|
};
|
|
17433
17555
|
const removeCachedEditorFile = (applicationId, uri) => {
|
|
17434
|
-
void invoke$
|
|
17556
|
+
void invoke$a(undefined, 'CacheStorage.removeEditorFileCache', applicationId || '', uri).catch(() => {});
|
|
17435
17557
|
};
|
|
17436
17558
|
const readFileWithCache = async (applicationId, uri, forceReload, useCache) => {
|
|
17437
17559
|
if (!useCache) {
|
|
@@ -17447,7 +17569,7 @@ const readFileWithCache = async (applicationId, uri, forceReload, useCache) => {
|
|
|
17447
17569
|
}
|
|
17448
17570
|
let fingerprint = '';
|
|
17449
17571
|
try {
|
|
17450
|
-
const stat = await invoke$
|
|
17572
|
+
const stat = await invoke$a(applicationId, 'FileSystem.statWithMetadata', uri);
|
|
17451
17573
|
if (stat?.size <= editorFileCacheMaxBytes) {
|
|
17452
17574
|
fingerprint = getFileStatFingerprint(stat);
|
|
17453
17575
|
}
|
|
@@ -17459,7 +17581,7 @@ const readFileWithCache = async (applicationId, uri, forceReload, useCache) => {
|
|
|
17459
17581
|
}
|
|
17460
17582
|
if (fingerprint) {
|
|
17461
17583
|
try {
|
|
17462
|
-
const cached = await invoke$
|
|
17584
|
+
const cached = await invoke$a(undefined, 'CacheStorage.getEditorFileCache', applicationId || '', uri, fingerprint);
|
|
17463
17585
|
if (typeof cached === 'string') {
|
|
17464
17586
|
return cached;
|
|
17465
17587
|
}
|
|
@@ -17469,7 +17591,7 @@ const readFileWithCache = async (applicationId, uri, forceReload, useCache) => {
|
|
|
17469
17591
|
}
|
|
17470
17592
|
const content = await readFile$1(applicationId, uri);
|
|
17471
17593
|
if (fingerprint && new TextEncoder().encode(content).byteLength <= editorFileCacheMaxBytes) {
|
|
17472
|
-
void invoke$
|
|
17594
|
+
void invoke$a(undefined, 'CacheStorage.setEditorFileCache', applicationId || '', uri, fingerprint, content).catch(() => {});
|
|
17473
17595
|
}
|
|
17474
17596
|
return content;
|
|
17475
17597
|
};
|
|
@@ -17508,7 +17630,7 @@ const readFile = (applicationId, uri, forceReload, useCache) => {
|
|
|
17508
17630
|
};
|
|
17509
17631
|
const getWorkspaceUri = async applicationId => {
|
|
17510
17632
|
try {
|
|
17511
|
-
return await invoke$
|
|
17633
|
+
return await invoke$a(applicationId, 'Workspace.getPath');
|
|
17512
17634
|
} catch {
|
|
17513
17635
|
return '';
|
|
17514
17636
|
}
|
|
@@ -17692,8 +17814,7 @@ const loadContent = async (state, savedState, largeFile = false, focus = true, f
|
|
|
17692
17814
|
const tokenizePath = getTokenizePath(languages, computedLanguageId);
|
|
17693
17815
|
await loadTokenizer(computedLanguageId, tokenizePath);
|
|
17694
17816
|
const tokenizer = getTokenizer(computedLanguageId);
|
|
17695
|
-
const newTokenizerId =
|
|
17696
|
-
set$5(newTokenizerId, tokenizer);
|
|
17817
|
+
const newTokenizerId = register(tokenizer);
|
|
17697
17818
|
effectiveEditor.tokenizerId = newTokenizerId;
|
|
17698
17819
|
}
|
|
17699
17820
|
const savedHistory = existingEditor ? undefined : getSavedHistory(savedState, content);
|
|
@@ -17843,7 +17964,7 @@ const refreshGutterDecorationsAll = async () => {
|
|
|
17843
17964
|
...latest.newState,
|
|
17844
17965
|
gutterDecorations: refreshedEditor.gutterDecorations
|
|
17845
17966
|
});
|
|
17846
|
-
await invoke$
|
|
17967
|
+
await invoke$e('Editor.renderPending', editor.id);
|
|
17847
17968
|
}
|
|
17848
17969
|
}
|
|
17849
17970
|
};
|
|
@@ -19038,7 +19159,7 @@ const renderIncremental = (oldState, newState) => {
|
|
|
19038
19159
|
const textAppendPaths = getTextAppendPaths$1(newState.uid);
|
|
19039
19160
|
if (renderedDom && textAppendPaths && canRenderPlainTextAppend(oldState, newState)) {
|
|
19040
19161
|
const newDom = updateTextAppendDom(renderedDom, newState, textAppendPaths);
|
|
19041
|
-
set$
|
|
19162
|
+
set$2(newState.uid, newDom, textAppendPaths);
|
|
19042
19163
|
const patches = getTextAppendPatches(newState, textAppendPaths);
|
|
19043
19164
|
return [SetPatches, newState.uid, patches];
|
|
19044
19165
|
}
|
|
@@ -19046,7 +19167,7 @@ const renderIncremental = (oldState, newState) => {
|
|
|
19046
19167
|
const newDom = getDom(newState);
|
|
19047
19168
|
const patches = diffTree(oldDom, newDom);
|
|
19048
19169
|
const newTextAppendPaths = newState.languageId === 'plaintext' && newState.lines.length === 1 ? getTextAppendPaths(newDom) : undefined;
|
|
19049
|
-
set$
|
|
19170
|
+
set$2(newState.uid, newDom, newTextAppendPaths);
|
|
19050
19171
|
if (patches.length === 0) {
|
|
19051
19172
|
return [];
|
|
19052
19173
|
}
|
|
@@ -19178,6 +19299,60 @@ const render2 = (uid, _diffResult) => {
|
|
|
19178
19299
|
return commands;
|
|
19179
19300
|
};
|
|
19180
19301
|
|
|
19302
|
+
const queues = new Map();
|
|
19303
|
+
const focusCommands = new Set(['Viewlet.focus', 'Viewlet.focusSelector', 'Viewlet.setFocusContext', 'Viewlet.setAdditionalFocus', 'Viewlet.unsetAdditionalFocus']);
|
|
19304
|
+
const renderDirect = async (uid, preserveFocus) => {
|
|
19305
|
+
const instance = get$8(uid);
|
|
19306
|
+
if (!instance) return [];
|
|
19307
|
+
const {
|
|
19308
|
+
newState,
|
|
19309
|
+
oldState
|
|
19310
|
+
} = instance;
|
|
19311
|
+
const oldDom = get$1(uid);
|
|
19312
|
+
const oldPaths = getTextAppendPaths$1(uid);
|
|
19313
|
+
try {
|
|
19314
|
+
const commands = render2(uid, []);
|
|
19315
|
+
const result = [];
|
|
19316
|
+
for (const command of commands) {
|
|
19317
|
+
if (preserveFocus && focusCommands.has(command[0])) continue;
|
|
19318
|
+
// Widget creation/declarations and focus contexts must still pass through
|
|
19319
|
+
// renderer-worker. Replace only DOM patches, preserving command order.
|
|
19320
|
+
if (isConnected() && command[0] === 'Viewlet.setPatches' && command[1] === uid) {
|
|
19321
|
+
const transactionId = await invoke$1('Viewlet.queueCommands', uid, [command]);
|
|
19322
|
+
result.push(['Viewlet.commitPending', uid, transactionId]);
|
|
19323
|
+
} else {
|
|
19324
|
+
result.push(command);
|
|
19325
|
+
}
|
|
19326
|
+
}
|
|
19327
|
+
return result;
|
|
19328
|
+
} catch (error) {
|
|
19329
|
+
const latest = get$8(uid);
|
|
19330
|
+
if (latest?.newState.lifecycle === newState.lifecycle && latest.oldState === newState) {
|
|
19331
|
+
// A rejected queue RPC must not acknowledge patches that never arrived.
|
|
19332
|
+
set$a(uid, oldState, latest.newState);
|
|
19333
|
+
if (oldDom) set$2(uid, oldDom, oldPaths);else dispose$2(uid);
|
|
19334
|
+
}
|
|
19335
|
+
throw error;
|
|
19336
|
+
}
|
|
19337
|
+
};
|
|
19338
|
+
const renderDirect2 = async (uid, preserveFocus = false) => {
|
|
19339
|
+
const lifecycle = get$8(uid)?.newState.lifecycle;
|
|
19340
|
+
const previous = queues.get(uid);
|
|
19341
|
+
const {
|
|
19342
|
+
promise,
|
|
19343
|
+
resolve
|
|
19344
|
+
} = Promise.withResolvers();
|
|
19345
|
+
queues.set(uid, promise);
|
|
19346
|
+
if (previous) await previous;
|
|
19347
|
+
try {
|
|
19348
|
+
if (get$8(uid)?.newState.lifecycle !== lifecycle) return [];
|
|
19349
|
+
return await renderDirect(uid, preserveFocus);
|
|
19350
|
+
} finally {
|
|
19351
|
+
resolve();
|
|
19352
|
+
if (queues.get(uid) === promise) queues.delete(uid);
|
|
19353
|
+
}
|
|
19354
|
+
};
|
|
19355
|
+
|
|
19181
19356
|
const renderLines = {
|
|
19182
19357
|
apply(oldState, newState) {
|
|
19183
19358
|
const {
|
|
@@ -19438,7 +19613,7 @@ const save = async (uid, skipFormatting = false) => {
|
|
|
19438
19613
|
const saved = await saveContent(uid);
|
|
19439
19614
|
if (savedFrom && saved && savedFrom.uri !== saved.uri) {
|
|
19440
19615
|
// Retargeting calls Editor.handleUriChange, so release the editing queue first.
|
|
19441
|
-
await invoke$
|
|
19616
|
+
await invoke$a(savedFrom.applicationId, 'Main.handleUriChange', savedFrom.uri, saved.uri);
|
|
19442
19617
|
}
|
|
19443
19618
|
};
|
|
19444
19619
|
|
|
@@ -19563,7 +19738,7 @@ const updateDebugInfo = async debugId => {
|
|
|
19563
19738
|
};
|
|
19564
19739
|
set$a(key, oldState, newEditor);
|
|
19565
19740
|
// @ts-ignore
|
|
19566
|
-
await invoke$
|
|
19741
|
+
await invoke$e('Editor.rerender', key);
|
|
19567
19742
|
};
|
|
19568
19743
|
|
|
19569
19744
|
// State and undo history belong in this worker. Rendering reads changes separately.
|
|
@@ -19608,7 +19783,7 @@ const wrapTypingCommand = (fn, shouldOpenCompletion, shouldDismissHover, preserv
|
|
|
19608
19783
|
const newEditor = await fn(editor, ...args);
|
|
19609
19784
|
return shouldDismissHover(...args) ? removeHoverFromEditor(newEditor) : newEditor;
|
|
19610
19785
|
}, preservesTypingCoalescing);
|
|
19611
|
-
|
|
19786
|
+
const typingCommand = async (uid, ...args) => {
|
|
19612
19787
|
const dismissHover = shouldDismissHover(...args);
|
|
19613
19788
|
if (dismissHover) {
|
|
19614
19789
|
clear$2(uid);
|
|
@@ -19617,9 +19792,10 @@ const wrapTypingCommand = (fn, shouldOpenCompletion, shouldDismissHover, preserv
|
|
|
19617
19792
|
await command(uid, ...args);
|
|
19618
19793
|
const editor = get$8(uid)?.newState;
|
|
19619
19794
|
if (editor && (shouldOpenCompletion(...args) && shouldOpenAutomaticCompletion(editor) || editor.widgets?.some(widget => widget.id === Completion && widget.newState.automatic))) {
|
|
19620
|
-
void updateAutomaticCompletionDeferred(uid).then(() => invoke$
|
|
19795
|
+
void updateAutomaticCompletionDeferred(uid).then(() => invoke$e('Editor.renderPending', uid)).catch(error => handleError$1(error, 'Failed to open completion widget: '));
|
|
19621
19796
|
}
|
|
19622
19797
|
};
|
|
19798
|
+
return typingCommand;
|
|
19623
19799
|
};
|
|
19624
19800
|
const deleteLeftCommand = wrapTypingCommand(deleteCharacterLeft, () => false, () => false);
|
|
19625
19801
|
const typeCommand = wrapTypingCommand(type, () => true, Boolean);
|
|
@@ -19730,6 +19906,7 @@ const commandMap = {
|
|
|
19730
19906
|
'Editor.handleBlur': wrapCommand(handleBlur$1),
|
|
19731
19907
|
'Editor.handleClickAtPosition': wrapCommand(handleClickAtPosition),
|
|
19732
19908
|
'Editor.handleContextMenu': wrapCommand(handleContextMenu),
|
|
19909
|
+
'Editor.handleDirectMessagePort': port => handleDirectMessagePort(port, commandMap),
|
|
19733
19910
|
'Editor.handleDoubleClick': wrapCommand(handleDoubleClick),
|
|
19734
19911
|
'Editor.handleFocus': wrapFocusCommand(handleFocus$1),
|
|
19735
19912
|
'Editor.handleKeyUp': wrapCommand(handleKeyUp, true),
|
|
@@ -19792,6 +19969,7 @@ const commandMap = {
|
|
|
19792
19969
|
'Editor.refreshTextDecorations': wrapCommand(refreshTextDecorations),
|
|
19793
19970
|
'Editor.render': renderEditor,
|
|
19794
19971
|
'Editor.render2': render2,
|
|
19972
|
+
'Editor.renderDirect2': renderDirect2,
|
|
19795
19973
|
'Editor.renderEventListeners': renderEventListeners,
|
|
19796
19974
|
'Editor.replaceRange': wrapCommand(replaceRange),
|
|
19797
19975
|
'Editor.rerender': wrapCommand(rerender),
|