@lvce-editor/editor-worker 19.76.1 → 19.76.3
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/diff-sdk.js +60 -11
- package/dist/editorWorkerMain.js +60 -11
- package/package.json +1 -1
package/dist/diff-sdk.js
CHANGED
|
@@ -4646,21 +4646,66 @@ const getVisible = async editor => {
|
|
|
4646
4646
|
length: maxLineY - minLineY
|
|
4647
4647
|
}, (_, index) => minLineY + index);
|
|
4648
4648
|
const getVisualRow = rowIndex => viewLineIndices ? getVisualRowForDocumentRow$1(rowIndex, viewLineIndices) : getVisualRowForDocumentRow(rowIndex, foldingRanges);
|
|
4649
|
-
const
|
|
4650
|
-
const
|
|
4651
|
-
const getRelativeRow = rowIndex => getVisualRow(rowIndex) -
|
|
4649
|
+
const visibleStartVisualRow = itemHeight ? Math.floor(deltaY / itemHeight) : getVisualRow(minLineY);
|
|
4650
|
+
const visibleEndVisualRow = visibleStartVisualRow + (visibleViewLineIndices?.length || actualVisibleLineIndices.length);
|
|
4651
|
+
const getRelativeRow = rowIndex => getVisualRow(rowIndex) - visibleStartVisualRow;
|
|
4652
4652
|
const horizontalOffset = -(editor.deltaX ?? 0);
|
|
4653
|
+
const lineWidths = new Map();
|
|
4654
|
+
const textsToMeasure = new Set();
|
|
4655
|
+
const textByLine = new Map();
|
|
4656
|
+
const addLineWidth = line => {
|
|
4657
|
+
if (!line) {
|
|
4658
|
+
return;
|
|
4659
|
+
}
|
|
4660
|
+
const cachedWidth = getCachedLineWidth(editor, line);
|
|
4661
|
+
if (cachedWidth !== undefined) {
|
|
4662
|
+
lineWidths.set(line, cachedWidth);
|
|
4663
|
+
return;
|
|
4664
|
+
}
|
|
4665
|
+
const text = line.replaceAll('\t', () => ' '.repeat(tabSize));
|
|
4666
|
+
textByLine.set(line, text);
|
|
4667
|
+
textsToMeasure.add(text);
|
|
4668
|
+
};
|
|
4669
|
+
for (let i = 0; i < selections.length; i += 4) {
|
|
4670
|
+
const [selectionStartRow,, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
|
|
4671
|
+
const selectionStartVisualRow = getVisualRow(selectionStartRow);
|
|
4672
|
+
const selectionEndVisualRow = getVisualRow(selectionEndRow);
|
|
4673
|
+
if (selectionEndVisualRow < visibleStartVisualRow || selectionStartVisualRow >= visibleEndVisualRow) {
|
|
4674
|
+
continue;
|
|
4675
|
+
}
|
|
4676
|
+
if (selectionStartRow !== selectionEndRow && selectionStartVisualRow >= visibleStartVisualRow && selectionStartVisualRow < visibleEndVisualRow) {
|
|
4677
|
+
const startLine = lines[selectionStartRow];
|
|
4678
|
+
addLineWidth(startLine);
|
|
4679
|
+
}
|
|
4680
|
+
if (selectionEndColumn === lines[selectionEndRow].length && selectionEndVisualRow >= visibleStartVisualRow && selectionEndVisualRow < visibleEndVisualRow) {
|
|
4681
|
+
const endLine = lines[selectionEndRow];
|
|
4682
|
+
addLineWidth(endLine);
|
|
4683
|
+
}
|
|
4684
|
+
const selectedVisibleRows = actualVisibleLineIndices.filter(rowIndex => rowIndex > selectionStartRow && rowIndex < selectionEndRow);
|
|
4685
|
+
for (const rowIndex of selectedVisibleRows) {
|
|
4686
|
+
const line = lines[rowIndex];
|
|
4687
|
+
addLineWidth(line);
|
|
4688
|
+
}
|
|
4689
|
+
}
|
|
4690
|
+
const texts = [...textsToMeasure];
|
|
4691
|
+
if (texts.length > 0) {
|
|
4692
|
+
const widths = await measureTextWidths(texts, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, averageCharWidth);
|
|
4693
|
+
const widthByText = new Map(texts.map((text, index) => [text, widths[index]]));
|
|
4694
|
+
for (const [line, text] of textByLine) {
|
|
4695
|
+
lineWidths.set(line, widthByText.get(text));
|
|
4696
|
+
}
|
|
4697
|
+
}
|
|
4653
4698
|
for (let i = 0; i < selections.length; i += 4) {
|
|
4654
4699
|
const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn, reversed] = getSelectionPairs(selections, i);
|
|
4655
4700
|
const selectionStartVisualRow = getVisualRow(selectionStartRow);
|
|
4656
4701
|
const selectionEndVisualRow = getVisualRow(selectionEndRow);
|
|
4657
|
-
if (selectionEndVisualRow <
|
|
4702
|
+
if (selectionEndVisualRow < visibleStartVisualRow || selectionStartVisualRow >= visibleEndVisualRow) {
|
|
4658
4703
|
continue;
|
|
4659
4704
|
}
|
|
4660
4705
|
const relativeEndLineRow = getRelativeRow(selectionEndRow);
|
|
4661
4706
|
const endLineDifference = horizontalOffset;
|
|
4662
4707
|
const endLine = lines[selectionEndRow];
|
|
4663
|
-
const endLineEndX = await getX(endLine, selectionEndColumn, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, endLineDifference, getCachedLineWidth(editor, endLine));
|
|
4708
|
+
const endLineEndX = await getX(endLine, selectionEndColumn, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, endLineDifference, lineWidths.get(endLine) ?? getCachedLineWidth(editor, endLine));
|
|
4664
4709
|
const endLineY = relativeEndLineRow * rowHeight;
|
|
4665
4710
|
if (isEmpty$1(selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn) && endLineEndX > 0) {
|
|
4666
4711
|
visibleCursors.push(endLineEndX, endLineY);
|
|
@@ -4679,10 +4724,10 @@ const getVisible = async editor => {
|
|
|
4679
4724
|
const selectionWidth = endLineEndX - startX;
|
|
4680
4725
|
visibleSelections.push(startX, startLineY, selectionWidth, rowHeight);
|
|
4681
4726
|
} else {
|
|
4682
|
-
if (selectionStartVisualRow >=
|
|
4727
|
+
if (selectionStartVisualRow >= visibleStartVisualRow) {
|
|
4683
4728
|
const startLine = lines[selectionStartRow];
|
|
4684
4729
|
const startLineStartX = await getX(startLine, selectionStartColumn, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, startLineDifference);
|
|
4685
|
-
const startLineEndX = await getX(startLine, startLine.length, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, startLineDifference);
|
|
4730
|
+
const startLineEndX = await getX(startLine, startLine.length, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, startLineDifference, lineWidths.get(startLine) ?? getCachedLineWidth(editor, startLine));
|
|
4686
4731
|
const startLineStartY = startLineYRelative * rowHeight;
|
|
4687
4732
|
const selectionWidth = startLineEndX - startLineStartX;
|
|
4688
4733
|
if (reversed) {
|
|
@@ -4696,10 +4741,10 @@ const getVisible = async editor => {
|
|
|
4696
4741
|
const relativeLine = getRelativeRow(rowIndex);
|
|
4697
4742
|
const currentLineY = relativeLine * rowHeight;
|
|
4698
4743
|
const difference = horizontalOffset;
|
|
4699
|
-
const selectionWidth = await getX(currentLine, currentLine.length, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, difference);
|
|
4744
|
+
const selectionWidth = await getX(currentLine, currentLine.length, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, difference, lineWidths.get(currentLine) ?? getCachedLineWidth(editor, currentLine));
|
|
4700
4745
|
visibleSelections.push(0, currentLineY, selectionWidth, rowHeight);
|
|
4701
4746
|
}
|
|
4702
|
-
if (selectionEndVisualRow <
|
|
4747
|
+
if (selectionEndVisualRow < visibleEndVisualRow) {
|
|
4703
4748
|
const selectionWidth = endLineEndX;
|
|
4704
4749
|
visibleSelections.push(0, endLineY, selectionWidth, rowHeight);
|
|
4705
4750
|
if (!reversed) {
|
|
@@ -11881,7 +11926,9 @@ const advanceSelectionAutoScroll = async editor => {
|
|
|
11881
11926
|
hasListener: false
|
|
11882
11927
|
};
|
|
11883
11928
|
}
|
|
11884
|
-
const
|
|
11929
|
+
const distance = Math.abs(y - (y < editor.y ? editor.y : bottom));
|
|
11930
|
+
const speed = Math.min(96, 4 + distance * 0.2);
|
|
11931
|
+
const deltaY = y < editor.y ? -speed : speed;
|
|
11885
11932
|
const scrolledEditor = await setDeltaY$1(editor, editor.deltaY + deltaY);
|
|
11886
11933
|
if (scrolledEditor === editor) {
|
|
11887
11934
|
return {
|
|
@@ -16723,7 +16770,9 @@ const createCommandMap = commands => ({
|
|
|
16723
16770
|
if (!current || editor.lifecycle?.disposed || current.lifecycle !== editor.lifecycle) return;
|
|
16724
16771
|
// The wrapped command has released the document queue before requesting a
|
|
16725
16772
|
// render; a diff can now run without waiting on its own command.
|
|
16726
|
-
|
|
16773
|
+
// Blur can finish after another editor has gained focus. Apply its state
|
|
16774
|
+
// without letting the delayed render replace the current focus context.
|
|
16775
|
+
await RendererWorker.invoke('Viewlet.requestRender', uid, command === 'handleBlur');
|
|
16727
16776
|
}
|
|
16728
16777
|
});
|
|
16729
16778
|
|
package/dist/editorWorkerMain.js
CHANGED
|
@@ -5059,21 +5059,66 @@ const getVisible = async editor => {
|
|
|
5059
5059
|
length: maxLineY - minLineY
|
|
5060
5060
|
}, (_, index) => minLineY + index);
|
|
5061
5061
|
const getVisualRow = rowIndex => viewLineIndices ? getVisualRowForDocumentRow$1(rowIndex, viewLineIndices) : getVisualRowForDocumentRow(rowIndex, foldingRanges);
|
|
5062
|
-
const
|
|
5063
|
-
const
|
|
5064
|
-
const getRelativeRow = rowIndex => getVisualRow(rowIndex) -
|
|
5062
|
+
const visibleStartVisualRow = itemHeight ? Math.floor(deltaY / itemHeight) : getVisualRow(minLineY);
|
|
5063
|
+
const visibleEndVisualRow = visibleStartVisualRow + (visibleViewLineIndices?.length || actualVisibleLineIndices.length);
|
|
5064
|
+
const getRelativeRow = rowIndex => getVisualRow(rowIndex) - visibleStartVisualRow;
|
|
5065
5065
|
const horizontalOffset = -(editor.deltaX ?? 0);
|
|
5066
|
+
const lineWidths = new Map();
|
|
5067
|
+
const textsToMeasure = new Set();
|
|
5068
|
+
const textByLine = new Map();
|
|
5069
|
+
const addLineWidth = line => {
|
|
5070
|
+
if (!line) {
|
|
5071
|
+
return;
|
|
5072
|
+
}
|
|
5073
|
+
const cachedWidth = getCachedLineWidth(editor, line);
|
|
5074
|
+
if (cachedWidth !== undefined) {
|
|
5075
|
+
lineWidths.set(line, cachedWidth);
|
|
5076
|
+
return;
|
|
5077
|
+
}
|
|
5078
|
+
const text = line.replaceAll('\t', () => ' '.repeat(tabSize));
|
|
5079
|
+
textByLine.set(line, text);
|
|
5080
|
+
textsToMeasure.add(text);
|
|
5081
|
+
};
|
|
5082
|
+
for (let i = 0; i < selections.length; i += 4) {
|
|
5083
|
+
const [selectionStartRow,, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
|
|
5084
|
+
const selectionStartVisualRow = getVisualRow(selectionStartRow);
|
|
5085
|
+
const selectionEndVisualRow = getVisualRow(selectionEndRow);
|
|
5086
|
+
if (selectionEndVisualRow < visibleStartVisualRow || selectionStartVisualRow >= visibleEndVisualRow) {
|
|
5087
|
+
continue;
|
|
5088
|
+
}
|
|
5089
|
+
if (selectionStartRow !== selectionEndRow && selectionStartVisualRow >= visibleStartVisualRow && selectionStartVisualRow < visibleEndVisualRow) {
|
|
5090
|
+
const startLine = lines[selectionStartRow];
|
|
5091
|
+
addLineWidth(startLine);
|
|
5092
|
+
}
|
|
5093
|
+
if (selectionEndColumn === lines[selectionEndRow].length && selectionEndVisualRow >= visibleStartVisualRow && selectionEndVisualRow < visibleEndVisualRow) {
|
|
5094
|
+
const endLine = lines[selectionEndRow];
|
|
5095
|
+
addLineWidth(endLine);
|
|
5096
|
+
}
|
|
5097
|
+
const selectedVisibleRows = actualVisibleLineIndices.filter(rowIndex => rowIndex > selectionStartRow && rowIndex < selectionEndRow);
|
|
5098
|
+
for (const rowIndex of selectedVisibleRows) {
|
|
5099
|
+
const line = lines[rowIndex];
|
|
5100
|
+
addLineWidth(line);
|
|
5101
|
+
}
|
|
5102
|
+
}
|
|
5103
|
+
const texts = [...textsToMeasure];
|
|
5104
|
+
if (texts.length > 0) {
|
|
5105
|
+
const widths = await measureTextWidths(texts, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, averageCharWidth);
|
|
5106
|
+
const widthByText = new Map(texts.map((text, index) => [text, widths[index]]));
|
|
5107
|
+
for (const [line, text] of textByLine) {
|
|
5108
|
+
lineWidths.set(line, widthByText.get(text));
|
|
5109
|
+
}
|
|
5110
|
+
}
|
|
5066
5111
|
for (let i = 0; i < selections.length; i += 4) {
|
|
5067
5112
|
const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn, reversed] = getSelectionPairs(selections, i);
|
|
5068
5113
|
const selectionStartVisualRow = getVisualRow(selectionStartRow);
|
|
5069
5114
|
const selectionEndVisualRow = getVisualRow(selectionEndRow);
|
|
5070
|
-
if (selectionEndVisualRow <
|
|
5115
|
+
if (selectionEndVisualRow < visibleStartVisualRow || selectionStartVisualRow >= visibleEndVisualRow) {
|
|
5071
5116
|
continue;
|
|
5072
5117
|
}
|
|
5073
5118
|
const relativeEndLineRow = getRelativeRow(selectionEndRow);
|
|
5074
5119
|
const endLineDifference = horizontalOffset;
|
|
5075
5120
|
const endLine = lines[selectionEndRow];
|
|
5076
|
-
const endLineEndX = await getX(endLine, selectionEndColumn, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, endLineDifference, getCachedLineWidth(editor, endLine));
|
|
5121
|
+
const endLineEndX = await getX(endLine, selectionEndColumn, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, endLineDifference, lineWidths.get(endLine) ?? getCachedLineWidth(editor, endLine));
|
|
5077
5122
|
const endLineY = relativeEndLineRow * rowHeight;
|
|
5078
5123
|
if (isEmpty$1(selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn) && endLineEndX > 0) {
|
|
5079
5124
|
visibleCursors.push(endLineEndX, endLineY);
|
|
@@ -5092,10 +5137,10 @@ const getVisible = async editor => {
|
|
|
5092
5137
|
const selectionWidth = endLineEndX - startX;
|
|
5093
5138
|
visibleSelections.push(startX, startLineY, selectionWidth, rowHeight);
|
|
5094
5139
|
} else {
|
|
5095
|
-
if (selectionStartVisualRow >=
|
|
5140
|
+
if (selectionStartVisualRow >= visibleStartVisualRow) {
|
|
5096
5141
|
const startLine = lines[selectionStartRow];
|
|
5097
5142
|
const startLineStartX = await getX(startLine, selectionStartColumn, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, startLineDifference);
|
|
5098
|
-
const startLineEndX = await getX(startLine, startLine.length, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, startLineDifference);
|
|
5143
|
+
const startLineEndX = await getX(startLine, startLine.length, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, startLineDifference, lineWidths.get(startLine) ?? getCachedLineWidth(editor, startLine));
|
|
5099
5144
|
const startLineStartY = startLineYRelative * rowHeight;
|
|
5100
5145
|
const selectionWidth = startLineEndX - startLineStartX;
|
|
5101
5146
|
if (reversed) {
|
|
@@ -5109,10 +5154,10 @@ const getVisible = async editor => {
|
|
|
5109
5154
|
const relativeLine = getRelativeRow(rowIndex);
|
|
5110
5155
|
const currentLineY = relativeLine * rowHeight;
|
|
5111
5156
|
const difference = horizontalOffset;
|
|
5112
|
-
const selectionWidth = await getX(currentLine, currentLine.length, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, difference);
|
|
5157
|
+
const selectionWidth = await getX(currentLine, currentLine.length, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, difference, lineWidths.get(currentLine) ?? getCachedLineWidth(editor, currentLine));
|
|
5113
5158
|
visibleSelections.push(0, currentLineY, selectionWidth, rowHeight);
|
|
5114
5159
|
}
|
|
5115
|
-
if (selectionEndVisualRow <
|
|
5160
|
+
if (selectionEndVisualRow < visibleEndVisualRow) {
|
|
5116
5161
|
const selectionWidth = endLineEndX;
|
|
5117
5162
|
visibleSelections.push(0, endLineY, selectionWidth, rowHeight);
|
|
5118
5163
|
if (!reversed) {
|
|
@@ -12285,7 +12330,9 @@ const advanceSelectionAutoScroll = async editor => {
|
|
|
12285
12330
|
hasListener: false
|
|
12286
12331
|
};
|
|
12287
12332
|
}
|
|
12288
|
-
const
|
|
12333
|
+
const distance = Math.abs(y - (y < editor.y ? editor.y : bottom));
|
|
12334
|
+
const speed = Math.min(96, 4 + distance * 0.2);
|
|
12335
|
+
const deltaY = y < editor.y ? -speed : speed;
|
|
12289
12336
|
const scrolledEditor = await setDeltaY$1(editor, editor.deltaY + deltaY);
|
|
12290
12337
|
if (scrolledEditor === editor) {
|
|
12291
12338
|
return {
|
|
@@ -17127,7 +17174,9 @@ const createCommandMap = commands => ({
|
|
|
17127
17174
|
if (!current || editor.lifecycle?.disposed || current.lifecycle !== editor.lifecycle) return;
|
|
17128
17175
|
// The wrapped command has released the document queue before requesting a
|
|
17129
17176
|
// render; a diff can now run without waiting on its own command.
|
|
17130
|
-
|
|
17177
|
+
// Blur can finish after another editor has gained focus. Apply its state
|
|
17178
|
+
// without letting the delayed render replace the current focus context.
|
|
17179
|
+
await invoke$e('Viewlet.requestRender', uid, command === 'handleBlur');
|
|
17131
17180
|
}
|
|
17132
17181
|
});
|
|
17133
17182
|
|