@lvce-editor/completion-worker 1.24.0 → 1.25.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.
@@ -626,7 +626,8 @@ const splitLines = lines => {
626
626
  return lines.split(NewLine);
627
627
  };
628
628
  const getCurrentStack = () => {
629
- const currentStack = joinLines(splitLines(new Error().stack || '').slice(2));
629
+ const stackLinesToSkip = 3;
630
+ const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
630
631
  return currentStack;
631
632
  };
632
633
  const getNewLineIndex = (string, startIndex = undefined) => {
@@ -897,6 +898,12 @@ const invokeAndTransfer$1 = (ipc, method, ...params) => {
897
898
  return invokeHelper(ipc, method, params, true);
898
899
  };
899
900
 
901
+ class CommandNotFoundError extends Error {
902
+ constructor(command) {
903
+ super(`Command not found ${command}`);
904
+ this.name = 'CommandNotFoundError';
905
+ }
906
+ }
900
907
  const commands = Object.create(null);
901
908
  const register = commandMap => {
902
909
  Object.assign(commands, commandMap);
@@ -907,7 +914,7 @@ const getCommand$1 = key => {
907
914
  const execute$1 = (command, ...args) => {
908
915
  const fn = getCommand$1(command);
909
916
  if (!fn) {
910
- throw new Error(`command not found ${command}`);
917
+ throw new CommandNotFoundError(command);
911
918
  }
912
919
  return fn(...args);
913
920
  };
@@ -1487,9 +1494,10 @@ const executeResolveCompletionItem = async (editorUid, offset, name, completionI
1487
1494
  noProviderFoundResult: []});
1488
1495
  };
1489
1496
 
1490
- const getOffsetAtCursor = editorUid => {
1497
+ const getOffsetAtCursor = async editorUid => {
1491
1498
  // TODO ask editor worker
1492
- return 0;
1499
+ // @ts-ignore
1500
+ return invoke$1('Editor.getOffsetAtCursor', editorUid);
1493
1501
  };
1494
1502
 
1495
1503
  // TODO don't send unnecessary parts of completion item like matches
@@ -1497,7 +1505,7 @@ const resolveCompletion = async (editorUid, name, completionItem) => {
1497
1505
  try {
1498
1506
  string(name);
1499
1507
  object(completionItem);
1500
- const offset = getOffsetAtCursor(editorUid);
1508
+ const offset = await getOffsetAtCursor(editorUid);
1501
1509
  const resolvedCompletionItem = await executeResolveCompletionItem(editorUid, offset, name, completionItem);
1502
1510
  return resolvedCompletionItem;
1503
1511
  } catch {
@@ -2018,7 +2026,7 @@ const error = message => {
2018
2026
  // TODO possible to do this with events/state machine instead of promises -> enables canceling operations / concurrent calls
2019
2027
  const getCompletions = async (editorUid, editorLanguageId) => {
2020
2028
  try {
2021
- const offset = getOffsetAtCursor(editorUid);
2029
+ const offset = await getOffsetAtCursor(editorUid);
2022
2030
  const completions = await executeCompletionProvider(editorUid, editorLanguageId, offset);
2023
2031
  return completions;
2024
2032
  } catch (error$1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/completion-worker",
3
- "version": "1.24.0",
3
+ "version": "1.25.0",
4
4
  "description": "Web Worker for the find widget in Lvce Editor",
5
5
  "repository": {
6
6
  "type": "git",