@lvce-editor/editor-worker 19.72.1 → 19.72.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.
@@ -4155,18 +4155,15 @@ const getX = async (line, column, fontWeight, fontSize, fontFamily, isMonospaceF
4155
4155
  number(averageCharWidth);
4156
4156
  number(difference);
4157
4157
  if (column === 0) {
4158
- return 0;
4158
+ return difference === 0 ? 0 : Math.min(width, difference);
4159
4159
  }
4160
4160
  // TODO support non-monospace font, emoji, tab character, zero width characters
4161
- if (column * averageCharWidth > width) {
4162
- return width;
4163
- }
4164
4161
  const normalize = shouldNormalizeText(line);
4165
4162
  const normalizedLine = normalizeText(line, normalize, tabSize);
4166
4163
  const tabCount = getTabCount(line.slice(0, column));
4167
- const partialText = normalizedLine.slice(0, column + tabCount);
4164
+ const partialText = normalizedLine.slice(0, column + tabCount * (tabSize - 1));
4168
4165
  const textWidth = await measureTextWidth(partialText, fontWeight, fontSize, fontFamily, letterSpacing, isMonospaceFont, averageCharWidth);
4169
- return textWidth - halfCursorWidth + difference;
4166
+ return Math.min(width, textWidth - halfCursorWidth + difference);
4170
4167
  };
4171
4168
 
4172
4169
  const px = value => {
@@ -4278,7 +4275,6 @@ const getVisible = async editor => {
4278
4275
  charWidth,
4279
4276
  cursorWidth,
4280
4277
  deltaY,
4281
- differences,
4282
4278
  focused,
4283
4279
  foldingRanges = [],
4284
4280
  fontFamily,
@@ -4307,7 +4303,7 @@ const getVisible = async editor => {
4307
4303
  const startVisualRow = itemHeight ? Math.floor(deltaY / itemHeight) : getVisualRow(minLineY);
4308
4304
  const endVisualRow = startVisualRow + (visibleViewLineIndices?.length || actualVisibleLineIndices.length);
4309
4305
  const getRelativeRow = rowIndex => getVisualRow(rowIndex) - startVisualRow;
4310
- const getDifference = rowIndex => differences[actualVisibleLineIndices.indexOf(rowIndex)];
4306
+ const horizontalOffset = -(editor.deltaX ?? 0);
4311
4307
  for (let i = 0; i < selections.length; i += 4) {
4312
4308
  const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn, reversed] = getSelectionPairs(selections, i);
4313
4309
  const selectionStartVisualRow = getVisualRow(selectionStartRow);
@@ -4316,7 +4312,7 @@ const getVisible = async editor => {
4316
4312
  continue;
4317
4313
  }
4318
4314
  const relativeEndLineRow = getRelativeRow(selectionEndRow);
4319
- const endLineDifference = getDifference(selectionEndRow);
4315
+ const endLineDifference = horizontalOffset;
4320
4316
  const endLine = lines[selectionEndRow];
4321
4317
  const endLineEndX = await getX(endLine, selectionEndColumn, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, endLineDifference);
4322
4318
  const endLineY = relativeEndLineRow * rowHeight;
@@ -4326,7 +4322,7 @@ const getVisible = async editor => {
4326
4322
  }
4327
4323
  const startLineYRelative = getRelativeRow(selectionStartRow);
4328
4324
  const startLineY = startLineYRelative * rowHeight;
4329
- const startLineDifference = getDifference(selectionStartRow);
4325
+ const startLineDifference = horizontalOffset;
4330
4326
  if (selectionStartRow === selectionEndRow) {
4331
4327
  const startX = await getX(endLine, selectionStartColumn, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, startLineDifference);
4332
4328
  if (reversed) {
@@ -4353,7 +4349,7 @@ const getVisible = async editor => {
4353
4349
  const currentLine = lines[rowIndex];
4354
4350
  const relativeLine = getRelativeRow(rowIndex);
4355
4351
  const currentLineY = relativeLine * rowHeight;
4356
- const difference = getDifference(rowIndex);
4352
+ const difference = horizontalOffset;
4357
4353
  const selectionWidth = await getX(currentLine, currentLine.length, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, averageCharWidth, difference);
4358
4354
  visibleSelections.push(0, currentLineY, selectionWidth, rowHeight);
4359
4355
  }
@@ -5315,6 +5311,7 @@ const getVisibleDiagnostics = async (editor, diagnostics) => {
5315
5311
  const visibleDiagnostics = [];
5316
5312
  const {
5317
5313
  charWidth,
5314
+ deltaX = 0,
5318
5315
  deltaY,
5319
5316
  fontFamily,
5320
5317
  fontSize,
@@ -5325,8 +5322,7 @@ const getVisibleDiagnostics = async (editor, diagnostics) => {
5325
5322
  lines,
5326
5323
  rowHeight,
5327
5324
  tabSize,
5328
- viewLineIndices,
5329
- width
5325
+ viewLineIndices
5330
5326
  } = editor;
5331
5327
  const startVisualRow = itemHeight ? Math.floor(deltaY / itemHeight) : editor.minLineY || 0;
5332
5328
  for (const diagnostic of diagnostics) {
@@ -5335,10 +5331,10 @@ const getVisibleDiagnostics = async (editor, diagnostics) => {
5335
5331
  endColumnIndex,
5336
5332
  rowIndex
5337
5333
  } = diagnostic;
5338
- const endLineDifference = 0;
5334
+ const endLineDifference = -deltaX;
5339
5335
  const halfCursorWidth = 0;
5340
- const x = await getX(lines[rowIndex], columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, charWidth, endLineDifference);
5341
- const endX = await getX(lines[rowIndex], endColumnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, charWidth, endLineDifference);
5336
+ const x = await getX(lines[rowIndex], columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, Infinity, charWidth, endLineDifference);
5337
+ const endX = await getX(lines[rowIndex], endColumnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, Infinity, charWidth, endLineDifference);
5342
5338
  const diagnosticWidth = Math.max(charWidth, endX - x);
5343
5339
  const visualRow = viewLineIndices ? getVisualRowForDocumentRow$1(rowIndex, viewLineIndices) : rowIndex;
5344
5340
  const y = (visualRow - startVisualRow) * rowHeight;
@@ -5417,10 +5413,10 @@ const updateHorizontalLayout = async state => {
5417
5413
  };
5418
5414
 
5419
5415
  const shouldUpdateDiagnosticData = (oldState, newState) => {
5420
- return oldState.diagnostics !== newState.diagnostics || (newState.diagnostics?.length ?? 0) > 0 && (oldState.minLineY !== newState.minLineY || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width);
5416
+ return oldState.diagnostics !== newState.diagnostics || (newState.diagnostics?.length ?? 0) > 0 && (oldState.deltaX !== newState.deltaX || oldState.minLineY !== newState.minLineY || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width);
5421
5417
  };
5422
5418
  const shouldUpdateSelectionData = (oldState, newState) => {
5423
- return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.cursorWidth !== newState.cursorWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
5419
+ return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.deltaX !== newState.deltaX || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.visibleViewLineIndices !== newState.visibleViewLineIndices || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.cursorWidth !== newState.cursorWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
5424
5420
  };
5425
5421
  const shouldUpdateBracketMatchData = (oldState, newState) => {
5426
5422
  if (!('bracketMatchInfos' in newState)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.72.1",
3
+ "version": "19.72.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"