@lvce-editor/editor-worker 19.74.5 → 19.74.6
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 +30 -11
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -6097,26 +6097,45 @@ const updateHorizontalLayout = async state => {
|
|
|
6097
6097
|
const previous = caches.get(owner);
|
|
6098
6098
|
const previousWidths = previous?.font === font ? previous.widths : undefined;
|
|
6099
6099
|
const widths = new Map();
|
|
6100
|
-
|
|
6100
|
+
const textsToMeasure = new Set();
|
|
6101
|
+
const textByLine = new Map();
|
|
6101
6102
|
for (const line of lines) {
|
|
6102
|
-
|
|
6103
|
-
if (measured
|
|
6104
|
-
|
|
6103
|
+
const measured = previousWidths?.get(line);
|
|
6104
|
+
if (measured !== undefined) {
|
|
6105
|
+
widths.set(line, measured);
|
|
6106
|
+
continue;
|
|
6105
6107
|
}
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
+
const text = line.replaceAll('\t', () => ' '.repeat(tabSize));
|
|
6109
|
+
textByLine.set(line, text);
|
|
6110
|
+
textsToMeasure.add(text);
|
|
6108
6111
|
}
|
|
6109
6112
|
const showGutter = lineNumbers || breakPoints.length > 0 || lightBulbRowIndex >= 0 || gutterDecorations.length > 0;
|
|
6110
6113
|
const gutterText = String(lines.length);
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6114
|
+
if (showGutter && !widths.has(gutterText)) {
|
|
6115
|
+
const measured = previousWidths?.get(gutterText);
|
|
6116
|
+
if (measured === undefined) {
|
|
6117
|
+
textsToMeasure.add(gutterText);
|
|
6118
|
+
} else {
|
|
6119
|
+
widths.set(gutterText, measured);
|
|
6120
|
+
}
|
|
6121
|
+
}
|
|
6122
|
+
const texts = [...textsToMeasure];
|
|
6123
|
+
const measuredWidths = texts.length > 0 ? await measureTextWidths(texts, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, charWidth) : [];
|
|
6124
|
+
const measuredByText = new Map(texts.map((text, index) => [text, measuredWidths[index]]));
|
|
6125
|
+
for (const [line, text] of textByLine) {
|
|
6126
|
+
widths.set(line, measuredByText.get(text));
|
|
6127
|
+
}
|
|
6128
|
+
if (showGutter && !widths.has(gutterText)) {
|
|
6129
|
+
widths.set(gutterText, measuredByText.get(gutterText));
|
|
6130
|
+
}
|
|
6131
|
+
let longestLineWidth = 0;
|
|
6132
|
+
for (const line of lines) {
|
|
6133
|
+
longestLineWidth = Math.max(longestLineWidth, widths.get(line));
|
|
6116
6134
|
}
|
|
6117
6135
|
if (lifecycle?.disposed) {
|
|
6118
6136
|
return state;
|
|
6119
6137
|
}
|
|
6138
|
+
const gutterWidth = showGutter ? Math.max(30, widths.get(gutterText) + 1) : 0;
|
|
6120
6139
|
caches.set(owner, {
|
|
6121
6140
|
font,
|
|
6122
6141
|
widths
|