@lvce-editor/editor-worker 19.29.10 → 19.29.12

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.
@@ -5642,18 +5642,6 @@ const getCursorOffset = editor => {
5642
5642
  return offsetAt(editor, editor.selections[0], editor.selections[1]);
5643
5643
  };
5644
5644
 
5645
- const cancelSelection = editor => {
5646
- const {
5647
- selections
5648
- } = editor;
5649
- if (selections.length === 4 && selections[0] === selections[2] && selections[1] === selections[3]) {
5650
- return editor;
5651
- }
5652
- const newSelections = alloc(4);
5653
- moveRangeToPosition$1(newSelections, 0, selections[0], selections[1]);
5654
- return scheduleSelections(editor, newSelections);
5655
- };
5656
-
5657
5645
  const getIndex = (widgets, id) => {
5658
5646
  for (const [i, widget] of widgets.entries()) {
5659
5647
  if (widget.id === id) {
@@ -5668,6 +5656,28 @@ const removeEditorWidget = (widgets, id) => {
5668
5656
  return newWidgets;
5669
5657
  };
5670
5658
 
5659
+ const cancelSelection = editor => {
5660
+ const {
5661
+ selections,
5662
+ widgets = []
5663
+ } = editor;
5664
+ if (widgets.some(widget => widget.id === Hover)) {
5665
+ return {
5666
+ ...editor,
5667
+ additionalFocus: 0,
5668
+ focused: true,
5669
+ widgetRevision: next(editor.uid),
5670
+ widgets: removeEditorWidget(widgets, Hover)
5671
+ };
5672
+ }
5673
+ if (selections.length === 4 && selections[0] === selections[2] && selections[1] === selections[3]) {
5674
+ return editor;
5675
+ }
5676
+ const newSelections = alloc(4);
5677
+ moveRangeToPosition$1(newSelections, 0, selections[0], selections[1]);
5678
+ return scheduleSelections(editor, newSelections);
5679
+ };
5680
+
5671
5681
  const isMatchingWidget$2 = widget => {
5672
5682
  return widget.id === CodeGenerator;
5673
5683
  };
@@ -7625,7 +7635,7 @@ const executeHoverProvider = async (editor, offset) => {
7625
7635
  return executeIsolatedHoverProvider(editor, offset);
7626
7636
  };
7627
7637
 
7628
- const getHover$1 = async (editor, offset) => {
7638
+ const getHover = async (editor, offset) => {
7629
7639
  object(editor);
7630
7640
  number(offset);
7631
7641
  // TODO invoke extension host worker directly
@@ -7689,17 +7699,6 @@ const tokenizeCodeBlock = async (codeBlock, languageId, tokenizerPath) => {
7689
7699
  return lineInfos;
7690
7700
  };
7691
7701
 
7692
- const getHoverPosition = (position, selections) => {
7693
- if (position) {
7694
- return position;
7695
- }
7696
- const rowIndex = selections[0];
7697
- const columnIndex = selections[1];
7698
- return {
7699
- columnIndex,
7700
- rowIndex
7701
- };
7702
- };
7703
7702
  const containsPosition = (diagnostic, rowIndex, columnIndex) => {
7704
7703
  const {
7705
7704
  columnIndex: startColumnIndex,
@@ -7727,22 +7726,8 @@ const getMatchingDiagnostics = (diagnostics, rowIndex, columnIndex) => {
7727
7726
  }
7728
7727
  return matching;
7729
7728
  };
7730
- const getHover = async (editor, offset) => {
7731
- try {
7732
- return await getHover$1(editor, offset);
7733
- } catch {
7734
- return undefined;
7735
- }
7736
- };
7737
7729
  const fallbackDisplayStringLanguageId = 'typescript'; // TODO remove this
7738
- const getHoverPositionXy = (editor, rowIndex, wordStart, documentationHeight) => {
7739
- const x$1 = x(editor, rowIndex, wordStart);
7740
- const y$1 = editor.height - y(editor, rowIndex) + editor.y + 40;
7741
- return {
7742
- x: x$1,
7743
- y: y$1
7744
- };
7745
- };
7730
+ const hoverWidth = 600;
7746
7731
  const getEditorHoverInfo = async (editorUid, position) => {
7747
7732
  number(editorUid);
7748
7733
  const instance = get$8(editorUid);
@@ -7753,11 +7738,17 @@ const getEditorHoverInfo = async (editorUid, position) => {
7753
7738
  const {
7754
7739
  columnIndex,
7755
7740
  rowIndex
7756
- } = getHoverPosition(position, selections);
7741
+ } = position || {
7742
+ columnIndex: selections[1],
7743
+ rowIndex: selections[0]
7744
+ };
7757
7745
  const offset = offsetAt(editor, rowIndex, columnIndex);
7758
7746
  const diagnostics = editor.diagnostics || [];
7759
7747
  const matchingDiagnostics = getMatchingDiagnostics(diagnostics, rowIndex, columnIndex);
7760
- const hover = await getHover(editor, offset);
7748
+ let hover;
7749
+ try {
7750
+ hover = await getHover(editor, offset);
7751
+ } catch {}
7761
7752
  if (!hover && matchingDiagnostics.length === 0) {
7762
7753
  return undefined;
7763
7754
  }
@@ -7770,17 +7761,18 @@ const getEditorHoverInfo = async (editorUid, position) => {
7770
7761
  const lineInfos = displayString ? await tokenizeCodeBlock(displayString, displayStringLanguageId || fallbackDisplayStringLanguageId, tokenizerPath) : [];
7771
7762
  const wordPart = getWordBefore(editor, rowIndex, columnIndex);
7772
7763
  const wordStart = columnIndex - wordPart.length;
7773
- await measureTextBlockHeight();
7774
- const {
7775
- x,
7776
- y
7777
- } = getHoverPositionXy(editor, rowIndex, wordStart);
7764
+ const documentationHeight = await measureTextBlockHeight();
7765
+ const height = Math.min((matchingDiagnostics.length > 0 ? 30 : 0) + (lineInfos.length > 0 ? lineInfos.length * editor.rowHeight + 12 : 0) + (documentation ? documentationHeight + 11 : 0) || 20, editor.height);
7766
+ const x$1 = Math.max(editor.x, Math.min(x(editor, rowIndex, wordStart), editor.x + editor.width - hoverWidth));
7767
+ const rowBottom = y(editor, rowIndex);
7768
+ const y$1 = rowBottom + height <= editor.y + editor.height ? rowBottom : Math.max(editor.y, rowBottom - editor.rowHeight - height);
7778
7769
  return {
7779
7770
  documentation,
7771
+ height,
7780
7772
  lineInfos,
7781
7773
  matchingDiagnostics,
7782
- x,
7783
- y
7774
+ x: x$1,
7775
+ y: y$1
7784
7776
  };
7785
7777
  };
7786
7778
 
@@ -7791,6 +7783,7 @@ const loadHoverContent = async (state, position) => {
7791
7783
  }
7792
7784
  const {
7793
7785
  documentation,
7786
+ height,
7794
7787
  lineInfos,
7795
7788
  matchingDiagnostics,
7796
7789
  x,
@@ -7800,6 +7793,7 @@ const loadHoverContent = async (state, position) => {
7800
7793
  ...state,
7801
7794
  diagnostics: matchingDiagnostics,
7802
7795
  documentation,
7796
+ height,
7803
7797
  lineInfos,
7804
7798
  width: 600,
7805
7799
  x,
@@ -11000,6 +10994,7 @@ const loadContent$1 = async (editorUid, state, position) => {
11000
10994
  }
11001
10995
  const {
11002
10996
  documentation,
10997
+ height,
11003
10998
  lineInfos,
11004
10999
  matchingDiagnostics,
11005
11000
  x,
@@ -11009,6 +11004,7 @@ const loadContent$1 = async (editorUid, state, position) => {
11009
11004
  ...state,
11010
11005
  diagnostics: matchingDiagnostics,
11011
11006
  documentation,
11007
+ height,
11012
11008
  lineInfos,
11013
11009
  x,
11014
11010
  y
@@ -11513,6 +11509,10 @@ const getKeyBindings = () => {
11513
11509
  command: 'Editor.closeColorPicker',
11514
11510
  key: Escape,
11515
11511
  when: FocusColorPicker
11512
+ }, {
11513
+ command: 'Editor.cancelSelection',
11514
+ key: Escape,
11515
+ when: FocusEditorHover
11516
11516
  }, {
11517
11517
  command: 'Editor.closeSourceAction',
11518
11518
  key: Escape,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.29.10",
3
+ "version": "19.29.12",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"