@lvce-editor/editor-worker 19.29.9 → 19.29.10

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.
@@ -7625,7 +7625,7 @@ const executeHoverProvider = async (editor, offset) => {
7625
7625
  return executeIsolatedHoverProvider(editor, offset);
7626
7626
  };
7627
7627
 
7628
- const getHover = async (editor, offset) => {
7628
+ const getHover$1 = async (editor, offset) => {
7629
7629
  object(editor);
7630
7630
  number(offset);
7631
7631
  // TODO invoke extension host worker directly
@@ -7700,15 +7700,40 @@ const getHoverPosition = (position, selections) => {
7700
7700
  rowIndex
7701
7701
  };
7702
7702
  };
7703
+ const containsPosition = (diagnostic, rowIndex, columnIndex) => {
7704
+ const {
7705
+ columnIndex: startColumnIndex,
7706
+ endColumnIndex,
7707
+ endRowIndex,
7708
+ rowIndex: startRowIndex
7709
+ } = diagnostic;
7710
+ if (rowIndex < startRowIndex || rowIndex > endRowIndex) {
7711
+ return false;
7712
+ }
7713
+ if (rowIndex === startRowIndex && columnIndex < startColumnIndex) {
7714
+ return false;
7715
+ }
7716
+ if (rowIndex === endRowIndex && columnIndex >= endColumnIndex) {
7717
+ return false;
7718
+ }
7719
+ return true;
7720
+ };
7703
7721
  const getMatchingDiagnostics = (diagnostics, rowIndex, columnIndex) => {
7704
7722
  const matching = [];
7705
7723
  for (const diagnostic of diagnostics) {
7706
- if (diagnostic.rowIndex === rowIndex) {
7724
+ if (containsPosition(diagnostic, rowIndex, columnIndex)) {
7707
7725
  matching.push(diagnostic);
7708
7726
  }
7709
7727
  }
7710
7728
  return matching;
7711
7729
  };
7730
+ const getHover = async (editor, offset) => {
7731
+ try {
7732
+ return await getHover$1(editor, offset);
7733
+ } catch {
7734
+ return undefined;
7735
+ }
7736
+ };
7712
7737
  const fallbackDisplayStringLanguageId = 'typescript'; // TODO remove this
7713
7738
  const getHoverPositionXy = (editor, rowIndex, wordStart, documentationHeight) => {
7714
7739
  const x$1 = x(editor, rowIndex, wordStart);
@@ -7730,17 +7755,19 @@ const getEditorHoverInfo = async (editorUid, position) => {
7730
7755
  rowIndex
7731
7756
  } = getHoverPosition(position, selections);
7732
7757
  const offset = offsetAt(editor, rowIndex, columnIndex);
7758
+ const diagnostics = editor.diagnostics || [];
7759
+ const matchingDiagnostics = getMatchingDiagnostics(diagnostics, rowIndex, columnIndex);
7733
7760
  const hover = await getHover(editor, offset);
7734
- if (!hover) {
7761
+ if (!hover && matchingDiagnostics.length === 0) {
7735
7762
  return undefined;
7736
7763
  }
7737
7764
  const {
7738
- displayString,
7739
- displayStringLanguageId,
7740
- documentation
7741
- } = hover;
7765
+ displayString = '',
7766
+ displayStringLanguageId = '',
7767
+ documentation = ''
7768
+ } = hover || {};
7742
7769
  const tokenizerPath = '';
7743
- const lineInfos = await tokenizeCodeBlock(displayString, displayStringLanguageId || fallbackDisplayStringLanguageId, tokenizerPath);
7770
+ const lineInfos = displayString ? await tokenizeCodeBlock(displayString, displayStringLanguageId || fallbackDisplayStringLanguageId, tokenizerPath) : [];
7744
7771
  const wordPart = getWordBefore(editor, rowIndex, columnIndex);
7745
7772
  const wordStart = columnIndex - wordPart.length;
7746
7773
  await measureTextBlockHeight();
@@ -7748,8 +7775,6 @@ const getEditorHoverInfo = async (editorUid, position) => {
7748
7775
  x,
7749
7776
  y
7750
7777
  } = getHoverPositionXy(editor, rowIndex, wordStart);
7751
- const diagnostics = editor.diagnostics || [];
7752
- const matchingDiagnostics = getMatchingDiagnostics(diagnostics, rowIndex);
7753
7778
  return {
7754
7779
  documentation,
7755
7780
  lineInfos,
@@ -7782,7 +7807,61 @@ const loadHoverContent = async (state, position) => {
7782
7807
  };
7783
7808
  };
7784
7809
 
7810
+ const updateWidget = (editor, widgetId, newState) => {
7811
+ // TODO avoid closure
7812
+ const isWidget = widget => {
7813
+ return widget.id === widgetId;
7814
+ };
7815
+ const childIndex = editor.widgets.findIndex(isWidget);
7816
+ if (childIndex === -1) {
7817
+ return editor;
7818
+ }
7819
+ // TODO scroll up/down if necessary
7820
+ const childWidget = editor.widgets[childIndex];
7821
+ const newWidget = {
7822
+ ...childWidget,
7823
+ newState,
7824
+ oldState: childWidget.newState
7825
+ };
7826
+ const newWidgets = [...editor.widgets.slice(0, childIndex), newWidget, ...editor.widgets.slice(childIndex + 1)];
7827
+ return {
7828
+ ...editor,
7829
+ widgets: newWidgets
7830
+ };
7831
+ };
7832
+
7833
+ const getHoverWidgetIndex = widgets => {
7834
+ return widgets.findIndex(widget => widget.id === Hover);
7835
+ };
7836
+ const updateHover = async (editor, widgetIndex, position) => {
7837
+ const widgetRevision = next(editor.uid);
7838
+ const widget = editor.widgets[widgetIndex];
7839
+ const newState = await loadHoverContent(widget.newState, position);
7840
+ if (get$2(editor.uid) !== widgetRevision) {
7841
+ return editor;
7842
+ }
7843
+ if (!newState) {
7844
+ return {
7845
+ ...editor,
7846
+ additionalFocus: Empty,
7847
+ focused: true,
7848
+ widgetRevision,
7849
+ widgets: removeEditorWidget(editor.widgets, Hover)
7850
+ };
7851
+ }
7852
+ return {
7853
+ ...updateWidget(editor, Hover, newState),
7854
+ widgetRevision
7855
+ };
7856
+ };
7785
7857
  const showHover$1 = async (editor, position) => {
7858
+ const {
7859
+ widgets = []
7860
+ } = editor;
7861
+ const widgetIndex = getHoverWidgetIndex(widgets);
7862
+ if (widgetIndex !== -1) {
7863
+ return updateHover(editor, widgetIndex, position);
7864
+ }
7786
7865
  const newStateGenerator = async state => {
7787
7866
  return loadHoverContent(state, position);
7788
7867
  };
@@ -7829,7 +7908,7 @@ const onHoverIdle = async token => {
7829
7908
  // Hover providers are optional and should not surface errors from an idle mouse event.
7830
7909
  }
7831
7910
  };
7832
- const hoverDelay = 300;
7911
+ const hoverDelay = 200;
7833
7912
  const handleMouseMove = async (editor, x, y, altKey) => {
7834
7913
  if (altKey) {
7835
7914
  return handleMouseMoveWithAltKey(editor, x, y);
@@ -8866,29 +8945,6 @@ const getWidgetInvoke = widgetId => {
8866
8945
  const SearchValue = 'search-value';
8867
8946
  const Close = 'Close';
8868
8947
 
8869
- const updateWidget = (editor, widgetId, newState) => {
8870
- // TODO avoid closure
8871
- const isWidget = widget => {
8872
- return widget.id === widgetId;
8873
- };
8874
- const childIndex = editor.widgets.findIndex(isWidget);
8875
- if (childIndex === -1) {
8876
- return editor;
8877
- }
8878
- // TODO scroll up/down if necessary
8879
- const childWidget = editor.widgets[childIndex];
8880
- const newWidget = {
8881
- ...childWidget,
8882
- newState,
8883
- oldState: childWidget.newState
8884
- };
8885
- const newWidgets = [...editor.widgets.slice(0, childIndex), newWidget, ...editor.widgets.slice(childIndex + 1)];
8886
- return {
8887
- ...editor,
8888
- widgets: newWidgets
8889
- };
8890
- };
8891
-
8892
8948
  const getEditorByWidgetUid = (widgetUid, widgetId) => {
8893
8949
  for (const key of getKeys$2()) {
8894
8950
  const editor = get$8(Number(key)).newState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.29.9",
3
+ "version": "19.29.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"