@lvce-editor/editor-worker 19.74.4 → 19.74.5

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.
@@ -2369,7 +2369,13 @@ const getHorizontalScrollDimensions = ({
2369
2369
  };
2370
2370
 
2371
2371
  const defaultThreshold = 500;
2372
+ const simpleAscii = /^[\t -~]*$/;
2372
2373
  const getSegments = line => {
2374
+ if (simpleAscii.test(line)) {
2375
+ return Array.from({
2376
+ length: line.length + 1
2377
+ }, (_, index) => index);
2378
+ }
2373
2379
  if (typeof Intl.Segmenter === 'function') {
2374
2380
  // @ts-ignore
2375
2381
  return [...Array.from(new Intl.Segmenter(undefined, {
@@ -8866,6 +8872,26 @@ const wrapFocusCommand$1 = (fn, returnState = true) => {
8866
8872
  };
8867
8873
  };
8868
8874
 
8875
+ // Mouse positions are replaceable; edits and explicit navigation remain ordered.
8876
+ // Check before starting provider work and again before committing its result.
8877
+ const wrapLatestCommand$1 = (fn, returnState = true) => {
8878
+ const latest = new Map();
8879
+ return async (uid, ...args) => {
8880
+ const token = {};
8881
+ latest.set(uid, token);
8882
+ const command = wrapCommand$1(async editor => {
8883
+ if (latest.get(uid) !== token) return editor;
8884
+ const result = await fn(editor, ...args);
8885
+ return latest.get(uid) === token ? result : editor;
8886
+ }, false, returnState);
8887
+ try {
8888
+ return await command(uid);
8889
+ } finally {
8890
+ if (latest.get(uid) === token) latest.delete(uid);
8891
+ }
8892
+ };
8893
+ };
8894
+
8869
8895
  // Optional provider work must not hold the editing queue while another worker responds.
8870
8896
  const wrapDeferredCommand$1 = (fn, returnState = true) => {
8871
8897
  const apply = wrapCommand$1((editor, snapshot, result) => merge(editor, snapshot, result), false, returnState);
@@ -19486,6 +19512,9 @@ const wrapFocusCommand = fn => {
19486
19512
  const wrapDeferredCommand = fn => {
19487
19513
  return wrapDeferredCommand$1(fn, false);
19488
19514
  };
19515
+ const wrapLatestCommand = fn => {
19516
+ return wrapLatestCommand$1(fn, false);
19517
+ };
19489
19518
 
19490
19519
  const executeViewletCommand = (uid, commandId, ...args) => {
19491
19520
  return executeViewletCommand$1(commandMap, uid, commandId, ...args);
@@ -19644,8 +19673,8 @@ const commandMap = {
19644
19673
  'Editor.handleMouseDown': wrapCommand(handleMouseDown),
19645
19674
  'Editor.handleMouseEnter': handleMouseEnter,
19646
19675
  'Editor.handleMouseLeave': handleMouseLeave,
19647
- 'Editor.handleMouseMove': wrapCommand(handleMouseMove),
19648
- 'Editor.handleMouseMoveWithAltKey': wrapCommand(handleMouseMoveWithAltKey),
19676
+ 'Editor.handleMouseMove': wrapLatestCommand(handleMouseMove),
19677
+ 'Editor.handleMouseMoveWithAltKey': wrapLatestCommand(handleMouseMoveWithAltKey),
19649
19678
  'Editor.handleNativeSelectionChange': editorHandleNativeSelectionChange,
19650
19679
  'Editor.handlePointerCaptureLost': wrapCommand(handlePointerCaptureLost),
19651
19680
  'Editor.handlePointerDown': wrapCommand(handlePointerDown$1),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.74.4",
3
+ "version": "19.74.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"