@lvce-editor/editor-worker 19.27.0 → 19.27.2
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 +447 -351
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -2040,6 +2040,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
2040
2040
|
hasListener: false,
|
|
2041
2041
|
height,
|
|
2042
2042
|
highlightedLine: -1,
|
|
2043
|
+
hoverEnabled: false,
|
|
2043
2044
|
id,
|
|
2044
2045
|
incrementalEdits: emptyIncrementalEdits,
|
|
2045
2046
|
initial: true,
|
|
@@ -5727,7 +5728,7 @@ const hasWidget = (widgets, id) => {
|
|
|
5727
5728
|
|
|
5728
5729
|
const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGenerator, fullFocus) => {
|
|
5729
5730
|
const {
|
|
5730
|
-
widgets
|
|
5731
|
+
widgets = []
|
|
5731
5732
|
} = editor;
|
|
5732
5733
|
if (hasWidget(widgets, widgetId)) {
|
|
5733
5734
|
return editor;
|
|
@@ -5736,6 +5737,9 @@ const addWidgetToEditor = async (widgetId, focusKey, editor, factory, newStateGe
|
|
|
5736
5737
|
// @ts-ignore
|
|
5737
5738
|
widget.newState.editorUid = editor.uid;
|
|
5738
5739
|
const newState = await newStateGenerator(widget.newState, editor.uid);
|
|
5740
|
+
if (!newState) {
|
|
5741
|
+
return editor;
|
|
5742
|
+
}
|
|
5739
5743
|
// @ts-ignore
|
|
5740
5744
|
newState.editorUid = editor.uid;
|
|
5741
5745
|
const latestWidget = {
|
|
@@ -5778,12 +5782,12 @@ const create$6 = () => {
|
|
|
5778
5782
|
return widget;
|
|
5779
5783
|
};
|
|
5780
5784
|
|
|
5781
|
-
const newStateGenerator$
|
|
5785
|
+
const newStateGenerator$5 = (state, parentUid) => {
|
|
5782
5786
|
return loadContent$3(state, parentUid);
|
|
5783
5787
|
};
|
|
5784
5788
|
const openColorPicker = async editor => {
|
|
5785
5789
|
const fullFocus = true;
|
|
5786
|
-
return addWidgetToEditor(ColorPicker$1, ColorPicker, editor, create$6, newStateGenerator$
|
|
5790
|
+
return addWidgetToEditor(ColorPicker$1, ColorPicker, editor, create$6, newStateGenerator$5, fullFocus);
|
|
5787
5791
|
};
|
|
5788
5792
|
const closeColorPicker = editor => {
|
|
5789
5793
|
const {
|
|
@@ -7388,15 +7392,17 @@ const handleMouseDown = async (state, button, altKey, ctrlKey, x, y, detail) =>
|
|
|
7388
7392
|
const state$4 = {
|
|
7389
7393
|
editor: undefined,
|
|
7390
7394
|
timeout: -1,
|
|
7395
|
+
token: 0,
|
|
7391
7396
|
x: 0,
|
|
7392
7397
|
y: 0
|
|
7393
7398
|
};
|
|
7394
7399
|
const get$1 = () => {
|
|
7395
7400
|
return state$4;
|
|
7396
7401
|
};
|
|
7397
|
-
const set$1 = (editor, timeout, x, y) => {
|
|
7402
|
+
const set$1 = (editor, timeout, x, y, token) => {
|
|
7398
7403
|
state$4.editor = editor;
|
|
7399
7404
|
state$4.timeout = timeout;
|
|
7405
|
+
state$4.token = token;
|
|
7400
7406
|
state$4.x = x;
|
|
7401
7407
|
state$4.y = y;
|
|
7402
7408
|
};
|
|
@@ -7471,10 +7477,265 @@ const handleMouseMoveWithAltKey = async (editor, x, y) => {
|
|
|
7471
7477
|
}
|
|
7472
7478
|
};
|
|
7473
7479
|
|
|
7474
|
-
const
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7480
|
+
const create$5 = () => {
|
|
7481
|
+
const uid = create$8();
|
|
7482
|
+
const widget = {
|
|
7483
|
+
id: Hover,
|
|
7484
|
+
newState: {
|
|
7485
|
+
commands: [],
|
|
7486
|
+
content: '',
|
|
7487
|
+
diagnostics: [],
|
|
7488
|
+
documentation: '',
|
|
7489
|
+
editorUid: 0,
|
|
7490
|
+
height: 0,
|
|
7491
|
+
lineInfos: [],
|
|
7492
|
+
uid: uid,
|
|
7493
|
+
width: 0,
|
|
7494
|
+
x: 0,
|
|
7495
|
+
y: 0
|
|
7496
|
+
},
|
|
7497
|
+
oldState: {
|
|
7498
|
+
commands: [],
|
|
7499
|
+
content: '',
|
|
7500
|
+
diagnostics: [],
|
|
7501
|
+
documentation: '',
|
|
7502
|
+
editorUid: 0,
|
|
7503
|
+
height: 0,
|
|
7504
|
+
lineInfos: [],
|
|
7505
|
+
uid: uid,
|
|
7506
|
+
width: 0,
|
|
7507
|
+
x: 0,
|
|
7508
|
+
y: 0
|
|
7509
|
+
}
|
|
7510
|
+
};
|
|
7511
|
+
return widget;
|
|
7512
|
+
};
|
|
7513
|
+
|
|
7514
|
+
const OnDiagnostic = 'onDiagnostic';
|
|
7515
|
+
const OnHover = 'onHover';
|
|
7516
|
+
const OnTabCompletion = 'onTabCompletion';
|
|
7517
|
+
|
|
7518
|
+
const execute = async ({
|
|
7519
|
+
args,
|
|
7520
|
+
assetDir,
|
|
7521
|
+
editor,
|
|
7522
|
+
event,
|
|
7523
|
+
method,
|
|
7524
|
+
noProviderFoundMessage,
|
|
7525
|
+
noProviderFoundResult = undefined,
|
|
7526
|
+
platform
|
|
7527
|
+
}) => {
|
|
7528
|
+
const fullEvent = `${event}:${editor.languageId}`;
|
|
7529
|
+
await activateByEvent(fullEvent, assetDir, platform);
|
|
7530
|
+
const result = await invoke$6(method, editor.uid, ...args);
|
|
7531
|
+
return result;
|
|
7532
|
+
};
|
|
7533
|
+
|
|
7534
|
+
const getTextDocument$1 = editor => {
|
|
7535
|
+
return {
|
|
7536
|
+
documentId: editor.id || editor.uid,
|
|
7537
|
+
languageId: editor.languageId,
|
|
7538
|
+
text: getText$1(editor),
|
|
7539
|
+
uri: editor.uri
|
|
7540
|
+
};
|
|
7541
|
+
};
|
|
7542
|
+
const executeIsolatedHoverProvider = async (editor, offset) => {
|
|
7543
|
+
const textDocument = getTextDocument$1(editor);
|
|
7544
|
+
return invoke$e('Extensions.executeHoverProvider', textDocument, offset);
|
|
7545
|
+
};
|
|
7546
|
+
const executeHoverProvider = async (editor, offset) => {
|
|
7547
|
+
object(editor);
|
|
7548
|
+
number(offset);
|
|
7549
|
+
const isolatedHover = await executeIsolatedHoverProvider(editor, offset);
|
|
7550
|
+
if (isolatedHover) {
|
|
7551
|
+
return isolatedHover;
|
|
7552
|
+
}
|
|
7553
|
+
return execute({
|
|
7554
|
+
args: [offset],
|
|
7555
|
+
editor,
|
|
7556
|
+
event: OnHover,
|
|
7557
|
+
method: HoverExecute,
|
|
7558
|
+
noProviderFoundMessage: 'No hover provider found'
|
|
7559
|
+
});
|
|
7560
|
+
};
|
|
7561
|
+
|
|
7562
|
+
const getHover = async (editor, offset) => {
|
|
7563
|
+
object(editor);
|
|
7564
|
+
number(offset);
|
|
7565
|
+
// TODO invoke extension host worker directly
|
|
7566
|
+
const hover = await executeHoverProvider(editor, offset);
|
|
7567
|
+
return hover;
|
|
7568
|
+
};
|
|
7569
|
+
|
|
7570
|
+
const measureTextBlockHeight = async (text, fontFamily, fontSize, lineHeight, width) => {
|
|
7571
|
+
// @ts-ignore
|
|
7572
|
+
// return RendererProcess.invoke('MeasureTextBlockHeight.measureTextBlockHeight', text, fontSize, fontFamily, lineHeight, width)
|
|
7573
|
+
return 100;
|
|
7574
|
+
};
|
|
7575
|
+
|
|
7576
|
+
const getLineInfo = (line, tokens, TokenMap) => {
|
|
7577
|
+
const tokensLength = tokens.length;
|
|
7578
|
+
let end = 0;
|
|
7579
|
+
let start = 0;
|
|
7580
|
+
const lineInfo = [];
|
|
7581
|
+
for (let i = 0; i < tokensLength; i += 2) {
|
|
7582
|
+
const tokenType = tokens[i];
|
|
7583
|
+
const tokenLength = tokens[i + 1];
|
|
7584
|
+
end += tokenLength;
|
|
7585
|
+
const text = line.slice(start, end);
|
|
7586
|
+
const className = `Token ${TokenMap[tokenType] || 'Unknown'}`;
|
|
7587
|
+
const normalizedText = text;
|
|
7588
|
+
lineInfo.push(normalizedText, className);
|
|
7589
|
+
start = end;
|
|
7590
|
+
}
|
|
7591
|
+
return lineInfo;
|
|
7592
|
+
};
|
|
7593
|
+
|
|
7594
|
+
const getLineInfos = (lines, tokenizer, languageId) => {
|
|
7595
|
+
const lineInfos = [];
|
|
7596
|
+
const {
|
|
7597
|
+
hasArrayReturn,
|
|
7598
|
+
initialLineState,
|
|
7599
|
+
tokenizeLine,
|
|
7600
|
+
TokenMap
|
|
7601
|
+
} = tokenizer;
|
|
7602
|
+
let currentLineState = getInitialLineState(initialLineState);
|
|
7603
|
+
for (const line of lines) {
|
|
7604
|
+
const result = safeTokenizeLine(languageId, tokenizeLine, line, currentLineState, hasArrayReturn);
|
|
7605
|
+
const {
|
|
7606
|
+
tokens
|
|
7607
|
+
} = result;
|
|
7608
|
+
const lineInfo = getLineInfo(line, tokens, TokenMap);
|
|
7609
|
+
lineInfos.push(lineInfo);
|
|
7610
|
+
currentLineState = result;
|
|
7611
|
+
}
|
|
7612
|
+
console.error({
|
|
7613
|
+
lineInfos
|
|
7614
|
+
});
|
|
7615
|
+
return lineInfos;
|
|
7616
|
+
};
|
|
7617
|
+
|
|
7618
|
+
const tokenizeCodeBlock = async (codeBlock, languageId, tokenizerPath) => {
|
|
7619
|
+
await loadTokenizer(languageId, tokenizerPath);
|
|
7620
|
+
const tokenizer = getTokenizer(languageId);
|
|
7621
|
+
const lines = splitLines(codeBlock);
|
|
7622
|
+
const lineInfos = getLineInfos(lines, tokenizer, languageId);
|
|
7623
|
+
return lineInfos;
|
|
7624
|
+
};
|
|
7625
|
+
|
|
7626
|
+
const getHoverPosition = (position, selections) => {
|
|
7627
|
+
if (position) {
|
|
7628
|
+
return position;
|
|
7629
|
+
}
|
|
7630
|
+
const rowIndex = selections[0];
|
|
7631
|
+
const columnIndex = selections[1];
|
|
7632
|
+
return {
|
|
7633
|
+
columnIndex,
|
|
7634
|
+
rowIndex
|
|
7635
|
+
};
|
|
7636
|
+
};
|
|
7637
|
+
const getMatchingDiagnostics = (diagnostics, rowIndex, columnIndex) => {
|
|
7638
|
+
const matching = [];
|
|
7639
|
+
for (const diagnostic of diagnostics) {
|
|
7640
|
+
if (diagnostic.rowIndex === rowIndex) {
|
|
7641
|
+
matching.push(diagnostic);
|
|
7642
|
+
}
|
|
7643
|
+
}
|
|
7644
|
+
return matching;
|
|
7645
|
+
};
|
|
7646
|
+
const fallbackDisplayStringLanguageId = 'typescript'; // TODO remove this
|
|
7647
|
+
const getHoverPositionXy = (editor, rowIndex, wordStart, documentationHeight) => {
|
|
7648
|
+
const x$1 = x(editor, rowIndex, wordStart);
|
|
7649
|
+
const y$1 = editor.height - y(editor, rowIndex) + editor.y + 40;
|
|
7650
|
+
return {
|
|
7651
|
+
x: x$1,
|
|
7652
|
+
y: y$1
|
|
7653
|
+
};
|
|
7654
|
+
};
|
|
7655
|
+
const getEditorHoverInfo = async (editorUid, position) => {
|
|
7656
|
+
number(editorUid);
|
|
7657
|
+
const instance = get$7(editorUid);
|
|
7658
|
+
const editor = instance.newState;
|
|
7659
|
+
const {
|
|
7660
|
+
selections
|
|
7661
|
+
} = editor;
|
|
7662
|
+
const {
|
|
7663
|
+
columnIndex,
|
|
7664
|
+
rowIndex
|
|
7665
|
+
} = getHoverPosition(position, selections);
|
|
7666
|
+
const offset = offsetAt(editor, rowIndex, columnIndex);
|
|
7667
|
+
const hover = await getHover(editor, offset);
|
|
7668
|
+
if (!hover) {
|
|
7669
|
+
return undefined;
|
|
7670
|
+
}
|
|
7671
|
+
const {
|
|
7672
|
+
displayString,
|
|
7673
|
+
displayStringLanguageId,
|
|
7674
|
+
documentation
|
|
7675
|
+
} = hover;
|
|
7676
|
+
const tokenizerPath = '';
|
|
7677
|
+
const lineInfos = await tokenizeCodeBlock(displayString, displayStringLanguageId || fallbackDisplayStringLanguageId, tokenizerPath);
|
|
7678
|
+
const wordPart = getWordBefore(editor, rowIndex, columnIndex);
|
|
7679
|
+
const wordStart = columnIndex - wordPart.length;
|
|
7680
|
+
await measureTextBlockHeight();
|
|
7681
|
+
const {
|
|
7682
|
+
x,
|
|
7683
|
+
y
|
|
7684
|
+
} = getHoverPositionXy(editor, rowIndex, wordStart);
|
|
7685
|
+
const diagnostics = editor.diagnostics || [];
|
|
7686
|
+
const matchingDiagnostics = getMatchingDiagnostics(diagnostics, rowIndex);
|
|
7687
|
+
return {
|
|
7688
|
+
documentation,
|
|
7689
|
+
lineInfos,
|
|
7690
|
+
matchingDiagnostics,
|
|
7691
|
+
x,
|
|
7692
|
+
y
|
|
7693
|
+
};
|
|
7694
|
+
};
|
|
7695
|
+
|
|
7696
|
+
const loadHoverContent = async (state, position) => {
|
|
7697
|
+
const hoverInfo = await getEditorHoverInfo(state.editorUid, position);
|
|
7698
|
+
if (!hoverInfo) {
|
|
7699
|
+
return undefined;
|
|
7700
|
+
}
|
|
7701
|
+
const {
|
|
7702
|
+
documentation,
|
|
7703
|
+
lineInfos,
|
|
7704
|
+
matchingDiagnostics,
|
|
7705
|
+
x,
|
|
7706
|
+
y
|
|
7707
|
+
} = hoverInfo;
|
|
7708
|
+
return {
|
|
7709
|
+
...state,
|
|
7710
|
+
diagnostics: matchingDiagnostics,
|
|
7711
|
+
documentation,
|
|
7712
|
+
lineInfos,
|
|
7713
|
+
width: 600,
|
|
7714
|
+
x,
|
|
7715
|
+
y
|
|
7716
|
+
};
|
|
7717
|
+
};
|
|
7718
|
+
|
|
7719
|
+
const showHover2 = async (editor, position) => {
|
|
7720
|
+
const newStateGenerator = async state => {
|
|
7721
|
+
return loadHoverContent(state, position);
|
|
7722
|
+
};
|
|
7723
|
+
return addWidgetToEditor(Hover, FocusEditorHover, editor, create$5, newStateGenerator);
|
|
7724
|
+
};
|
|
7725
|
+
|
|
7726
|
+
const showHover$1 = async (editor, position, token) => {
|
|
7727
|
+
const instance = get$7(editor.uid);
|
|
7728
|
+
if (!instance) {
|
|
7729
|
+
return;
|
|
7730
|
+
}
|
|
7731
|
+
const latestEditor = instance.newState;
|
|
7732
|
+
const newEditor = await showHover2(latestEditor, position);
|
|
7733
|
+
const latestInstance = get$7(editor.uid);
|
|
7734
|
+
if (latestEditor === newEditor || !latestInstance || latestInstance.newState !== latestEditor || get$1().token !== token) {
|
|
7735
|
+
return;
|
|
7736
|
+
}
|
|
7737
|
+
set$9(editor.uid, latestInstance.oldState, newEditor);
|
|
7738
|
+
await invoke$b('Editor.renderPending', editor.uid);
|
|
7478
7739
|
};
|
|
7479
7740
|
|
|
7480
7741
|
// TODO several things can happen:
|
|
@@ -7485,14 +7746,22 @@ const showHover$1 = async (editor, position) => {
|
|
|
7485
7746
|
// 5. show color picker
|
|
7486
7747
|
// 6. show error info
|
|
7487
7748
|
|
|
7488
|
-
const onHoverIdle = async
|
|
7489
|
-
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
|
|
7749
|
+
const onHoverIdle = async token => {
|
|
7750
|
+
try {
|
|
7751
|
+
const {
|
|
7752
|
+
editor,
|
|
7753
|
+
token: latestToken,
|
|
7754
|
+
x,
|
|
7755
|
+
y
|
|
7756
|
+
} = get$1();
|
|
7757
|
+
if (latestToken !== token) {
|
|
7758
|
+
return;
|
|
7759
|
+
}
|
|
7760
|
+
const position = await at(editor, x, y);
|
|
7761
|
+
await showHover$1(editor, position, token);
|
|
7762
|
+
} catch {
|
|
7763
|
+
// Hover providers are optional and should not surface errors from an idle mouse event.
|
|
7764
|
+
}
|
|
7496
7765
|
};
|
|
7497
7766
|
const hoverDelay = 300;
|
|
7498
7767
|
const handleMouseMove = async (editor, x, y, altKey) => {
|
|
@@ -7507,8 +7776,9 @@ const handleMouseMove = async (editor, x, y, altKey) => {
|
|
|
7507
7776
|
if (oldState.timeout !== -1) {
|
|
7508
7777
|
clearTimeout(oldState.timeout);
|
|
7509
7778
|
}
|
|
7510
|
-
const
|
|
7511
|
-
|
|
7779
|
+
const token = create$8();
|
|
7780
|
+
const timeout = setTimeout(onHoverIdle, hoverDelay, token);
|
|
7781
|
+
set$1(editorWithoutDefinitionLink, timeout, x, y, token);
|
|
7512
7782
|
return editorWithoutDefinitionLink;
|
|
7513
7783
|
};
|
|
7514
7784
|
|
|
@@ -8225,7 +8495,7 @@ const insertLineBreak = async editor => {
|
|
|
8225
8495
|
const Script = 2;
|
|
8226
8496
|
const Unknown$1 = 0;
|
|
8227
8497
|
|
|
8228
|
-
const create$
|
|
8498
|
+
const create$4 = () => {
|
|
8229
8499
|
const completionUid = create$8();
|
|
8230
8500
|
const widget = {
|
|
8231
8501
|
id: CodeGenerator,
|
|
@@ -8253,7 +8523,7 @@ const create$5 = () => {
|
|
|
8253
8523
|
return widget;
|
|
8254
8524
|
};
|
|
8255
8525
|
|
|
8256
|
-
const newStateGenerator$
|
|
8526
|
+
const newStateGenerator$4 = async state => {
|
|
8257
8527
|
const latestState = {
|
|
8258
8528
|
...state,
|
|
8259
8529
|
height: 45,
|
|
@@ -8265,10 +8535,10 @@ const newStateGenerator$5 = async state => {
|
|
|
8265
8535
|
};
|
|
8266
8536
|
const openCodeGenerator = async editor => {
|
|
8267
8537
|
const fullFocus = true;
|
|
8268
|
-
return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create$
|
|
8538
|
+
return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create$4, newStateGenerator$4, fullFocus);
|
|
8269
8539
|
};
|
|
8270
8540
|
|
|
8271
|
-
const create$
|
|
8541
|
+
const create$3 = () => {
|
|
8272
8542
|
const completionUid = create$8();
|
|
8273
8543
|
const completionWidget = {
|
|
8274
8544
|
id: Completion,
|
|
@@ -8297,7 +8567,7 @@ const {
|
|
|
8297
8567
|
setFactory
|
|
8298
8568
|
} = createLazyRpc(CompletionWorker);
|
|
8299
8569
|
|
|
8300
|
-
const newStateGenerator$
|
|
8570
|
+
const newStateGenerator$3 = async (state, parentUid) => {
|
|
8301
8571
|
const {
|
|
8302
8572
|
height,
|
|
8303
8573
|
uid,
|
|
@@ -8322,7 +8592,7 @@ const newStateGenerator$4 = async (state, parentUid) => {
|
|
|
8322
8592
|
};
|
|
8323
8593
|
const openCompletion = async editor => {
|
|
8324
8594
|
const fullFocus = false;
|
|
8325
|
-
return addWidgetToEditor(Completion, EditorCompletion, editor, create$
|
|
8595
|
+
return addWidgetToEditor(Completion, EditorCompletion, editor, create$3, newStateGenerator$3, fullFocus);
|
|
8326
8596
|
};
|
|
8327
8597
|
|
|
8328
8598
|
const isFunctional = widgetId => {
|
|
@@ -8684,7 +8954,7 @@ const EditorFindWidget = {
|
|
|
8684
8954
|
toggleUseRegularExpression
|
|
8685
8955
|
};
|
|
8686
8956
|
|
|
8687
|
-
const create$
|
|
8957
|
+
const create$2 = () => {
|
|
8688
8958
|
const uid = create$8();
|
|
8689
8959
|
const widget = {
|
|
8690
8960
|
id: Find,
|
|
@@ -8743,7 +9013,7 @@ const loadContent$2 = async (state, parentUid) => {
|
|
|
8743
9013
|
};
|
|
8744
9014
|
};
|
|
8745
9015
|
|
|
8746
|
-
const newStateGenerator$
|
|
9016
|
+
const newStateGenerator$2 = (state, parentUid) => {
|
|
8747
9017
|
return loadContent$2(state, parentUid);
|
|
8748
9018
|
};
|
|
8749
9019
|
const openFind2 = async editor => {
|
|
@@ -8752,7 +9022,7 @@ const openFind2 = async editor => {
|
|
|
8752
9022
|
return editorWithFocusedFind;
|
|
8753
9023
|
}
|
|
8754
9024
|
const fullFocus = true;
|
|
8755
|
-
return addWidgetToEditor(Find, FindWidget, editor, create$
|
|
9025
|
+
return addWidgetToEditor(Find, FindWidget, editor, create$2, newStateGenerator$2, fullFocus);
|
|
8756
9026
|
};
|
|
8757
9027
|
|
|
8758
9028
|
const openFind = async state => {
|
|
@@ -8785,7 +9055,7 @@ const getPositionAtCursor$1 = editor => {
|
|
|
8785
9055
|
};
|
|
8786
9056
|
};
|
|
8787
9057
|
|
|
8788
|
-
const create$
|
|
9058
|
+
const create$1 = () => {
|
|
8789
9059
|
const completionUid = create$8();
|
|
8790
9060
|
const renameWidget = {
|
|
8791
9061
|
id: Rename$1,
|
|
@@ -8809,7 +9079,7 @@ const create$2 = () => {
|
|
|
8809
9079
|
return renameWidget;
|
|
8810
9080
|
};
|
|
8811
9081
|
|
|
8812
|
-
const newStateGenerator$
|
|
9082
|
+
const newStateGenerator$1 = async (state, parentUid) => {
|
|
8813
9083
|
const {
|
|
8814
9084
|
height,
|
|
8815
9085
|
uid,
|
|
@@ -8844,7 +9114,7 @@ const openRename = async editor => {
|
|
|
8844
9114
|
return editor;
|
|
8845
9115
|
}
|
|
8846
9116
|
const fullFocus = true;
|
|
8847
|
-
const editorWithRenameWidget = await addWidgetToEditor(Rename$1, FocusEditorRename$1, editor, create$
|
|
9117
|
+
const editorWithRenameWidget = await addWidgetToEditor(Rename$1, FocusEditorRename$1, editor, create$1, newStateGenerator$1, fullFocus);
|
|
8848
9118
|
if (editorWithRenameWidget === editor) {
|
|
8849
9119
|
return editor;
|
|
8850
9120
|
}
|
|
@@ -8856,22 +9126,6 @@ const openRename = async editor => {
|
|
|
8856
9126
|
};
|
|
8857
9127
|
};
|
|
8858
9128
|
|
|
8859
|
-
const execute = async ({
|
|
8860
|
-
args,
|
|
8861
|
-
assetDir,
|
|
8862
|
-
editor,
|
|
8863
|
-
event,
|
|
8864
|
-
method,
|
|
8865
|
-
noProviderFoundMessage,
|
|
8866
|
-
noProviderFoundResult = undefined,
|
|
8867
|
-
platform
|
|
8868
|
-
}) => {
|
|
8869
|
-
const fullEvent = `${event}:${editor.languageId}`;
|
|
8870
|
-
await activateByEvent(fullEvent, assetDir, platform);
|
|
8871
|
-
const result = await invoke$6(method, editor.uid, ...args);
|
|
8872
|
-
return result;
|
|
8873
|
-
};
|
|
8874
|
-
|
|
8875
9129
|
const getOrganizeImportEdits = async editor => {
|
|
8876
9130
|
const edits = await execute({
|
|
8877
9131
|
args: [],
|
|
@@ -9450,82 +9704,20 @@ const setText = (editor, text) => {
|
|
|
9450
9704
|
rowIndex: 0
|
|
9451
9705
|
};
|
|
9452
9706
|
const end = {
|
|
9453
|
-
columnIndex: endColumnIndex,
|
|
9454
|
-
rowIndex: endRowIndex
|
|
9455
|
-
};
|
|
9456
|
-
const changes = [{
|
|
9457
|
-
deleted: getSelectionText(editor, {
|
|
9458
|
-
end,
|
|
9459
|
-
start
|
|
9460
|
-
}),
|
|
9461
|
-
end,
|
|
9462
|
-
inserted: splitLines(text),
|
|
9463
|
-
origin: EditorType,
|
|
9464
|
-
start
|
|
9465
|
-
}];
|
|
9466
|
-
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
9467
|
-
};
|
|
9468
|
-
|
|
9469
|
-
const create$1 = () => {
|
|
9470
|
-
const uid = create$8();
|
|
9471
|
-
const widget = {
|
|
9472
|
-
id: Hover,
|
|
9473
|
-
newState: {
|
|
9474
|
-
commands: [],
|
|
9475
|
-
content: '',
|
|
9476
|
-
diagnostics: [],
|
|
9477
|
-
documentation: '',
|
|
9478
|
-
editorUid: 0,
|
|
9479
|
-
height: 0,
|
|
9480
|
-
lineInfos: [],
|
|
9481
|
-
uid: uid,
|
|
9482
|
-
width: 0,
|
|
9483
|
-
x: 0,
|
|
9484
|
-
y: 0
|
|
9485
|
-
},
|
|
9486
|
-
oldState: {
|
|
9487
|
-
commands: [],
|
|
9488
|
-
content: '',
|
|
9489
|
-
diagnostics: [],
|
|
9490
|
-
documentation: '',
|
|
9491
|
-
editorUid: 0,
|
|
9492
|
-
height: 0,
|
|
9493
|
-
lineInfos: [],
|
|
9494
|
-
uid: uid,
|
|
9495
|
-
width: 0,
|
|
9496
|
-
x: 0,
|
|
9497
|
-
y: 0
|
|
9498
|
-
}
|
|
9499
|
-
};
|
|
9500
|
-
return widget;
|
|
9501
|
-
};
|
|
9502
|
-
|
|
9503
|
-
const newStateGenerator$1 = async (state, parentUid) => {
|
|
9504
|
-
const {
|
|
9505
|
-
height,
|
|
9506
|
-
uid,
|
|
9507
|
-
width,
|
|
9508
|
-
x,
|
|
9509
|
-
y
|
|
9510
|
-
} = state;
|
|
9511
|
-
const {
|
|
9512
|
-
newState
|
|
9513
|
-
} = get$7(parentUid);
|
|
9514
|
-
const {
|
|
9515
|
-
languageId
|
|
9516
|
-
} = newState;
|
|
9517
|
-
await invoke$2('Hover.create', uid, x, y, width, height, parentUid, languageId);
|
|
9518
|
-
await invoke$2('Hover.loadContent', uid);
|
|
9519
|
-
const diff = await invoke$2('Hover.diff2', uid);
|
|
9520
|
-
const commands = await invoke$2('Hover.render2', uid, diff);
|
|
9521
|
-
return {
|
|
9522
|
-
...state,
|
|
9523
|
-
commands
|
|
9707
|
+
columnIndex: endColumnIndex,
|
|
9708
|
+
rowIndex: endRowIndex
|
|
9524
9709
|
};
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
|
|
9710
|
+
const changes = [{
|
|
9711
|
+
deleted: getSelectionText(editor, {
|
|
9712
|
+
end,
|
|
9713
|
+
start
|
|
9714
|
+
}),
|
|
9715
|
+
end,
|
|
9716
|
+
inserted: splitLines(text),
|
|
9717
|
+
origin: EditorType,
|
|
9718
|
+
start
|
|
9719
|
+
}];
|
|
9720
|
+
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
9529
9721
|
};
|
|
9530
9722
|
|
|
9531
9723
|
const EditorHover = 'EditorHover';
|
|
@@ -9650,10 +9842,6 @@ const sortLinesAscending = editor => {
|
|
|
9650
9842
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
9651
9843
|
};
|
|
9652
9844
|
|
|
9653
|
-
const OnDiagnostic = 'onDiagnostic';
|
|
9654
|
-
const OnHover = 'onHover';
|
|
9655
|
-
const OnTabCompletion = 'onTabCompletion';
|
|
9656
|
-
|
|
9657
9845
|
const executeTabCompletionProvider = async (editor, offset) => {
|
|
9658
9846
|
return execute({
|
|
9659
9847
|
args: [offset],
|
|
@@ -10466,168 +10654,6 @@ const EditorCompletionWidget = {
|
|
|
10466
10654
|
toggleDetails: toggleDetails$1
|
|
10467
10655
|
};
|
|
10468
10656
|
|
|
10469
|
-
const getTextDocument$1 = editor => {
|
|
10470
|
-
return {
|
|
10471
|
-
documentId: editor.id || editor.uid,
|
|
10472
|
-
languageId: editor.languageId,
|
|
10473
|
-
text: getText$1(editor),
|
|
10474
|
-
uri: editor.uri
|
|
10475
|
-
};
|
|
10476
|
-
};
|
|
10477
|
-
const executeIsolatedHoverProvider = async (editor, offset) => {
|
|
10478
|
-
const textDocument = getTextDocument$1(editor);
|
|
10479
|
-
return invoke$e('Extensions.executeHoverProvider', textDocument, offset);
|
|
10480
|
-
};
|
|
10481
|
-
const executeHoverProvider = async (editor, offset) => {
|
|
10482
|
-
object(editor);
|
|
10483
|
-
number(offset);
|
|
10484
|
-
const isolatedHover = await executeIsolatedHoverProvider(editor, offset);
|
|
10485
|
-
if (isolatedHover) {
|
|
10486
|
-
return isolatedHover;
|
|
10487
|
-
}
|
|
10488
|
-
return execute({
|
|
10489
|
-
args: [offset],
|
|
10490
|
-
editor,
|
|
10491
|
-
event: OnHover,
|
|
10492
|
-
method: HoverExecute,
|
|
10493
|
-
noProviderFoundMessage: 'No hover provider found'
|
|
10494
|
-
});
|
|
10495
|
-
};
|
|
10496
|
-
|
|
10497
|
-
const getHover = async (editor, offset) => {
|
|
10498
|
-
object(editor);
|
|
10499
|
-
number(offset);
|
|
10500
|
-
// TODO invoke extension host worker directly
|
|
10501
|
-
const hover = await executeHoverProvider(editor, offset);
|
|
10502
|
-
return hover;
|
|
10503
|
-
};
|
|
10504
|
-
|
|
10505
|
-
const measureTextBlockHeight = async (text, fontFamily, fontSize, lineHeight, width) => {
|
|
10506
|
-
// @ts-ignore
|
|
10507
|
-
// return RendererProcess.invoke('MeasureTextBlockHeight.measureTextBlockHeight', text, fontSize, fontFamily, lineHeight, width)
|
|
10508
|
-
return 100;
|
|
10509
|
-
};
|
|
10510
|
-
|
|
10511
|
-
const getLineInfo = (line, tokens, TokenMap) => {
|
|
10512
|
-
const tokensLength = tokens.length;
|
|
10513
|
-
let end = 0;
|
|
10514
|
-
let start = 0;
|
|
10515
|
-
const lineInfo = [];
|
|
10516
|
-
for (let i = 0; i < tokensLength; i += 2) {
|
|
10517
|
-
const tokenType = tokens[i];
|
|
10518
|
-
const tokenLength = tokens[i + 1];
|
|
10519
|
-
end += tokenLength;
|
|
10520
|
-
const text = line.slice(start, end);
|
|
10521
|
-
const className = `Token ${TokenMap[tokenType] || 'Unknown'}`;
|
|
10522
|
-
const normalizedText = text;
|
|
10523
|
-
lineInfo.push(normalizedText, className);
|
|
10524
|
-
start = end;
|
|
10525
|
-
}
|
|
10526
|
-
return lineInfo;
|
|
10527
|
-
};
|
|
10528
|
-
|
|
10529
|
-
const getLineInfos = (lines, tokenizer, languageId) => {
|
|
10530
|
-
const lineInfos = [];
|
|
10531
|
-
const {
|
|
10532
|
-
hasArrayReturn,
|
|
10533
|
-
initialLineState,
|
|
10534
|
-
tokenizeLine,
|
|
10535
|
-
TokenMap
|
|
10536
|
-
} = tokenizer;
|
|
10537
|
-
let currentLineState = getInitialLineState(initialLineState);
|
|
10538
|
-
for (const line of lines) {
|
|
10539
|
-
const result = safeTokenizeLine(languageId, tokenizeLine, line, currentLineState, hasArrayReturn);
|
|
10540
|
-
const {
|
|
10541
|
-
tokens
|
|
10542
|
-
} = result;
|
|
10543
|
-
const lineInfo = getLineInfo(line, tokens, TokenMap);
|
|
10544
|
-
lineInfos.push(lineInfo);
|
|
10545
|
-
currentLineState = result;
|
|
10546
|
-
}
|
|
10547
|
-
console.error({
|
|
10548
|
-
lineInfos
|
|
10549
|
-
});
|
|
10550
|
-
return lineInfos;
|
|
10551
|
-
};
|
|
10552
|
-
|
|
10553
|
-
const tokenizeCodeBlock = async (codeBlock, languageId, tokenizerPath) => {
|
|
10554
|
-
await loadTokenizer(languageId, tokenizerPath);
|
|
10555
|
-
const tokenizer = getTokenizer(languageId);
|
|
10556
|
-
const lines = splitLines(codeBlock);
|
|
10557
|
-
const lineInfos = getLineInfos(lines, tokenizer, languageId);
|
|
10558
|
-
return lineInfos;
|
|
10559
|
-
};
|
|
10560
|
-
|
|
10561
|
-
const getHoverPosition = (position, selections) => {
|
|
10562
|
-
if (position) {
|
|
10563
|
-
return position;
|
|
10564
|
-
}
|
|
10565
|
-
const rowIndex = selections[0];
|
|
10566
|
-
const columnIndex = selections[1];
|
|
10567
|
-
return {
|
|
10568
|
-
columnIndex,
|
|
10569
|
-
rowIndex
|
|
10570
|
-
};
|
|
10571
|
-
};
|
|
10572
|
-
const getMatchingDiagnostics = (diagnostics, rowIndex, columnIndex) => {
|
|
10573
|
-
const matching = [];
|
|
10574
|
-
for (const diagnostic of diagnostics) {
|
|
10575
|
-
if (diagnostic.rowIndex === rowIndex) {
|
|
10576
|
-
matching.push(diagnostic);
|
|
10577
|
-
}
|
|
10578
|
-
}
|
|
10579
|
-
return matching;
|
|
10580
|
-
};
|
|
10581
|
-
const fallbackDisplayStringLanguageId = 'typescript'; // TODO remove this
|
|
10582
|
-
const getHoverPositionXy = (editor, rowIndex, wordStart, documentationHeight) => {
|
|
10583
|
-
const x$1 = x(editor, rowIndex, wordStart);
|
|
10584
|
-
const y$1 = editor.height - y(editor, rowIndex) + editor.y + 40;
|
|
10585
|
-
return {
|
|
10586
|
-
x: x$1,
|
|
10587
|
-
y: y$1
|
|
10588
|
-
};
|
|
10589
|
-
};
|
|
10590
|
-
const getEditorHoverInfo = async (editorUid, position) => {
|
|
10591
|
-
number(editorUid);
|
|
10592
|
-
const instance = get$7(editorUid);
|
|
10593
|
-
const editor = instance.newState;
|
|
10594
|
-
const {
|
|
10595
|
-
selections
|
|
10596
|
-
} = editor;
|
|
10597
|
-
const {
|
|
10598
|
-
columnIndex,
|
|
10599
|
-
rowIndex
|
|
10600
|
-
} = getHoverPosition(position, selections);
|
|
10601
|
-
const offset = offsetAt(editor, rowIndex, columnIndex);
|
|
10602
|
-
const hover = await getHover(editor, offset);
|
|
10603
|
-
if (!hover) {
|
|
10604
|
-
return undefined;
|
|
10605
|
-
}
|
|
10606
|
-
const {
|
|
10607
|
-
displayString,
|
|
10608
|
-
displayStringLanguageId,
|
|
10609
|
-
documentation
|
|
10610
|
-
} = hover;
|
|
10611
|
-
const tokenizerPath = '';
|
|
10612
|
-
const lineInfos = await tokenizeCodeBlock(displayString, displayStringLanguageId || fallbackDisplayStringLanguageId, tokenizerPath);
|
|
10613
|
-
const wordPart = getWordBefore(editor, rowIndex, columnIndex);
|
|
10614
|
-
const wordStart = columnIndex - wordPart.length;
|
|
10615
|
-
await measureTextBlockHeight();
|
|
10616
|
-
const {
|
|
10617
|
-
x,
|
|
10618
|
-
y
|
|
10619
|
-
} = getHoverPositionXy(editor, rowIndex, wordStart);
|
|
10620
|
-
const diagnostics = editor.diagnostics || [];
|
|
10621
|
-
const matchingDiagnostics = getMatchingDiagnostics(diagnostics, rowIndex);
|
|
10622
|
-
return {
|
|
10623
|
-
documentation,
|
|
10624
|
-
lineInfos,
|
|
10625
|
-
matchingDiagnostics,
|
|
10626
|
-
x,
|
|
10627
|
-
y
|
|
10628
|
-
};
|
|
10629
|
-
};
|
|
10630
|
-
|
|
10631
10657
|
const loadContent$1 = async (editorUid, state, position) => {
|
|
10632
10658
|
const hoverInfo = await getEditorHoverInfo(editorUid, position);
|
|
10633
10659
|
if (!hoverInfo) {
|
|
@@ -10771,6 +10797,12 @@ const hoverDocumentationNode = {
|
|
|
10771
10797
|
className: HoverDocumentation,
|
|
10772
10798
|
type: Div
|
|
10773
10799
|
};
|
|
10800
|
+
const hoverSashNode = {
|
|
10801
|
+
childCount: 0,
|
|
10802
|
+
className: mergeClassNames('Sash', 'SashVertical', 'SashResize'),
|
|
10803
|
+
onPointerDown: HandleSashPointerDown,
|
|
10804
|
+
type: Div
|
|
10805
|
+
};
|
|
10774
10806
|
const getChildCount = (lineInfos, documentation, diagnostics) => {
|
|
10775
10807
|
const documentationCount = documentation ? 1 : 0;
|
|
10776
10808
|
const diagnosticsCount = diagnostics && diagnostics.length > 0 ? 1 : 0;
|
|
@@ -10804,12 +10836,7 @@ const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
|
|
|
10804
10836
|
if (documentation) {
|
|
10805
10837
|
dom.push(hoverDocumentationNode, text(documentation));
|
|
10806
10838
|
}
|
|
10807
|
-
dom.push(
|
|
10808
|
-
childCount: 0,
|
|
10809
|
-
className: mergeClassNames('Sash', 'SashVertical', 'SashResize'),
|
|
10810
|
-
onPointerDown: HandleSashPointerDown,
|
|
10811
|
-
type: Div
|
|
10812
|
-
});
|
|
10839
|
+
dom.push(hoverSashNode);
|
|
10813
10840
|
return dom;
|
|
10814
10841
|
};
|
|
10815
10842
|
|
|
@@ -11477,6 +11504,10 @@ const getKeyBindings = () => {
|
|
|
11477
11504
|
command: 'Editor.toggleBreakpoint',
|
|
11478
11505
|
key: F9,
|
|
11479
11506
|
when: FocusEditorText
|
|
11507
|
+
}, {
|
|
11508
|
+
command: 'Editor.goToDefinition',
|
|
11509
|
+
key: F12,
|
|
11510
|
+
when: FocusEditorText
|
|
11480
11511
|
}, {
|
|
11481
11512
|
command: 'EditorRename.accept',
|
|
11482
11513
|
key: Enter,
|
|
@@ -11543,7 +11574,7 @@ const getKeyBindings = () => {
|
|
|
11543
11574
|
when: FocusEditorText
|
|
11544
11575
|
}, {
|
|
11545
11576
|
command: 'Editor.findAllReferences',
|
|
11546
|
-
key:
|
|
11577
|
+
key: Shift | F12,
|
|
11547
11578
|
when: FocusEditorText
|
|
11548
11579
|
}, {
|
|
11549
11580
|
command: 'Editor.organizeImports',
|
|
@@ -11782,6 +11813,7 @@ const kQuickSuggestions = 'editor.quickSuggestions';
|
|
|
11782
11813
|
const kAutoClosingQuotes = 'editor.autoClosingQuotes';
|
|
11783
11814
|
const kAutoClosingBrackets = 'editor.autoclosingBrackets';
|
|
11784
11815
|
const kFontWeight = 'editor.fontWeight';
|
|
11816
|
+
const kHover = 'editor.hover';
|
|
11785
11817
|
const isAutoClosingBracketsEnabled = async () => {
|
|
11786
11818
|
return Boolean(await get$2(kAutoClosingBrackets));
|
|
11787
11819
|
};
|
|
@@ -11800,6 +11832,9 @@ const getRowHeight = async () => {
|
|
|
11800
11832
|
const getFontSize = async () => {
|
|
11801
11833
|
return (await get$2(kFontSize)) || 15; // TODO find out if it is possible to use all numeric values for settings for efficiency, maybe settings could be an array
|
|
11802
11834
|
};
|
|
11835
|
+
const getHoverEnabled = async () => {
|
|
11836
|
+
return (await get$2(kHover)) ?? true;
|
|
11837
|
+
};
|
|
11803
11838
|
const getFontFamily = async () => {
|
|
11804
11839
|
return (await get$2(kFontFamily)) || 'Fira Code';
|
|
11805
11840
|
};
|
|
@@ -11826,13 +11861,14 @@ const getFontWeight = async () => {
|
|
|
11826
11861
|
};
|
|
11827
11862
|
|
|
11828
11863
|
const getEditorPreferences = async () => {
|
|
11829
|
-
const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, rowHeight, tabSize, letterSpacing, completionTriggerCharacters] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters()]);
|
|
11864
|
+
const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, hoverEnabled, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, rowHeight, tabSize, letterSpacing, completionTriggerCharacters] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), getHoverEnabled(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters()]);
|
|
11830
11865
|
return {
|
|
11831
11866
|
completionTriggerCharacters,
|
|
11832
11867
|
diagnosticsEnabled: diagnosticsEnabled$1,
|
|
11833
11868
|
fontFamily,
|
|
11834
11869
|
fontSize,
|
|
11835
11870
|
fontWeight,
|
|
11871
|
+
hoverEnabled,
|
|
11836
11872
|
isAutoClosingBracketsEnabled: isAutoClosingBracketsEnabled$1,
|
|
11837
11873
|
isAutoClosingQuotesEnabled: isAutoClosingQuotesEnabled$1,
|
|
11838
11874
|
isAutoClosingTagsEnabled: isAutoClosingTagsEnabled$1,
|
|
@@ -12105,6 +12141,7 @@ const loadContent = async (state, savedState) => {
|
|
|
12105
12141
|
fontFamily,
|
|
12106
12142
|
fontSize,
|
|
12107
12143
|
fontWeight,
|
|
12144
|
+
hoverEnabled,
|
|
12108
12145
|
isAutoClosingBracketsEnabled,
|
|
12109
12146
|
isAutoClosingQuotesEnabled,
|
|
12110
12147
|
isAutoClosingTagsEnabled,
|
|
@@ -12132,6 +12169,7 @@ const loadContent = async (state, savedState) => {
|
|
|
12132
12169
|
fontFamily,
|
|
12133
12170
|
fontSize,
|
|
12134
12171
|
fontWeight,
|
|
12172
|
+
hoverEnabled,
|
|
12135
12173
|
isAutoClosingBracketsEnabled,
|
|
12136
12174
|
isAutoClosingQuotesEnabled,
|
|
12137
12175
|
isAutoClosingTagsEnabled,
|
|
@@ -12144,9 +12182,19 @@ const loadContent = async (state, savedState) => {
|
|
|
12144
12182
|
tabSize,
|
|
12145
12183
|
tokenizerId: newTokenizerId
|
|
12146
12184
|
};
|
|
12147
|
-
let
|
|
12185
|
+
let existingEditor;
|
|
12186
|
+
for (const key of getKeys$2()) {
|
|
12187
|
+
const editor = get$7(Number(key))?.newState;
|
|
12188
|
+
if (editor && editor.id !== id && !editor.initial && editor.uri === uri) {
|
|
12189
|
+
existingEditor = editor;
|
|
12190
|
+
break;
|
|
12191
|
+
}
|
|
12192
|
+
}
|
|
12193
|
+
let content = existingEditor ? getText$1(existingEditor) : '';
|
|
12148
12194
|
try {
|
|
12149
|
-
|
|
12195
|
+
if (!existingEditor) {
|
|
12196
|
+
content = await readFile(uri);
|
|
12197
|
+
}
|
|
12150
12198
|
} catch (error) {
|
|
12151
12199
|
const newEditor1 = setBounds(newEditor0, x, y, width, height, 9);
|
|
12152
12200
|
return {
|
|
@@ -12193,7 +12241,10 @@ const loadContent = async (state, savedState) => {
|
|
|
12193
12241
|
const newEditor5 = {
|
|
12194
12242
|
...newEditor4,
|
|
12195
12243
|
completionsOnType,
|
|
12196
|
-
initial: false
|
|
12244
|
+
initial: false,
|
|
12245
|
+
modified: existingEditor?.modified || false,
|
|
12246
|
+
redoStack: existingEditor?.redoStack || [],
|
|
12247
|
+
undoStack: existingEditor?.undoStack || []
|
|
12197
12248
|
};
|
|
12198
12249
|
return newEditor5;
|
|
12199
12250
|
};
|
|
@@ -12784,27 +12835,31 @@ const getEditorScrollBarDiagnosticsVirtualDom = scrollBarDiagnostics => {
|
|
|
12784
12835
|
}, ...getDiagnosticsVirtualDom([...scrollBarDiagnostics])];
|
|
12785
12836
|
};
|
|
12786
12837
|
|
|
12838
|
+
const verticalScrollBarNode = {
|
|
12839
|
+
childCount: 1,
|
|
12840
|
+
className: mergeClassNames('ScrollBar', 'ScrollBarVertical'),
|
|
12841
|
+
onContextMenu: HandleContextMenu,
|
|
12842
|
+
onPointerDown: HandleScrollBarVerticalPointerDown,
|
|
12843
|
+
type: Div
|
|
12844
|
+
};
|
|
12845
|
+
const verticalScrollBarThumbNode = {
|
|
12846
|
+
childCount: 0,
|
|
12847
|
+
className: mergeClassNames('ScrollBarThumb', 'ScrollBarThumbVertical'),
|
|
12848
|
+
type: Div
|
|
12849
|
+
};
|
|
12850
|
+
const horizontalScrollBarNode = {
|
|
12851
|
+
childCount: 1,
|
|
12852
|
+
className: mergeClassNames('ScrollBar', 'ScrollBarHorizontal'),
|
|
12853
|
+
onPointerDown: HandleScrollBarHorizontalPointerDown,
|
|
12854
|
+
type: Div
|
|
12855
|
+
};
|
|
12856
|
+
const horizontalScrollBarThumbNode = {
|
|
12857
|
+
childCount: 0,
|
|
12858
|
+
className: mergeClassNames('ScrollBarThumb', 'ScrollBarThumbHorizontal'),
|
|
12859
|
+
type: Div
|
|
12860
|
+
};
|
|
12787
12861
|
const getScrollBarVirtualDom = () => {
|
|
12788
|
-
return [
|
|
12789
|
-
childCount: 1,
|
|
12790
|
-
className: mergeClassNames('ScrollBar', 'ScrollBarVertical'),
|
|
12791
|
-
onContextMenu: HandleContextMenu,
|
|
12792
|
-
onPointerDown: HandleScrollBarVerticalPointerDown,
|
|
12793
|
-
type: Div
|
|
12794
|
-
}, {
|
|
12795
|
-
childCount: 0,
|
|
12796
|
-
className: mergeClassNames('ScrollBarThumb', 'ScrollBarThumbVertical'),
|
|
12797
|
-
type: Div
|
|
12798
|
-
}, {
|
|
12799
|
-
childCount: 1,
|
|
12800
|
-
className: mergeClassNames('ScrollBar', 'ScrollBarHorizontal'),
|
|
12801
|
-
onPointerDown: HandleScrollBarHorizontalPointerDown,
|
|
12802
|
-
type: Div
|
|
12803
|
-
}, {
|
|
12804
|
-
childCount: 0,
|
|
12805
|
-
className: mergeClassNames('ScrollBarThumb', 'ScrollBarThumbHorizontal'),
|
|
12806
|
-
type: Div
|
|
12807
|
-
}];
|
|
12862
|
+
return [verticalScrollBarNode, verticalScrollBarThumbNode, horizontalScrollBarNode, horizontalScrollBarThumbNode];
|
|
12808
12863
|
};
|
|
12809
12864
|
|
|
12810
12865
|
const editorContentNode = {
|
|
@@ -12872,6 +12927,11 @@ const getGutterInfos = (minLineY, maxLineY, breakPoints, showLineNumbers = true,
|
|
|
12872
12927
|
return gutterInfos;
|
|
12873
12928
|
};
|
|
12874
12929
|
|
|
12930
|
+
const textEditorErrorIconNode = {
|
|
12931
|
+
childCount: 0,
|
|
12932
|
+
className: mergeClassNames('EditorTextIcon', 'EditorTextIconError', 'MaskIcon', 'MaskIconError'),
|
|
12933
|
+
type: Div
|
|
12934
|
+
};
|
|
12875
12935
|
const textEditorErrorMessageNode = {
|
|
12876
12936
|
childCount: 1,
|
|
12877
12937
|
className: 'TextEditorErrorMessage',
|
|
@@ -12901,11 +12961,7 @@ const getEditorVirtualDom = ({
|
|
|
12901
12961
|
'data-uid': uid,
|
|
12902
12962
|
role: Code,
|
|
12903
12963
|
type: Div
|
|
12904
|
-
},
|
|
12905
|
-
childCount: 0,
|
|
12906
|
-
className: mergeClassNames('EditorTextIcon', 'EditorTextIconError', 'MaskIcon', 'MaskIconError'),
|
|
12907
|
-
type: Div
|
|
12908
|
-
}, textEditorErrorMessageNode, text(loadError)];
|
|
12964
|
+
}, textEditorErrorIconNode, textEditorErrorMessageNode, text(loadError)];
|
|
12909
12965
|
}
|
|
12910
12966
|
const visibleGutterInfos = breakPoints.length > 0 || visibleLineIndices ? getGutterInfos(minLineY, maxLineY, breakPoints, lineNumbers, visibleLineIndices) : gutterInfos;
|
|
12911
12967
|
const showGutter = lineNumbers || breakPoints.length > 0;
|
|
@@ -13420,18 +13476,20 @@ const editorDiagnosticEffect = {
|
|
|
13420
13476
|
isActive: (oldEditor, newEditor) => newEditor.diagnosticsEnabled && JSON.stringify(oldEditor.lines) !== JSON.stringify(newEditor.lines)
|
|
13421
13477
|
};
|
|
13422
13478
|
|
|
13423
|
-
const queues =
|
|
13479
|
+
const queues = {};
|
|
13424
13480
|
|
|
13425
13481
|
// TODO wrap commands globally, not per editor
|
|
13426
13482
|
// TODO only store editor state in editor worker, not in renderer worker also
|
|
13427
13483
|
|
|
13428
13484
|
const wrapCommand = fn => async (uid, ...args) => {
|
|
13429
|
-
const
|
|
13485
|
+
const initialInstance = get$7(uid);
|
|
13486
|
+
const queueKey = initialInstance?.newState.uri || uid;
|
|
13487
|
+
const previous = queues[queueKey];
|
|
13430
13488
|
const {
|
|
13431
13489
|
promise: next,
|
|
13432
13490
|
resolve
|
|
13433
13491
|
} = Promise.withResolvers();
|
|
13434
|
-
queues[
|
|
13492
|
+
queues[queueKey] = next;
|
|
13435
13493
|
if (previous) {
|
|
13436
13494
|
await previous;
|
|
13437
13495
|
}
|
|
@@ -13444,19 +13502,50 @@ const wrapCommand = fn => async (uid, ...args) => {
|
|
|
13444
13502
|
}
|
|
13445
13503
|
const newEditorWithDerivedState = await updateDerivedState(state, newEditor);
|
|
13446
13504
|
set$9(uid, state, newEditorWithDerivedState);
|
|
13447
|
-
|
|
13448
|
-
|
|
13505
|
+
let finalEditor = newEditorWithDerivedState;
|
|
13506
|
+
if (editorDiagnosticEffect.isActive(state, newEditorWithDerivedState)) {
|
|
13507
|
+
finalEditor = await editorDiagnosticEffect.apply(newEditorWithDerivedState);
|
|
13508
|
+
if (!get$7(uid)) {
|
|
13509
|
+
return finalEditor;
|
|
13510
|
+
}
|
|
13511
|
+
set$9(uid, state, finalEditor);
|
|
13449
13512
|
}
|
|
13450
|
-
const
|
|
13451
|
-
|
|
13452
|
-
|
|
13513
|
+
const {
|
|
13514
|
+
initial,
|
|
13515
|
+
lines,
|
|
13516
|
+
modified,
|
|
13517
|
+
redoStack,
|
|
13518
|
+
undoStack,
|
|
13519
|
+
uri
|
|
13520
|
+
} = state;
|
|
13521
|
+
if (!initial && uri === finalEditor.uri && (lines !== finalEditor.lines || modified !== finalEditor.modified || redoStack !== finalEditor.redoStack || undoStack !== finalEditor.undoStack)) {
|
|
13522
|
+
for (const key of getKeys$2()) {
|
|
13523
|
+
const otherUid = Number(key);
|
|
13524
|
+
const instance = get$7(otherUid);
|
|
13525
|
+
const editor = instance?.newState;
|
|
13526
|
+
if (otherUid === uid || !instance || !editor || editor.initial || editor.uri !== finalEditor.uri) {
|
|
13527
|
+
continue;
|
|
13528
|
+
}
|
|
13529
|
+
const synchronizedEditor = await updateDerivedState(editor, {
|
|
13530
|
+
...editor,
|
|
13531
|
+
decorations: finalEditor.decorations,
|
|
13532
|
+
diagnostics: finalEditor.diagnostics,
|
|
13533
|
+
incrementalEdits: emptyIncrementalEdits,
|
|
13534
|
+
invalidStartIndex: Math.min(editor.invalidStartIndex, finalEditor.invalidStartIndex),
|
|
13535
|
+
lines: finalEditor.lines,
|
|
13536
|
+
modified: finalEditor.modified,
|
|
13537
|
+
redoStack: finalEditor.redoStack,
|
|
13538
|
+
undoStack: finalEditor.undoStack,
|
|
13539
|
+
visualDecorations: finalEditor.visualDecorations
|
|
13540
|
+
});
|
|
13541
|
+
set$9(otherUid, instance.oldState, synchronizedEditor);
|
|
13542
|
+
}
|
|
13453
13543
|
}
|
|
13454
|
-
|
|
13455
|
-
return newEditorWithDiagnostics;
|
|
13544
|
+
return finalEditor;
|
|
13456
13545
|
} finally {
|
|
13457
13546
|
resolve();
|
|
13458
|
-
if (queues[
|
|
13459
|
-
queues[
|
|
13547
|
+
if (queues[queueKey] === next) {
|
|
13548
|
+
delete queues[queueKey];
|
|
13460
13549
|
}
|
|
13461
13550
|
}
|
|
13462
13551
|
};
|
|
@@ -13641,7 +13730,7 @@ const commandMap = {
|
|
|
13641
13730
|
'Editor.setSelections2': setSelections2,
|
|
13642
13731
|
'Editor.setText': wrapCommand(setText),
|
|
13643
13732
|
'Editor.showHover': showHover,
|
|
13644
|
-
'Editor.showHover2':
|
|
13733
|
+
'Editor.showHover2': wrapCommand(showHover2),
|
|
13645
13734
|
'Editor.showSourceActions': wrapCommand(showSourceActions),
|
|
13646
13735
|
'Editor.showSourceActions2': wrapCommand(showSourceActions),
|
|
13647
13736
|
'Editor.showSourceActions3': wrapCommand(showSourceActions),
|
|
@@ -13828,6 +13917,11 @@ const listen = async () => {
|
|
|
13828
13917
|
|
|
13829
13918
|
const CodeGeneratorInput = 'CodeGeneratorInput';
|
|
13830
13919
|
|
|
13920
|
+
const codeGeneratorNode = {
|
|
13921
|
+
childCount: 2,
|
|
13922
|
+
className: mergeClassNames(Viewlet, CodeGeneratorWidget),
|
|
13923
|
+
type: Div
|
|
13924
|
+
};
|
|
13831
13925
|
const codeGeneratorMessageNode = {
|
|
13832
13926
|
childCount: 1,
|
|
13833
13927
|
className: CodeGeneratorMessage,
|
|
@@ -13836,11 +13930,7 @@ const codeGeneratorMessageNode = {
|
|
|
13836
13930
|
const getCodeGeneratorVirtualDom = state => {
|
|
13837
13931
|
const escapeToClose$1 = escapeToClose();
|
|
13838
13932
|
const enterCode$1 = enterCode();
|
|
13839
|
-
return [{
|
|
13840
|
-
childCount: 2,
|
|
13841
|
-
className: mergeClassNames(Viewlet, CodeGeneratorWidget),
|
|
13842
|
-
type: Div
|
|
13843
|
-
}, {
|
|
13933
|
+
return [codeGeneratorNode, {
|
|
13844
13934
|
childCount: 0,
|
|
13845
13935
|
className: mergeClassNames(CodeGeneratorInput$1, InputBox),
|
|
13846
13936
|
name: CodeGeneratorInput,
|
|
@@ -13950,6 +14040,11 @@ const EditorColorPickerWidget = {
|
|
|
13950
14040
|
|
|
13951
14041
|
const Focusable = 0;
|
|
13952
14042
|
|
|
14043
|
+
const completionDetailNode = {
|
|
14044
|
+
childCount: 2,
|
|
14045
|
+
className: mergeClassNames('Viewlet', 'EditorCompletionDetails'),
|
|
14046
|
+
type: Div
|
|
14047
|
+
};
|
|
13953
14048
|
const completionDetailContentNode = {
|
|
13954
14049
|
childCount: 1,
|
|
13955
14050
|
className: CompletionDetailContent,
|
|
@@ -13963,16 +14058,13 @@ const completionDetailCloseButtonNode = {
|
|
|
13963
14058
|
tabIndex: Focusable,
|
|
13964
14059
|
type: Div
|
|
13965
14060
|
};
|
|
14061
|
+
const completionDetailCloseIconNode = {
|
|
14062
|
+
childCount: 0,
|
|
14063
|
+
className: mergeClassNames(MaskIcon, IconClose),
|
|
14064
|
+
type: Div
|
|
14065
|
+
};
|
|
13966
14066
|
const getCompletionDetailVirtualDom = content => {
|
|
13967
|
-
const dom = [
|
|
13968
|
-
childCount: 2,
|
|
13969
|
-
className: mergeClassNames('Viewlet', 'EditorCompletionDetails'),
|
|
13970
|
-
type: Div
|
|
13971
|
-
}, completionDetailContentNode, text(content), completionDetailCloseButtonNode, {
|
|
13972
|
-
childCount: 0,
|
|
13973
|
-
className: mergeClassNames(MaskIcon, IconClose),
|
|
13974
|
-
type: Div
|
|
13975
|
-
}];
|
|
14067
|
+
const dom = [completionDetailNode, completionDetailContentNode, text(content), completionDetailCloseButtonNode, completionDetailCloseIconNode];
|
|
13976
14068
|
return dom;
|
|
13977
14069
|
};
|
|
13978
14070
|
|
|
@@ -14077,7 +14169,11 @@ const EditorCompletionDetailWidget = {
|
|
|
14077
14169
|
|
|
14078
14170
|
const commandsToForward = [SetDom2, SetCss, AppendToBody, SetBounds2, RegisterEventListeners, SetSelectionByName, SetValueByName, SetFocusContext, SetUid, 'Viewlet.focusSelector'];
|
|
14079
14171
|
const render$1 = widget => {
|
|
14080
|
-
const
|
|
14172
|
+
const {
|
|
14173
|
+
newState,
|
|
14174
|
+
oldState
|
|
14175
|
+
} = widget;
|
|
14176
|
+
const commands = newState.commands.length > 0 ? renderFull$3(oldState, newState) : [[SetDom2, newState.uid, getHoverVirtualDom(newState.lineInfos, newState.documentation, newState.diagnostics)], [SetBounds2, newState.uid, newState.x, newState.y, newState.width, newState.height]];
|
|
14081
14177
|
const wrappedCommands = [];
|
|
14082
14178
|
const {
|
|
14083
14179
|
uid
|