@lvce-editor/editor-worker 19.72.10 → 19.73.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 +449 -224
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -7048,6 +7048,408 @@ const disposeEditor = async editorUid => {
|
|
|
7048
7048
|
return commands;
|
|
7049
7049
|
};
|
|
7050
7050
|
|
|
7051
|
+
const getIndex = (widgets, id) => {
|
|
7052
|
+
for (const [i, widget] of widgets.entries()) {
|
|
7053
|
+
if (widget.id === id) {
|
|
7054
|
+
return i;
|
|
7055
|
+
}
|
|
7056
|
+
}
|
|
7057
|
+
return -1;
|
|
7058
|
+
};
|
|
7059
|
+
const removeEditorWidget = (widgets, id) => {
|
|
7060
|
+
const index = getIndex(widgets, id);
|
|
7061
|
+
const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
|
|
7062
|
+
return newWidgets;
|
|
7063
|
+
};
|
|
7064
|
+
|
|
7065
|
+
const closeCompletion = editor => {
|
|
7066
|
+
const {
|
|
7067
|
+
widgets
|
|
7068
|
+
} = editor;
|
|
7069
|
+
const widgetRevision = next(editor.uid);
|
|
7070
|
+
if (widgets.every(widget => widget.id !== Completion)) {
|
|
7071
|
+
return editor;
|
|
7072
|
+
}
|
|
7073
|
+
return {
|
|
7074
|
+
...editor,
|
|
7075
|
+
additionalFocus: 0,
|
|
7076
|
+
focused: true,
|
|
7077
|
+
widgetRevision,
|
|
7078
|
+
widgets: removeEditorWidget(widgets, Completion)
|
|
7079
|
+
};
|
|
7080
|
+
};
|
|
7081
|
+
|
|
7082
|
+
const hasWidget = (widgets, id) => {
|
|
7083
|
+
for (const widget of widgets) {
|
|
7084
|
+
if (widget.id === id) {
|
|
7085
|
+
return true;
|
|
7086
|
+
}
|
|
7087
|
+
}
|
|
7088
|
+
return false;
|
|
7089
|
+
};
|
|
7090
|
+
|
|
7091
|
+
const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGenerator, fullFocus) => {
|
|
7092
|
+
const {
|
|
7093
|
+
widgets = []
|
|
7094
|
+
} = editor;
|
|
7095
|
+
if (hasWidget(widgets, widgetId)) {
|
|
7096
|
+
return editor;
|
|
7097
|
+
}
|
|
7098
|
+
const widgetRevision = next(editor.uid);
|
|
7099
|
+
const widget = factory();
|
|
7100
|
+
// @ts-ignore
|
|
7101
|
+
widget.newState.editorUid = editor.uid;
|
|
7102
|
+
const newState = await newStateGenerator(widget.newState, editor.uid);
|
|
7103
|
+
if (!newState) {
|
|
7104
|
+
return editor;
|
|
7105
|
+
}
|
|
7106
|
+
if (get(editor.uid) !== widgetRevision) {
|
|
7107
|
+
return get$8(editor.uid)?.newState || editor;
|
|
7108
|
+
}
|
|
7109
|
+
// @ts-ignore
|
|
7110
|
+
newState.editorUid = editor.uid;
|
|
7111
|
+
const latestWidget = {
|
|
7112
|
+
...widget,
|
|
7113
|
+
newState
|
|
7114
|
+
};
|
|
7115
|
+
const newWidgets = [...widgets, latestWidget];
|
|
7116
|
+
const newFocus = !fullFocus;
|
|
7117
|
+
const newEditor = {
|
|
7118
|
+
...editor,
|
|
7119
|
+
additionalFocus: fullFocus ? 0 : focusKey,
|
|
7120
|
+
focus: fullFocus ? focusKey : FocusEditorText$1,
|
|
7121
|
+
focused: newFocus,
|
|
7122
|
+
widgetRevision,
|
|
7123
|
+
widgets: newWidgets
|
|
7124
|
+
};
|
|
7125
|
+
return newEditor;
|
|
7126
|
+
};
|
|
7127
|
+
|
|
7128
|
+
const state$5 = {
|
|
7129
|
+
configured: false,
|
|
7130
|
+
lastId: -1,
|
|
7131
|
+
nextId: 0
|
|
7132
|
+
};
|
|
7133
|
+
const configure = (start, end) => {
|
|
7134
|
+
const {
|
|
7135
|
+
configured
|
|
7136
|
+
} = state$5;
|
|
7137
|
+
if (configured) {
|
|
7138
|
+
throw new Error('Component id range is already configured');
|
|
7139
|
+
}
|
|
7140
|
+
if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start <= 0 || end < start) {
|
|
7141
|
+
throw new Error('Invalid component id range');
|
|
7142
|
+
}
|
|
7143
|
+
state$5.nextId = start;
|
|
7144
|
+
state$5.lastId = end;
|
|
7145
|
+
state$5.configured = true;
|
|
7146
|
+
};
|
|
7147
|
+
const create$8 = () => {
|
|
7148
|
+
const {
|
|
7149
|
+
configured,
|
|
7150
|
+
lastId,
|
|
7151
|
+
nextId
|
|
7152
|
+
} = state$5;
|
|
7153
|
+
if (!configured) {
|
|
7154
|
+
// Compatibility with renderer versions that do not assign worker id ranges.
|
|
7155
|
+
return Math.random();
|
|
7156
|
+
}
|
|
7157
|
+
if (nextId > lastId) {
|
|
7158
|
+
throw new Error('Component id range exhausted');
|
|
7159
|
+
}
|
|
7160
|
+
return state$5.nextId++;
|
|
7161
|
+
};
|
|
7162
|
+
|
|
7163
|
+
const create$7 = () => {
|
|
7164
|
+
const completionUid = create$8();
|
|
7165
|
+
const completionWidget = {
|
|
7166
|
+
id: Completion,
|
|
7167
|
+
newState: {
|
|
7168
|
+
commands: [],
|
|
7169
|
+
height: 0,
|
|
7170
|
+
uid: completionUid,
|
|
7171
|
+
width: 0,
|
|
7172
|
+
x: 0,
|
|
7173
|
+
y: 0
|
|
7174
|
+
},
|
|
7175
|
+
oldState: {
|
|
7176
|
+
commands: [],
|
|
7177
|
+
height: 0,
|
|
7178
|
+
uid: completionUid,
|
|
7179
|
+
width: 0,
|
|
7180
|
+
x: 0,
|
|
7181
|
+
y: 0
|
|
7182
|
+
}
|
|
7183
|
+
};
|
|
7184
|
+
return completionWidget;
|
|
7185
|
+
};
|
|
7186
|
+
|
|
7187
|
+
const {
|
|
7188
|
+
invoke: invoke$4,
|
|
7189
|
+
setFactory
|
|
7190
|
+
} = createLazyRpc(CompletionWorker);
|
|
7191
|
+
|
|
7192
|
+
const updateWidget = (editor, widgetId, newState) => {
|
|
7193
|
+
// TODO avoid closure
|
|
7194
|
+
const isWidget = widget => {
|
|
7195
|
+
return widget.id === widgetId;
|
|
7196
|
+
};
|
|
7197
|
+
const childIndex = editor.widgets.findIndex(isWidget);
|
|
7198
|
+
if (childIndex === -1) {
|
|
7199
|
+
return editor;
|
|
7200
|
+
}
|
|
7201
|
+
// TODO scroll up/down if necessary
|
|
7202
|
+
const childWidget = editor.widgets[childIndex];
|
|
7203
|
+
const newWidget = {
|
|
7204
|
+
...childWidget,
|
|
7205
|
+
newState,
|
|
7206
|
+
oldState: childWidget.newState
|
|
7207
|
+
};
|
|
7208
|
+
const newWidgets = [...editor.widgets.slice(0, childIndex), newWidget, ...editor.widgets.slice(childIndex + 1)];
|
|
7209
|
+
return {
|
|
7210
|
+
...editor,
|
|
7211
|
+
widgets: newWidgets
|
|
7212
|
+
};
|
|
7213
|
+
};
|
|
7214
|
+
|
|
7215
|
+
const disposeCompletion = async uid => {
|
|
7216
|
+
try {
|
|
7217
|
+
await invoke$4('Completions.dispose', uid);
|
|
7218
|
+
} catch {
|
|
7219
|
+
// A completion worker may already have disposed this state during shutdown.
|
|
7220
|
+
}
|
|
7221
|
+
};
|
|
7222
|
+
const newStateGenerator$4 = async (state, parentUid, markCreated, automatic) => {
|
|
7223
|
+
const {
|
|
7224
|
+
height,
|
|
7225
|
+
uid,
|
|
7226
|
+
width,
|
|
7227
|
+
x,
|
|
7228
|
+
y
|
|
7229
|
+
} = state;
|
|
7230
|
+
const {
|
|
7231
|
+
newState
|
|
7232
|
+
} = get$8(parentUid);
|
|
7233
|
+
const {
|
|
7234
|
+
applicationId,
|
|
7235
|
+
languageId
|
|
7236
|
+
} = newState;
|
|
7237
|
+
await invoke$4('Completions.create', uid, x, y, width, height, parentUid, languageId, applicationId);
|
|
7238
|
+
markCreated();
|
|
7239
|
+
await invoke$4('Completions.loadContent', uid, automatic);
|
|
7240
|
+
if (automatic && !(await invoke$4('Completions.hasItems', uid))) {
|
|
7241
|
+
return undefined;
|
|
7242
|
+
}
|
|
7243
|
+
const diff = await invoke$4('Completions.diff2', uid);
|
|
7244
|
+
const commands = await invoke$4('Completions.render2', uid, diff);
|
|
7245
|
+
return {
|
|
7246
|
+
...state,
|
|
7247
|
+
automatic,
|
|
7248
|
+
commands
|
|
7249
|
+
};
|
|
7250
|
+
};
|
|
7251
|
+
const openCompletion = async (editor, automatic = false) => {
|
|
7252
|
+
const widget = (editor.widgets || []).find(candidate => candidate.id === Completion);
|
|
7253
|
+
if (widget && (automatic || widget.newState.automatic)) {
|
|
7254
|
+
const {
|
|
7255
|
+
uid
|
|
7256
|
+
} = widget.newState;
|
|
7257
|
+
await invoke$4('Completions.loadContent', uid, automatic);
|
|
7258
|
+
if (get$8(editor.uid)?.newState !== editor) {
|
|
7259
|
+
return get$8(editor.uid)?.newState || editor;
|
|
7260
|
+
}
|
|
7261
|
+
if (automatic && !(await invoke$4('Completions.hasItems', uid))) {
|
|
7262
|
+
return closeCompletion(editor);
|
|
7263
|
+
}
|
|
7264
|
+
const diff = await invoke$4('Completions.diff2', uid);
|
|
7265
|
+
const commands = await invoke$4('Completions.render2', uid, diff);
|
|
7266
|
+
return updateWidget(editor, Completion, {
|
|
7267
|
+
...widget.newState,
|
|
7268
|
+
automatic,
|
|
7269
|
+
commands
|
|
7270
|
+
});
|
|
7271
|
+
}
|
|
7272
|
+
let completionUid = 0;
|
|
7273
|
+
let created = false;
|
|
7274
|
+
const generateState = async (state, parentUid) => {
|
|
7275
|
+
completionUid = state.uid;
|
|
7276
|
+
try {
|
|
7277
|
+
const result = await newStateGenerator$4(state, parentUid, () => {
|
|
7278
|
+
created = true;
|
|
7279
|
+
}, automatic);
|
|
7280
|
+
return result;
|
|
7281
|
+
} catch (error) {
|
|
7282
|
+
if (created) {
|
|
7283
|
+
await disposeCompletion(completionUid);
|
|
7284
|
+
}
|
|
7285
|
+
throw error;
|
|
7286
|
+
}
|
|
7287
|
+
};
|
|
7288
|
+
const fullFocus = false;
|
|
7289
|
+
const result = await addWidgetToEditor(Completion, EditorCompletion, editor, create$7, generateState, fullFocus);
|
|
7290
|
+
const wasAdded = (result?.widgets || []).some(widget => widget.id === Completion && widget.newState.uid === completionUid);
|
|
7291
|
+
const currentEditor = get$8(editor.uid)?.newState;
|
|
7292
|
+
if (created && (!wasAdded || currentEditor !== editor)) {
|
|
7293
|
+
await disposeCompletion(completionUid);
|
|
7294
|
+
}
|
|
7295
|
+
return result;
|
|
7296
|
+
};
|
|
7297
|
+
|
|
7298
|
+
const expressionKeywords = new Set(['return', 'throw', 'yield', 'await', 'typeof', 'void', 'delete', 'case', 'new', 'in', 'of']);
|
|
7299
|
+
const isIdentifier = character => /[\w$]/u.test(character);
|
|
7300
|
+
|
|
7301
|
+
// Scan the document prefix, retaining lexical state across lines and nested template expressions.
|
|
7302
|
+
const isTypeScriptCode = text => {
|
|
7303
|
+
const frames = [{
|
|
7304
|
+
context: 'code',
|
|
7305
|
+
depth: 0
|
|
7306
|
+
}];
|
|
7307
|
+
let expressionStart = true;
|
|
7308
|
+
let regexClass = false;
|
|
7309
|
+
scan: for (let index = 0; index < text.length; index++) {
|
|
7310
|
+
const frame = frames.at(-1);
|
|
7311
|
+
const character = text[index];
|
|
7312
|
+
const next = text[index + 1];
|
|
7313
|
+
switch (frame.context) {
|
|
7314
|
+
case 'blockComment':
|
|
7315
|
+
if (character === '*' && next === '/') {
|
|
7316
|
+
frames.pop();
|
|
7317
|
+
index++;
|
|
7318
|
+
}
|
|
7319
|
+
continue scan;
|
|
7320
|
+
case 'code':
|
|
7321
|
+
if (character === '/' && next === '/') {
|
|
7322
|
+
frames.push({
|
|
7323
|
+
context: 'lineComment',
|
|
7324
|
+
depth: 0
|
|
7325
|
+
});
|
|
7326
|
+
index++;
|
|
7327
|
+
} else if (character === '/' && next === '*') {
|
|
7328
|
+
frames.push({
|
|
7329
|
+
context: 'blockComment',
|
|
7330
|
+
depth: 0
|
|
7331
|
+
});
|
|
7332
|
+
index++;
|
|
7333
|
+
} else if (["'", '"', '`'].includes(character)) {
|
|
7334
|
+
frames.push({
|
|
7335
|
+
context: character === "'" ? 'single' : character === '"' ? 'double' : 'template',
|
|
7336
|
+
depth: 0
|
|
7337
|
+
});
|
|
7338
|
+
} else if (character === '/' && expressionStart) {
|
|
7339
|
+
frames.push({
|
|
7340
|
+
context: 'regex',
|
|
7341
|
+
depth: 0
|
|
7342
|
+
});
|
|
7343
|
+
regexClass = false;
|
|
7344
|
+
} else if (character === '{') {
|
|
7345
|
+
frame.depth++;
|
|
7346
|
+
expressionStart = true;
|
|
7347
|
+
} else if (character === '}') {
|
|
7348
|
+
frame.depth--;
|
|
7349
|
+
if (frame.depth === 0 && frames.length > 1) {
|
|
7350
|
+
frames.pop();
|
|
7351
|
+
}
|
|
7352
|
+
expressionStart = false;
|
|
7353
|
+
} else if (isIdentifier(character)) {
|
|
7354
|
+
const start = index;
|
|
7355
|
+
while (index + 1 < text.length && isIdentifier(text[index + 1])) {
|
|
7356
|
+
index++;
|
|
7357
|
+
}
|
|
7358
|
+
expressionStart = expressionKeywords.has(text.slice(start, index + 1));
|
|
7359
|
+
} else if (!/\s/u.test(character)) {
|
|
7360
|
+
expressionStart = '=(:,[!&|?;+-*%<>'.includes(character);
|
|
7361
|
+
}
|
|
7362
|
+
continue scan;
|
|
7363
|
+
case 'double':
|
|
7364
|
+
case 'single':
|
|
7365
|
+
if (character === '\\') {
|
|
7366
|
+
index++;
|
|
7367
|
+
} else if ([frame.context === 'single' ? "'" : '"', '\n', '\r'].includes(character)) {
|
|
7368
|
+
frames.pop();
|
|
7369
|
+
expressionStart = false;
|
|
7370
|
+
}
|
|
7371
|
+
continue scan;
|
|
7372
|
+
case 'lineComment':
|
|
7373
|
+
if (['\n', '\r'].includes(character)) {
|
|
7374
|
+
frames.pop();
|
|
7375
|
+
}
|
|
7376
|
+
continue scan;
|
|
7377
|
+
case 'regex':
|
|
7378
|
+
switch (character) {
|
|
7379
|
+
case '[':
|
|
7380
|
+
{
|
|
7381
|
+
regexClass = true;
|
|
7382
|
+
continue scan;
|
|
7383
|
+
}
|
|
7384
|
+
case ']':
|
|
7385
|
+
{
|
|
7386
|
+
regexClass = false;
|
|
7387
|
+
continue scan;
|
|
7388
|
+
}
|
|
7389
|
+
case '\\':
|
|
7390
|
+
{
|
|
7391
|
+
index++;
|
|
7392
|
+
continue scan;
|
|
7393
|
+
}
|
|
7394
|
+
default:
|
|
7395
|
+
if (character === '/' && !regexClass || ['\n', '\r'].includes(character)) {
|
|
7396
|
+
frames.pop();
|
|
7397
|
+
expressionStart = false;
|
|
7398
|
+
}
|
|
7399
|
+
}
|
|
7400
|
+
continue scan;
|
|
7401
|
+
case 'template':
|
|
7402
|
+
if (character === '\\') {
|
|
7403
|
+
index++;
|
|
7404
|
+
} else if (character === '`') {
|
|
7405
|
+
frames.pop();
|
|
7406
|
+
expressionStart = false;
|
|
7407
|
+
} else if (character === '$' && next === '{') {
|
|
7408
|
+
frames.push({
|
|
7409
|
+
context: 'code',
|
|
7410
|
+
depth: 1
|
|
7411
|
+
});
|
|
7412
|
+
expressionStart = true;
|
|
7413
|
+
index++;
|
|
7414
|
+
}
|
|
7415
|
+
continue scan;
|
|
7416
|
+
}
|
|
7417
|
+
}
|
|
7418
|
+
return frames.at(-1).context === 'code';
|
|
7419
|
+
};
|
|
7420
|
+
|
|
7421
|
+
const shouldOpenAutomaticCompletion = editor => {
|
|
7422
|
+
const {
|
|
7423
|
+
completionsOnType,
|
|
7424
|
+
isQuickSuggestionsEnabled,
|
|
7425
|
+
languageId,
|
|
7426
|
+
largeFile,
|
|
7427
|
+
lines,
|
|
7428
|
+
selections
|
|
7429
|
+
} = editor;
|
|
7430
|
+
if (largeFile || !(completionsOnType || languageId === 'typescript' && isQuickSuggestionsEnabled)) {
|
|
7431
|
+
return false;
|
|
7432
|
+
}
|
|
7433
|
+
if (languageId !== 'typescript') {
|
|
7434
|
+
return true;
|
|
7435
|
+
}
|
|
7436
|
+
const rowIndex = selections[0];
|
|
7437
|
+
const columnIndex = selections[1];
|
|
7438
|
+
const prefix = [...lines.slice(0, rowIndex), lines[rowIndex].slice(0, columnIndex)].join('\n');
|
|
7439
|
+
return /[\w$.]$/u.test(prefix) && isTypeScriptCode(prefix);
|
|
7440
|
+
};
|
|
7441
|
+
|
|
7442
|
+
const updateAutomaticCompletion = async editor => {
|
|
7443
|
+
const widget = (editor.widgets || []).find(candidate => candidate.id === Completion);
|
|
7444
|
+
if (widget && !widget.newState.automatic) {
|
|
7445
|
+
return editor;
|
|
7446
|
+
}
|
|
7447
|
+
if (!shouldOpenAutomaticCompletion(editor)) {
|
|
7448
|
+
return widget ? closeCompletion(editor) : editor;
|
|
7449
|
+
}
|
|
7450
|
+
return openCompletion(editor, true);
|
|
7451
|
+
};
|
|
7452
|
+
|
|
7051
7453
|
const getAcceptedLines = (lines, conflict, action) => {
|
|
7052
7454
|
const current = lines.slice(conflict.currentStartRowIndex, conflict.currentEndRowIndex);
|
|
7053
7455
|
const incoming = lines.slice(conflict.incomingStartRowIndex, conflict.incomingEndRowIndex);
|
|
@@ -7542,55 +7944,6 @@ const isFormattingError = error => {
|
|
|
7542
7944
|
return error && error instanceof Error && error.message.startsWith(expectedErrorMessage$1);
|
|
7543
7945
|
};
|
|
7544
7946
|
|
|
7545
|
-
const state$5 = {
|
|
7546
|
-
configured: false,
|
|
7547
|
-
lastId: -1,
|
|
7548
|
-
nextId: 0
|
|
7549
|
-
};
|
|
7550
|
-
const configure = (start, end) => {
|
|
7551
|
-
const {
|
|
7552
|
-
configured
|
|
7553
|
-
} = state$5;
|
|
7554
|
-
if (configured) {
|
|
7555
|
-
throw new Error('Component id range is already configured');
|
|
7556
|
-
}
|
|
7557
|
-
if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start <= 0 || end < start) {
|
|
7558
|
-
throw new Error('Invalid component id range');
|
|
7559
|
-
}
|
|
7560
|
-
state$5.nextId = start;
|
|
7561
|
-
state$5.lastId = end;
|
|
7562
|
-
state$5.configured = true;
|
|
7563
|
-
};
|
|
7564
|
-
const create$8 = () => {
|
|
7565
|
-
const {
|
|
7566
|
-
configured,
|
|
7567
|
-
lastId,
|
|
7568
|
-
nextId
|
|
7569
|
-
} = state$5;
|
|
7570
|
-
if (!configured) {
|
|
7571
|
-
// Compatibility with renderer versions that do not assign worker id ranges.
|
|
7572
|
-
return Math.random();
|
|
7573
|
-
}
|
|
7574
|
-
if (nextId > lastId) {
|
|
7575
|
-
throw new Error('Component id range exhausted');
|
|
7576
|
-
}
|
|
7577
|
-
return state$5.nextId++;
|
|
7578
|
-
};
|
|
7579
|
-
|
|
7580
|
-
const getIndex = (widgets, id) => {
|
|
7581
|
-
for (const [i, widget] of widgets.entries()) {
|
|
7582
|
-
if (widget.id === id) {
|
|
7583
|
-
return i;
|
|
7584
|
-
}
|
|
7585
|
-
}
|
|
7586
|
-
return -1;
|
|
7587
|
-
};
|
|
7588
|
-
const removeEditorWidget = (widgets, id) => {
|
|
7589
|
-
const index = getIndex(widgets, id);
|
|
7590
|
-
const newWidgets = [...widgets.slice(0, index), ...widgets.slice(index + 1)];
|
|
7591
|
-
return newWidgets;
|
|
7592
|
-
};
|
|
7593
|
-
|
|
7594
7947
|
const Message = 9;
|
|
7595
7948
|
|
|
7596
7949
|
const getAccurateColumnIndexAscii = async (line, guess, averageCharWidth, eventX, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth) => {
|
|
@@ -7606,7 +7959,7 @@ const getAccurateColumnIndexAscii = async (line, guess, averageCharWidth, eventX
|
|
|
7606
7959
|
const supported = () => {
|
|
7607
7960
|
return 'Segmenter' in Intl;
|
|
7608
7961
|
};
|
|
7609
|
-
const create$
|
|
7962
|
+
const create$6 = () => {
|
|
7610
7963
|
// @ts-ignore
|
|
7611
7964
|
const segmenter = new Intl.Segmenter();
|
|
7612
7965
|
return {
|
|
@@ -7641,7 +7994,7 @@ const create$7 = () => {
|
|
|
7641
7994
|
};
|
|
7642
7995
|
|
|
7643
7996
|
const getAccurateColumnIndexUnicode = async (line, guess, averageCharWidth, eventX, fontWeight, fontSize, fontFamily, letterSpacing) => {
|
|
7644
|
-
const segmenter = create$
|
|
7997
|
+
const segmenter = create$6();
|
|
7645
7998
|
const segments = segmenter.getSegments(line);
|
|
7646
7999
|
const isMonospaceFont = false;
|
|
7647
8000
|
const charWidth = 0;
|
|
@@ -8321,15 +8674,6 @@ const closeWidgetsMaybe = widgets => {
|
|
|
8321
8674
|
return widgets.filter(widget => isPersistentWidget(widget.id));
|
|
8322
8675
|
};
|
|
8323
8676
|
|
|
8324
|
-
const hasWidget = (widgets, id) => {
|
|
8325
|
-
for (const widget of widgets) {
|
|
8326
|
-
if (widget.id === id) {
|
|
8327
|
-
return true;
|
|
8328
|
-
}
|
|
8329
|
-
}
|
|
8330
|
-
return false;
|
|
8331
|
-
};
|
|
8332
|
-
|
|
8333
8677
|
const handleBlur$1 = async editor => {
|
|
8334
8678
|
if (!editor.focused) {
|
|
8335
8679
|
return editor;
|
|
@@ -8745,23 +9089,6 @@ const closeCodeGenerator = editor => {
|
|
|
8745
9089
|
};
|
|
8746
9090
|
};
|
|
8747
9091
|
|
|
8748
|
-
const closeCompletion = editor => {
|
|
8749
|
-
const {
|
|
8750
|
-
widgets
|
|
8751
|
-
} = editor;
|
|
8752
|
-
const widgetRevision = next(editor.uid);
|
|
8753
|
-
if (widgets.every(widget => widget.id !== Completion)) {
|
|
8754
|
-
return editor;
|
|
8755
|
-
}
|
|
8756
|
-
return {
|
|
8757
|
-
...editor,
|
|
8758
|
-
additionalFocus: 0,
|
|
8759
|
-
focused: true,
|
|
8760
|
-
widgetRevision,
|
|
8761
|
-
widgets: removeEditorWidget(widgets, Completion)
|
|
8762
|
-
};
|
|
8763
|
-
};
|
|
8764
|
-
|
|
8765
9092
|
const isMatchingWidget$1 = widget => {
|
|
8766
9093
|
return widget.id === Find;
|
|
8767
9094
|
};
|
|
@@ -8831,44 +9158,7 @@ const closeSourceAction = editor => {
|
|
|
8831
9158
|
};
|
|
8832
9159
|
};
|
|
8833
9160
|
|
|
8834
|
-
const
|
|
8835
|
-
const {
|
|
8836
|
-
widgets = []
|
|
8837
|
-
} = editor;
|
|
8838
|
-
if (hasWidget(widgets, widgetId)) {
|
|
8839
|
-
return editor;
|
|
8840
|
-
}
|
|
8841
|
-
const widgetRevision = next(editor.uid);
|
|
8842
|
-
const widget = factory();
|
|
8843
|
-
// @ts-ignore
|
|
8844
|
-
widget.newState.editorUid = editor.uid;
|
|
8845
|
-
const newState = await newStateGenerator(widget.newState, editor.uid);
|
|
8846
|
-
if (!newState) {
|
|
8847
|
-
return editor;
|
|
8848
|
-
}
|
|
8849
|
-
if (get(editor.uid) !== widgetRevision) {
|
|
8850
|
-
return get$8(editor.uid)?.newState || editor;
|
|
8851
|
-
}
|
|
8852
|
-
// @ts-ignore
|
|
8853
|
-
newState.editorUid = editor.uid;
|
|
8854
|
-
const latestWidget = {
|
|
8855
|
-
...widget,
|
|
8856
|
-
newState
|
|
8857
|
-
};
|
|
8858
|
-
const newWidgets = [...widgets, latestWidget];
|
|
8859
|
-
const newFocus = !fullFocus;
|
|
8860
|
-
const newEditor = {
|
|
8861
|
-
...editor,
|
|
8862
|
-
additionalFocus: fullFocus ? 0 : focusKey,
|
|
8863
|
-
focus: fullFocus ? focusKey : FocusEditorText$1,
|
|
8864
|
-
focused: newFocus,
|
|
8865
|
-
widgetRevision,
|
|
8866
|
-
widgets: newWidgets
|
|
8867
|
-
};
|
|
8868
|
-
return newEditor;
|
|
8869
|
-
};
|
|
8870
|
-
|
|
8871
|
-
const create$6 = (bounds, range, undoStackIndex) => {
|
|
9161
|
+
const create$5 = (bounds, range, undoStackIndex) => {
|
|
8872
9162
|
const completionUid = create$8();
|
|
8873
9163
|
const state = {
|
|
8874
9164
|
...bounds,
|
|
@@ -8922,7 +9212,7 @@ const getColorPickerBounds = editor => {
|
|
|
8922
9212
|
};
|
|
8923
9213
|
};
|
|
8924
9214
|
|
|
8925
|
-
const newStateGenerator$
|
|
9215
|
+
const newStateGenerator$3 = (state, parentUid) => {
|
|
8926
9216
|
return loadContent$3(state, parentUid);
|
|
8927
9217
|
};
|
|
8928
9218
|
const openColorPicker = async editor => {
|
|
@@ -8932,8 +9222,8 @@ const openColorPicker = async editor => {
|
|
|
8932
9222
|
getColorPickerRange
|
|
8933
9223
|
} = await Promise.resolve().then(function () { return GetColorPickerRange; });
|
|
8934
9224
|
const range = await getColorPickerRange(editor);
|
|
8935
|
-
const createWidget = () => create$
|
|
8936
|
-
return addWidgetToEditor(ColorPicker$2, ColorPicker, editor, createWidget, newStateGenerator$
|
|
9225
|
+
const createWidget = () => create$5(bounds, range, editor.undoStack.length);
|
|
9226
|
+
return addWidgetToEditor(ColorPicker$2, ColorPicker, editor, createWidget, newStateGenerator$3, fullFocus);
|
|
8937
9227
|
};
|
|
8938
9228
|
const closeColorPicker = editor => {
|
|
8939
9229
|
const {
|
|
@@ -9247,7 +9537,7 @@ const characterLeft = (line, columnIndex) => {
|
|
|
9247
9537
|
if (columnIndex > line.length) {
|
|
9248
9538
|
return 1;
|
|
9249
9539
|
}
|
|
9250
|
-
const segmenter = create$
|
|
9540
|
+
const segmenter = create$6();
|
|
9251
9541
|
const last = segmenter.at(line, columnIndex - 1);
|
|
9252
9542
|
if (!last) {
|
|
9253
9543
|
return 1;
|
|
@@ -9262,7 +9552,7 @@ const characterRight = (line, columnIndex) => {
|
|
|
9262
9552
|
if (!supported()) {
|
|
9263
9553
|
return 1;
|
|
9264
9554
|
}
|
|
9265
|
-
const segmenter = create$
|
|
9555
|
+
const segmenter = create$6();
|
|
9266
9556
|
const next = segmenter.at(line, columnIndex);
|
|
9267
9557
|
// @ts-ignore
|
|
9268
9558
|
return next.segment.length;
|
|
@@ -11006,7 +11296,7 @@ const getDiagnosticHoverInfo = async (editor, diagnostic) => {
|
|
|
11006
11296
|
};
|
|
11007
11297
|
};
|
|
11008
11298
|
|
|
11009
|
-
const create$
|
|
11299
|
+
const create$4 = () => {
|
|
11010
11300
|
const uid = create$8();
|
|
11011
11301
|
const widget = {
|
|
11012
11302
|
id: Hover,
|
|
@@ -11225,29 +11515,6 @@ const loadHoverContent = async (state, position) => {
|
|
|
11225
11515
|
};
|
|
11226
11516
|
};
|
|
11227
11517
|
|
|
11228
|
-
const updateWidget = (editor, widgetId, newState) => {
|
|
11229
|
-
// TODO avoid closure
|
|
11230
|
-
const isWidget = widget => {
|
|
11231
|
-
return widget.id === widgetId;
|
|
11232
|
-
};
|
|
11233
|
-
const childIndex = editor.widgets.findIndex(isWidget);
|
|
11234
|
-
if (childIndex === -1) {
|
|
11235
|
-
return editor;
|
|
11236
|
-
}
|
|
11237
|
-
// TODO scroll up/down if necessary
|
|
11238
|
-
const childWidget = editor.widgets[childIndex];
|
|
11239
|
-
const newWidget = {
|
|
11240
|
-
...childWidget,
|
|
11241
|
-
newState,
|
|
11242
|
-
oldState: childWidget.newState
|
|
11243
|
-
};
|
|
11244
|
-
const newWidgets = [...editor.widgets.slice(0, childIndex), newWidget, ...editor.widgets.slice(childIndex + 1)];
|
|
11245
|
-
return {
|
|
11246
|
-
...editor,
|
|
11247
|
-
widgets: newWidgets
|
|
11248
|
-
};
|
|
11249
|
-
};
|
|
11250
|
-
|
|
11251
11518
|
const getHoverWidgetIndex = widgets => {
|
|
11252
11519
|
return widgets.findIndex(widget => widget.id === Hover);
|
|
11253
11520
|
};
|
|
@@ -11257,7 +11524,7 @@ const applyHoverContent = async (editor, getNewState) => {
|
|
|
11257
11524
|
} = editor;
|
|
11258
11525
|
const widgetIndex = getHoverWidgetIndex(widgets);
|
|
11259
11526
|
if (widgetIndex === -1) {
|
|
11260
|
-
return addWidgetToEditor(Hover, FocusEditorHover, editor, create$
|
|
11527
|
+
return addWidgetToEditor(Hover, FocusEditorHover, editor, create$4, getNewState);
|
|
11261
11528
|
}
|
|
11262
11529
|
const widgetRevision = next(editor.uid);
|
|
11263
11530
|
const widget = widgets[widgetIndex];
|
|
@@ -12175,7 +12442,7 @@ const previousDiagnostic = editor => {
|
|
|
12175
12442
|
const Script = 2;
|
|
12176
12443
|
const Unknown$1 = 0;
|
|
12177
12444
|
|
|
12178
|
-
const create$
|
|
12445
|
+
const create$3 = () => {
|
|
12179
12446
|
const completionUid = create$8();
|
|
12180
12447
|
const widget = {
|
|
12181
12448
|
id: CodeGenerator,
|
|
@@ -12203,7 +12470,7 @@ const create$4 = () => {
|
|
|
12203
12470
|
return widget;
|
|
12204
12471
|
};
|
|
12205
12472
|
|
|
12206
|
-
const newStateGenerator$
|
|
12473
|
+
const newStateGenerator$2 = async state => {
|
|
12207
12474
|
const latestState = {
|
|
12208
12475
|
...state,
|
|
12209
12476
|
height: 45,
|
|
@@ -12215,65 +12482,7 @@ const newStateGenerator$3 = async state => {
|
|
|
12215
12482
|
};
|
|
12216
12483
|
const openCodeGenerator = async editor => {
|
|
12217
12484
|
const fullFocus = true;
|
|
12218
|
-
return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create$
|
|
12219
|
-
};
|
|
12220
|
-
|
|
12221
|
-
const create$3 = () => {
|
|
12222
|
-
const completionUid = create$8();
|
|
12223
|
-
const completionWidget = {
|
|
12224
|
-
id: Completion,
|
|
12225
|
-
newState: {
|
|
12226
|
-
commands: [],
|
|
12227
|
-
height: 0,
|
|
12228
|
-
uid: completionUid,
|
|
12229
|
-
width: 0,
|
|
12230
|
-
x: 0,
|
|
12231
|
-
y: 0
|
|
12232
|
-
},
|
|
12233
|
-
oldState: {
|
|
12234
|
-
commands: [],
|
|
12235
|
-
height: 0,
|
|
12236
|
-
uid: completionUid,
|
|
12237
|
-
width: 0,
|
|
12238
|
-
x: 0,
|
|
12239
|
-
y: 0
|
|
12240
|
-
}
|
|
12241
|
-
};
|
|
12242
|
-
return completionWidget;
|
|
12243
|
-
};
|
|
12244
|
-
|
|
12245
|
-
const {
|
|
12246
|
-
invoke: invoke$4,
|
|
12247
|
-
setFactory
|
|
12248
|
-
} = createLazyRpc(CompletionWorker);
|
|
12249
|
-
|
|
12250
|
-
const newStateGenerator$2 = async (state, parentUid) => {
|
|
12251
|
-
const {
|
|
12252
|
-
height,
|
|
12253
|
-
uid,
|
|
12254
|
-
width,
|
|
12255
|
-
x,
|
|
12256
|
-
y
|
|
12257
|
-
} = state;
|
|
12258
|
-
const {
|
|
12259
|
-
newState
|
|
12260
|
-
} = get$8(parentUid);
|
|
12261
|
-
const {
|
|
12262
|
-
applicationId,
|
|
12263
|
-
languageId
|
|
12264
|
-
} = newState;
|
|
12265
|
-
await invoke$4('Completions.create', uid, x, y, width, height, parentUid, languageId, applicationId);
|
|
12266
|
-
await invoke$4('Completions.loadContent', uid);
|
|
12267
|
-
const diff = await invoke$4('Completions.diff2', uid);
|
|
12268
|
-
const commands = await invoke$4('Completions.render2', uid, diff);
|
|
12269
|
-
return {
|
|
12270
|
-
...state,
|
|
12271
|
-
commands
|
|
12272
|
-
};
|
|
12273
|
-
};
|
|
12274
|
-
const openCompletion = async editor => {
|
|
12275
|
-
const fullFocus = false;
|
|
12276
|
-
return addWidgetToEditor(Completion, EditorCompletion, editor, create$3, newStateGenerator$2, fullFocus);
|
|
12485
|
+
return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create$3, newStateGenerator$2, fullFocus);
|
|
12277
12486
|
};
|
|
12278
12487
|
|
|
12279
12488
|
const isFunctional = widgetId => {
|
|
@@ -13808,7 +14017,7 @@ const showSignatureHelp = async editor => {
|
|
|
13808
14017
|
const newStateGenerator = async state => {
|
|
13809
14018
|
return loadSignatureHelpContent(state);
|
|
13810
14019
|
};
|
|
13811
|
-
return addWidgetToEditor(Hover, FocusEditorHover, editorWithoutHover, create$
|
|
14020
|
+
return addWidgetToEditor(Hover, FocusEditorHover, editorWithoutHover, create$4, newStateGenerator);
|
|
13812
14021
|
};
|
|
13813
14022
|
|
|
13814
14023
|
const create = () => {
|
|
@@ -14429,14 +14638,7 @@ const toggleCompletion = async editor => {
|
|
|
14429
14638
|
|
|
14430
14639
|
const type = async (editor, text) => {
|
|
14431
14640
|
const changes = editorReplaceSelections(editor, [text], EditorType);
|
|
14432
|
-
|
|
14433
|
-
if (newEditor.completionsOnType) {
|
|
14434
|
-
// TODO if completion widget is already visible, advance
|
|
14435
|
-
// TODO if character typed is space or tab or separator, close completions
|
|
14436
|
-
const withCompletion = await openCompletion(newEditor);
|
|
14437
|
-
return withCompletion;
|
|
14438
|
-
}
|
|
14439
|
-
return newEditor;
|
|
14641
|
+
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
14440
14642
|
};
|
|
14441
14643
|
|
|
14442
14644
|
const Slash = '/';
|
|
@@ -14815,6 +15017,15 @@ const add$7 = widget => {
|
|
|
14815
15017
|
const remove$6 = widget => {
|
|
14816
15018
|
return [];
|
|
14817
15019
|
};
|
|
15020
|
+
const fns = createFns(['handleEditorType', 'handleEditorDeleteLeft'], 'Completions', Completion);
|
|
15021
|
+
const handleEditorType$1 = editor => {
|
|
15022
|
+
const widget = (editor.widgets || []).find(candidate => candidate.id === Completion);
|
|
15023
|
+
return widget?.newState.automatic ? editor : fns.handleEditorType(editor);
|
|
15024
|
+
};
|
|
15025
|
+
const handleEditorDeleteLeft$1 = editor => {
|
|
15026
|
+
const widget = (editor.widgets || []).find(candidate => candidate.id === Completion);
|
|
15027
|
+
return widget?.newState.automatic ? editor : fns.handleEditorDeleteLeft(editor);
|
|
15028
|
+
};
|
|
14818
15029
|
const {
|
|
14819
15030
|
close: close$3,
|
|
14820
15031
|
closeDetails: closeDetails$1,
|
|
@@ -14825,8 +15036,6 @@ const {
|
|
|
14825
15036
|
focusPrevious: focusPrevious$1,
|
|
14826
15037
|
handleEditorBlur,
|
|
14827
15038
|
handleEditorClick,
|
|
14828
|
-
handleEditorDeleteLeft: handleEditorDeleteLeft$1,
|
|
14829
|
-
handleEditorType: handleEditorType$1,
|
|
14830
15039
|
handlePointerDown,
|
|
14831
15040
|
handleWheel: handleWheel$1,
|
|
14832
15041
|
openDetails,
|
|
@@ -18978,6 +19187,22 @@ const resize = async (editor, dimensions) => {
|
|
|
18978
19187
|
const resizedEditor = resize$2(editor, dimensions, editor.columnWidth);
|
|
18979
19188
|
return resize$1(resizedEditor, dimensions);
|
|
18980
19189
|
};
|
|
19190
|
+
const openCompletionDeferred = wrapDeferredCommand(openCompletion);
|
|
19191
|
+
const updateAutomaticCompletionDeferred = wrapDeferredCommand(updateAutomaticCompletion);
|
|
19192
|
+
const wrapTypingCommand = (fn, shouldOpenCompletion) => {
|
|
19193
|
+
const command = wrapCommand(fn, true);
|
|
19194
|
+
return async (uid, ...args) => {
|
|
19195
|
+
await command(uid, ...args);
|
|
19196
|
+
const editor = get$8(uid)?.newState;
|
|
19197
|
+
if (editor && (shouldOpenCompletion(...args) && shouldOpenAutomaticCompletion(editor) || editor.widgets?.some(widget => widget.id === Completion && widget.newState.automatic))) {
|
|
19198
|
+
void updateAutomaticCompletionDeferred(uid).then(() => invoke$d('Editor.renderPending', uid)).catch(error => handleError$1(error, 'Failed to open completion widget: '));
|
|
19199
|
+
}
|
|
19200
|
+
};
|
|
19201
|
+
};
|
|
19202
|
+
const deleteLeftCommand = wrapTypingCommand(deleteCharacterLeft, () => false);
|
|
19203
|
+
const typeCommand = wrapTypingCommand(type, () => true);
|
|
19204
|
+
const typeWithAutoClosingCommand = wrapTypingCommand(typeWithAutoClosing, () => true);
|
|
19205
|
+
const handleBeforeInputCommand = wrapTypingCommand(handleBeforeInput, inputType => inputType === InsertText);
|
|
18981
19206
|
const commandMap = {
|
|
18982
19207
|
'ActivateByEvent.activateByEvent': activateByEvent,
|
|
18983
19208
|
'CodeGenerator.accept': codeGeneratorAccept,
|
|
@@ -19031,10 +19256,10 @@ const commandMap = {
|
|
|
19031
19256
|
'Editor.deleteAll': wrapCommand(deleteAll),
|
|
19032
19257
|
'Editor.deleteAllLeft': wrapCommand(deleteAllLeft),
|
|
19033
19258
|
'Editor.deleteAllRight': wrapCommand(deleteAllRight),
|
|
19034
|
-
'Editor.deleteCharacterLeft':
|
|
19259
|
+
'Editor.deleteCharacterLeft': deleteLeftCommand,
|
|
19035
19260
|
'Editor.deleteCharacterRight': wrapCommand(deleteCharacterRight),
|
|
19036
19261
|
'Editor.deleteHorizontalRight': wrapCommand(editorDeleteHorizontalRight),
|
|
19037
|
-
'Editor.deleteLeft':
|
|
19262
|
+
'Editor.deleteLeft': deleteLeftCommand,
|
|
19038
19263
|
'Editor.deleteLine': wrapCommand(deleteLine$1),
|
|
19039
19264
|
'Editor.deleteRight': wrapCommand(deleteCharacterRight),
|
|
19040
19265
|
'Editor.deleteWordLeft': wrapCommand(deleteWordLeft),
|
|
@@ -19077,7 +19302,7 @@ const commandMap = {
|
|
|
19077
19302
|
'Editor.goToBracket': wrapCommand(goToBracket$1),
|
|
19078
19303
|
'Editor.goToDefinition': wrapCommand(goToDefinition),
|
|
19079
19304
|
'Editor.goToTypeDefinition': wrapCommand(goToTypeDefinition),
|
|
19080
|
-
'Editor.handleBeforeInput':
|
|
19305
|
+
'Editor.handleBeforeInput': handleBeforeInputCommand,
|
|
19081
19306
|
'Editor.handleBeforeInputFromContentEditable': wrapCommand(handleBeforeInputFromContentEditable),
|
|
19082
19307
|
'Editor.handleBlur': wrapCommand(handleBlur$1),
|
|
19083
19308
|
'Editor.handleClickAtPosition': wrapCommand(handleClickAtPosition),
|
|
@@ -19130,7 +19355,7 @@ const commandMap = {
|
|
|
19130
19355
|
'Editor.offsetAt': offsetAt,
|
|
19131
19356
|
'Editor.openCodeGenerator': wrapCommand(openCodeGenerator),
|
|
19132
19357
|
'Editor.openColorPicker': wrapCommand(openColorPicker),
|
|
19133
|
-
'Editor.openCompletion':
|
|
19358
|
+
'Editor.openCompletion': openCompletionDeferred,
|
|
19134
19359
|
'Editor.openFind': wrapCommand(openFind),
|
|
19135
19360
|
'Editor.openFind2': wrapCommand(openFind2),
|
|
19136
19361
|
'Editor.openRename': wrapCommand(openRename),
|
|
@@ -19194,11 +19419,11 @@ const commandMap = {
|
|
|
19194
19419
|
'Editor.toggleBlockComment': wrapCommand(toggleBlockComment),
|
|
19195
19420
|
'Editor.toggleBreakpoint': wrapCommand(toggleBreakpoint),
|
|
19196
19421
|
'Editor.toggleComment': wrapCommand(toggleComment),
|
|
19197
|
-
'Editor.toggleCompletion':
|
|
19422
|
+
'Editor.toggleCompletion': wrapDeferredCommand(toggleCompletion),
|
|
19198
19423
|
'Editor.toggleLineComment': wrapCommand(editorToggleLineComment),
|
|
19199
19424
|
'Editor.toggleMinimap': toggleMinimap,
|
|
19200
|
-
'Editor.type':
|
|
19201
|
-
'Editor.typeWithAutoClosing':
|
|
19425
|
+
'Editor.type': typeCommand,
|
|
19426
|
+
'Editor.typeWithAutoClosing': typeWithAutoClosingCommand,
|
|
19202
19427
|
'Editor.undo': wrapCommand(undo),
|
|
19203
19428
|
'Editor.unfold': wrapCommand(unfold),
|
|
19204
19429
|
'Editor.unIndent': wrapCommand(editorUnindent),
|