@lvce-editor/editor-worker 13.3.0 → 13.4.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.
@@ -2441,6 +2441,11 @@ const getTabCount = string => {
2441
2441
  return count;
2442
2442
  };
2443
2443
 
2444
+ const RE_ASCII = /^[\p{ASCII}]*$/u;
2445
+ const isAscii = line => {
2446
+ return RE_ASCII.test(line);
2447
+ };
2448
+
2444
2449
  const measureTextWidthFast = async (text, charWidth) => {
2445
2450
  return text.length * charWidth;
2446
2451
  };
@@ -2503,7 +2508,11 @@ const measureTextWidthSlow = async (text, fontWeight, fontSize, fontFamily, lett
2503
2508
  };
2504
2509
 
2505
2510
  const measureTextWidth = async (text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
2506
- if (isMonoSpaceFont) {
2511
+ // TODO maybe have a property for the whole text document
2512
+ // whether the document is ascii or not
2513
+ // so that it doesn't need to be checked on every cursor change
2514
+ // or scroll position change
2515
+ if (isMonoSpaceFont && isAscii(text)) {
2507
2516
  return await measureTextWidthFast(text, charWidth);
2508
2517
  }
2509
2518
  return await measureTextWidthSlow(text, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
@@ -3652,11 +3661,6 @@ const getAccurateColumnIndexUnicode = async (line, guess, averageCharWidth, even
3652
3661
  return line.length;
3653
3662
  };
3654
3663
 
3655
- const RE_ASCII = /^[\p{ASCII}]*$/u;
3656
- const isAscii = line => {
3657
- return RE_ASCII.test(line);
3658
- };
3659
-
3660
3664
  const guessOffset = (eventX, averageCharWidth) => {
3661
3665
  const guess = Math.round(eventX / averageCharWidth);
3662
3666
  return guess;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "13.3.0",
3
+ "version": "13.4.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"