@lvce-editor/editor-worker 19.27.3 → 19.28.1

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.
@@ -7535,7 +7535,7 @@ const execute = async ({
7535
7535
  return result;
7536
7536
  };
7537
7537
 
7538
- const getTextDocument$1 = editor => {
7538
+ const getTextDocument$2 = editor => {
7539
7539
  return {
7540
7540
  documentId: editor.id || editor.uid,
7541
7541
  languageId: editor.languageId,
@@ -7544,7 +7544,7 @@ const getTextDocument$1 = editor => {
7544
7544
  };
7545
7545
  };
7546
7546
  const executeIsolatedHoverProvider = async (editor, offset) => {
7547
- const textDocument = getTextDocument$1(editor);
7547
+ const textDocument = getTextDocument$2(editor);
7548
7548
  return invoke$e('Extensions.executeHoverProvider', textDocument, offset);
7549
7549
  };
7550
7550
  const executeHoverProvider = async (editor, offset) => {
@@ -9730,6 +9730,159 @@ const showHover = async state => {
9730
9730
  return state;
9731
9731
  };
9732
9732
 
9733
+ const clampIndex = (index, length) => {
9734
+ return Math.max(0, Math.min(index, length - 1));
9735
+ };
9736
+ const getDocumentation = (signature, parameter, activeParameter) => {
9737
+ const documentation = [];
9738
+ if (parameter) {
9739
+ documentation.push(`Parameter ${activeParameter + 1} of ${signature.parameters.length}: ${parameter.label}`);
9740
+ if (parameter.documentation) {
9741
+ documentation.push(parameter.documentation);
9742
+ }
9743
+ }
9744
+ if (signature.documentation) {
9745
+ documentation.push(signature.documentation);
9746
+ }
9747
+ return documentation.join('\n');
9748
+ };
9749
+ const getSignatureHelpContent = signatureHelp => {
9750
+ if (signatureHelp.signatures.length === 0) {
9751
+ return undefined;
9752
+ }
9753
+ const activeSignature = clampIndex(signatureHelp.activeSignature, signatureHelp.signatures.length);
9754
+ const signature = signatureHelp.signatures[activeSignature];
9755
+ const activeParameter = clampIndex(signatureHelp.activeParameter, signature.parameters.length);
9756
+ const parameter = signature.parameters[activeParameter];
9757
+ return {
9758
+ displayString: signature.label,
9759
+ documentation: getDocumentation(signature, parameter, activeParameter)
9760
+ };
9761
+ };
9762
+
9763
+ const borderHeight = 2;
9764
+ const documentationPaddingHeight = 8;
9765
+ const displayStringLineHeight = 20;
9766
+ const displayStringPaddingHeight = 8;
9767
+ const preferredWidth = 600;
9768
+ const getHeight = (lineCount, documentationHeight, hasDocumentation) => {
9769
+ const displayStringHeight = lineCount * displayStringLineHeight + displayStringPaddingHeight;
9770
+ const fullDocumentationHeight = hasDocumentation ? documentationHeight + documentationPaddingHeight : 0;
9771
+ return borderHeight + displayStringHeight + fullDocumentationHeight;
9772
+ };
9773
+ const getSignatureHelpWidgetBounds = (editor, rowIndex, columnIndex, lineCount, documentationHeight, hasDocumentation) => {
9774
+ const width = Math.min(preferredWidth, editor.width);
9775
+ const height = Math.min(getHeight(lineCount, documentationHeight, hasDocumentation), editor.height);
9776
+ const cursorX = x(editor, rowIndex, columnIndex);
9777
+ const cursorY = y(editor, rowIndex);
9778
+ const editorRight = editor.x + editor.width;
9779
+ const editorBottom = editor.y + editor.height;
9780
+ const x$1 = clamp(cursorX, editor.x, editorRight - width);
9781
+ const yBelow = cursorY;
9782
+ const yAbove = cursorY - editor.rowHeight - height;
9783
+ const preferredY = yBelow + height <= editorBottom ? yBelow : yAbove;
9784
+ const y$1 = clamp(preferredY, editor.y, editorBottom - height);
9785
+ return {
9786
+ height,
9787
+ width,
9788
+ x: x$1,
9789
+ y: y$1
9790
+ };
9791
+ };
9792
+
9793
+ const getTextDocument$1 = editor => {
9794
+ return {
9795
+ documentId: editor.id || editor.uid,
9796
+ languageId: editor.languageId,
9797
+ text: getText$1(editor),
9798
+ uri: editor.uri
9799
+ };
9800
+ };
9801
+ const executeSignatureHelpProvider = async (editor, offset) => {
9802
+ object(editor);
9803
+ number(offset);
9804
+ const textDocument = getTextDocument$1(editor);
9805
+ return invoke$e('Extensions.executeSignatureHelpProvider', textDocument, offset);
9806
+ };
9807
+
9808
+ const getSignatureHelp = async (editor, offset) => {
9809
+ return executeSignatureHelpProvider(editor, offset);
9810
+ };
9811
+
9812
+ const getSignatureHelpInfo = async editorUid => {
9813
+ number(editorUid);
9814
+ const instance = get$7(editorUid);
9815
+ const editor = instance.newState;
9816
+ const {
9817
+ selections
9818
+ } = editor;
9819
+ const rowIndex = selections[0];
9820
+ const columnIndex = selections[1];
9821
+ const offset = offsetAt(editor, rowIndex, columnIndex);
9822
+ const signatureHelp = await getSignatureHelp(editor, offset);
9823
+ if (!signatureHelp) {
9824
+ return undefined;
9825
+ }
9826
+ const content = getSignatureHelpContent(signatureHelp);
9827
+ if (!content) {
9828
+ return undefined;
9829
+ }
9830
+ const {
9831
+ displayString,
9832
+ documentation
9833
+ } = content;
9834
+ const lineInfos = await tokenizeCodeBlock(displayString, editor.languageId || 'typescript', '');
9835
+ const documentationHeight = await measureTextBlockHeight();
9836
+ const bounds = getSignatureHelpWidgetBounds(editor, rowIndex, columnIndex, lineInfos.length, documentationHeight, Boolean(documentation));
9837
+ return {
9838
+ ...bounds,
9839
+ documentation,
9840
+ lineInfos
9841
+ };
9842
+ };
9843
+
9844
+ const loadSignatureHelpContent = async state => {
9845
+ const {
9846
+ editorUid
9847
+ } = state;
9848
+ const signatureHelpInfo = await getSignatureHelpInfo(editorUid);
9849
+ if (!signatureHelpInfo) {
9850
+ return undefined;
9851
+ }
9852
+ const {
9853
+ documentation,
9854
+ height,
9855
+ lineInfos,
9856
+ width,
9857
+ x,
9858
+ y
9859
+ } = signatureHelpInfo;
9860
+ return {
9861
+ ...state,
9862
+ diagnostics: [],
9863
+ documentation,
9864
+ height,
9865
+ lineInfos,
9866
+ width,
9867
+ x,
9868
+ y
9869
+ };
9870
+ };
9871
+
9872
+ const showSignatureHelp = async editor => {
9873
+ const {
9874
+ widgets = []
9875
+ } = editor;
9876
+ const editorWithoutHover = hasWidget(widgets, Hover) ? {
9877
+ ...editor,
9878
+ widgets: removeEditorWidget(widgets, Hover)
9879
+ } : editor;
9880
+ const newStateGenerator = async state => {
9881
+ return loadSignatureHelpContent(state);
9882
+ };
9883
+ return addWidgetToEditor(Hover, FocusEditorHover, editorWithoutHover, create$5, newStateGenerator);
9884
+ };
9885
+
9733
9886
  const create = () => {
9734
9887
  const completionUid = create$8();
9735
9888
  const widget = {
@@ -11586,8 +11739,12 @@ const getKeyBindings = () => {
11586
11739
  when: FocusEditorText
11587
11740
  }, {
11588
11741
  command: 'Editor.selectionGrow',
11589
- key: CtrlCmd | Shift | Space$1,
11742
+ key: Alt$1 | Shift | RightArrow,
11590
11743
  when: FocusEditor
11744
+ }, {
11745
+ command: 'Editor.showSignatureHelp',
11746
+ key: CtrlCmd | Shift | Space$1,
11747
+ when: FocusEditorText
11591
11748
  }];
11592
11749
  };
11593
11750
 
@@ -13735,6 +13892,7 @@ const commandMap = {
13735
13892
  'Editor.setText': wrapCommand(setText),
13736
13893
  'Editor.showHover': showHover,
13737
13894
  'Editor.showHover2': wrapCommand(showHover2),
13895
+ 'Editor.showSignatureHelp': wrapCommand(showSignatureHelp),
13738
13896
  'Editor.showSourceActions': wrapCommand(showSourceActions),
13739
13897
  'Editor.showSourceActions2': wrapCommand(showSourceActions),
13740
13898
  'Editor.showSourceActions3': wrapCommand(showSourceActions),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.27.3",
3
+ "version": "19.28.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"