@adecore/editor-react 0.62.1 → 0.63.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.
Files changed (264) hide show
  1. package/README.md +2 -2
  2. package/dist/AnchoredPopup.d.ts +2 -1
  3. package/dist/CompletionPopup.js +0 -2
  4. package/dist/DiffView.d.ts +1 -28
  5. package/dist/EditorView.js +0 -1
  6. package/dist/HoverSections.d.ts +1 -8
  7. package/dist/HoverSections.js +2 -2
  8. package/dist/LanguagePopups.js +30 -14
  9. package/dist/PanelResizeHandle.js +0 -1
  10. package/dist/PeekPanel.js +0 -1
  11. package/dist/PickPopup.js +0 -1
  12. package/dist/RenderedDocs.js +0 -2
  13. package/dist/SplitDiffView.d.ts +1 -1
  14. package/dist/SymbolPicker.js +0 -1
  15. package/dist/call-hierarchy-model.js +0 -4
  16. package/dist/call-hierarchy.d.ts +9 -2
  17. package/dist/call-hierarchy.js +51 -67
  18. package/dist/clipboard-history.d.ts +3 -0
  19. package/dist/clipboard-history.js +0 -1
  20. package/dist/code-actions-model.js +1 -1
  21. package/dist/code-actions.d.ts +14 -2
  22. package/dist/code-actions.js +14 -9
  23. package/dist/code-authors.js +4 -12
  24. package/dist/code-vision-model.d.ts +0 -1
  25. package/dist/code-vision-model.js +1 -2
  26. package/dist/code-vision.d.ts +11 -3
  27. package/dist/code-vision.js +13 -18
  28. package/dist/completion-call.d.ts +1 -1
  29. package/dist/completion-call.js +2 -1
  30. package/dist/completion-model.d.ts +5 -4
  31. package/dist/completion-model.js +4 -4
  32. package/dist/completion.d.ts +13 -4
  33. package/dist/completion.js +19 -18
  34. package/dist/context-menu-rows.d.ts +2 -1
  35. package/dist/context-menu.d.ts +9 -3
  36. package/dist/context-menu.js +17 -19
  37. package/dist/definition-link.d.ts +8 -2
  38. package/dist/definition-link.js +4 -2
  39. package/dist/diagnostics-model.d.ts +6 -8
  40. package/dist/diagnostics-model.js +1 -54
  41. package/dist/diagnostics.d.ts +9 -7
  42. package/dist/diagnostics.js +6 -4
  43. package/dist/diff-view-props.d.ts +28 -0
  44. package/dist/diff-view-props.js +1 -0
  45. package/dist/doc-comment-model.js +0 -2
  46. package/dist/document-colors.d.ts +9 -4
  47. package/dist/document-colors.js +7 -4
  48. package/dist/document-links.d.ts +2 -3
  49. package/dist/document-links.js +2 -3
  50. package/dist/document-query.d.ts +2 -2
  51. package/dist/edit-locations.js +4 -22
  52. package/dist/editor-language.d.ts +12 -7
  53. package/dist/editor-language.js +54 -45
  54. package/dist/emmet.d.ts +3 -2
  55. package/dist/folding.d.ts +2 -4
  56. package/dist/folding.js +1 -2
  57. package/dist/format-on-type.d.ts +8 -2
  58. package/dist/format-on-type.js +8 -6
  59. package/dist/highlights.d.ts +2 -6
  60. package/dist/highlights.js +3 -3
  61. package/dist/history.d.ts +8 -2
  62. package/dist/history.js +4 -2
  63. package/dist/host-types.d.ts +39 -22
  64. package/dist/hover-content.js +0 -1
  65. package/dist/hover.d.ts +13 -2
  66. package/dist/hover.js +25 -28
  67. package/dist/index.d.ts +19 -9
  68. package/dist/index.js +5 -2
  69. package/dist/inlay-hints.d.ts +12 -21
  70. package/dist/inlay-hints.js +16 -15
  71. package/dist/inline-completion.d.ts +30 -10
  72. package/dist/inline-completion.js +346 -102
  73. package/dist/key-priority.d.ts +1 -1
  74. package/dist/key-priority.js +2 -2
  75. package/dist/language-context.d.ts +30 -0
  76. package/dist/language-context.js +1 -0
  77. package/dist/language-ids.d.ts +0 -1
  78. package/dist/language-ids.js +0 -32
  79. package/dist/line-text.js +0 -1
  80. package/dist/linked-editing.d.ts +2 -4
  81. package/dist/linked-editing.js +1 -3
  82. package/dist/live-templates.d.ts +14 -2
  83. package/dist/live-templates.js +15 -10
  84. package/dist/locales/en.d.ts +357 -0
  85. package/dist/locales/en.js +356 -0
  86. package/dist/locales/nl.d.ts +357 -0
  87. package/dist/locales/nl.js +356 -0
  88. package/dist/markup-context.d.ts +7 -6
  89. package/dist/markup-context.js +0 -1
  90. package/dist/markup.d.ts +8 -2
  91. package/dist/markup.js +19 -20
  92. package/dist/models.d.ts +2 -1
  93. package/dist/models.js +2 -1
  94. package/dist/navigation-history.d.ts +7 -0
  95. package/dist/navigation.d.ts +11 -8
  96. package/dist/navigation.js +9 -20
  97. package/dist/panel-size.d.ts +4 -0
  98. package/dist/paste-history.d.ts +8 -2
  99. package/dist/paste-history.js +4 -2
  100. package/dist/patch-layout.d.ts +0 -4
  101. package/dist/patch-layout.js +1 -1
  102. package/dist/peek-model.js +0 -1
  103. package/dist/peek.d.ts +8 -2
  104. package/dist/peek.js +31 -42
  105. package/dist/pick.d.ts +4 -2
  106. package/dist/pick.js +38 -15
  107. package/dist/popups.d.ts +25 -20
  108. package/dist/popups.js +31 -15
  109. package/dist/positions.d.ts +7 -0
  110. package/dist/positions.js +54 -0
  111. package/dist/postfix.d.ts +11 -2
  112. package/dist/postfix.js +10 -6
  113. package/dist/project-language.d.ts +11 -3
  114. package/dist/project-language.js +40 -9
  115. package/dist/project-problems.d.ts +7 -1
  116. package/dist/project-problems.js +2 -1
  117. package/dist/rename-model.js +1 -1
  118. package/dist/rename.d.ts +2 -2
  119. package/dist/rename.js +17 -22
  120. package/dist/rendered-docs.d.ts +8 -2
  121. package/dist/rendered-docs.js +5 -4
  122. package/dist/selection-ranges.d.ts +2 -2
  123. package/dist/semantic-tokens.d.ts +2 -4
  124. package/dist/semantic-tokens.js +2 -2
  125. package/dist/shortcut-keys.d.ts +2 -1
  126. package/dist/signature.d.ts +2 -2
  127. package/dist/signature.js +9 -15
  128. package/dist/snippet-field-transforms.js +1 -1
  129. package/dist/snippet-insert.d.ts +4 -2
  130. package/dist/snippet-insert.js +9 -15
  131. package/dist/snippet-session.d.ts +9 -4
  132. package/dist/snippet-session.js +14 -14
  133. package/dist/snippet-transform-format.d.ts +2 -1
  134. package/dist/snippet-transform-queue.d.ts +2 -4
  135. package/dist/snippet-transform-queue.js +5 -37
  136. package/dist/snippet.d.ts +2 -1
  137. package/dist/surround-constructs.d.ts +1 -1
  138. package/dist/surround.d.ts +13 -2
  139. package/dist/surround.js +15 -8
  140. package/dist/symbol-links.d.ts +0 -1
  141. package/dist/symbol-links.js +1 -1
  142. package/dist/symbol-picker-model.d.ts +0 -1
  143. package/dist/symbol-picker-model.js +1 -2
  144. package/dist/symbol-picker.d.ts +2 -2
  145. package/dist/symbol-picker.js +5 -10
  146. package/dist/symbols.d.ts +4 -3
  147. package/dist/template-builtins.d.ts +1 -1
  148. package/dist/template-builtins.js +0 -1
  149. package/dist/template-context.d.ts +3 -3
  150. package/dist/template-context.js +2 -11
  151. package/dist/template-types.d.ts +20 -0
  152. package/dist/template-types.js +1 -0
  153. package/dist/templates.d.ts +5 -20
  154. package/dist/templates.js +0 -1
  155. package/dist/testing.d.ts +6 -0
  156. package/dist/testing.js +42 -0
  157. package/dist/use-problem-counts.d.ts +1 -1
  158. package/dist/word-diff.d.ts +1 -1
  159. package/dist/word-diff.js +16 -25
  160. package/dist/workspace-edit.d.ts +1 -24
  161. package/dist/workspace-edit.js +0 -1
  162. package/package.json +10 -9
  163. package/src/AnchoredPopup.tsx +1 -1
  164. package/src/CompletionPopup.tsx +0 -2
  165. package/src/DiffView.tsx +6 -38
  166. package/src/EditorView.tsx +0 -1
  167. package/src/HoverSections.tsx +2 -2
  168. package/src/LanguagePopups.tsx +20 -14
  169. package/src/PanelResizeHandle.tsx +0 -1
  170. package/src/PeekPanel.tsx +0 -1
  171. package/src/PickPopup.tsx +0 -1
  172. package/src/RenderedDocs.tsx +0 -2
  173. package/src/SplitDiffView.tsx +1 -1
  174. package/src/SymbolPicker.tsx +0 -1
  175. package/src/call-hierarchy-model.ts +0 -7
  176. package/src/call-hierarchy.ts +32 -31
  177. package/src/clipboard-history.ts +5 -2
  178. package/src/code-actions-model.ts +1 -4
  179. package/src/code-actions.ts +26 -10
  180. package/src/code-authors.ts +4 -15
  181. package/src/code-vision-model.ts +1 -2
  182. package/src/code-vision.ts +23 -19
  183. package/src/completion-call.ts +2 -2
  184. package/src/completion-model.ts +12 -7
  185. package/src/completion.ts +31 -16
  186. package/src/context-menu-rows.ts +1 -1
  187. package/src/context-menu.ts +19 -10
  188. package/src/definition-link.ts +12 -4
  189. package/src/diagnostics-model.ts +8 -55
  190. package/src/diagnostics.ts +11 -20
  191. package/src/diff-view-props.ts +38 -0
  192. package/src/doc-comment-model.ts +0 -2
  193. package/src/document-colors.ts +14 -6
  194. package/src/document-links.ts +5 -6
  195. package/src/document-query.ts +3 -3
  196. package/src/edit-locations.ts +4 -19
  197. package/src/editor-language.ts +74 -39
  198. package/src/emmet.ts +2 -3
  199. package/src/folding.ts +4 -5
  200. package/src/format-on-type.ts +14 -7
  201. package/src/highlights.ts +6 -6
  202. package/src/history.ts +12 -4
  203. package/src/host-types.ts +52 -33
  204. package/src/hover-content.ts +0 -1
  205. package/src/hover.ts +29 -22
  206. package/src/index.ts +25 -14
  207. package/src/inlay-hints.ts +23 -17
  208. package/src/inline-completion.ts +340 -90
  209. package/src/key-priority.ts +2 -2
  210. package/src/language-context.ts +60 -0
  211. package/src/language-ids.ts +0 -34
  212. package/src/line-text.ts +0 -1
  213. package/src/linked-editing.ts +4 -6
  214. package/src/live-templates.ts +27 -13
  215. package/src/locales/en.ts +356 -0
  216. package/src/locales/nl.ts +356 -0
  217. package/src/markup-context.ts +6 -9
  218. package/src/markup.ts +19 -10
  219. package/src/models.ts +2 -1
  220. package/src/navigation-history.ts +11 -0
  221. package/src/navigation.ts +18 -20
  222. package/src/panel-size.ts +8 -0
  223. package/src/paste-history.ts +12 -4
  224. package/src/patch-layout.ts +1 -1
  225. package/src/peek-model.ts +0 -1
  226. package/src/peek.ts +22 -18
  227. package/src/pick.ts +30 -16
  228. package/src/popups.ts +61 -40
  229. package/src/positions.ts +54 -0
  230. package/src/postfix.ts +21 -8
  231. package/src/project-language.ts +63 -14
  232. package/src/project-problems.ts +10 -2
  233. package/src/proposal-model.ts +0 -1
  234. package/src/rename-model.ts +1 -1
  235. package/src/rename.ts +21 -24
  236. package/src/rendered-docs.ts +13 -6
  237. package/src/selection-ranges.ts +2 -2
  238. package/src/semantic-tokens.ts +5 -5
  239. package/src/shortcut-keys.ts +1 -1
  240. package/src/signature.ts +8 -8
  241. package/src/snippet-field-transforms.ts +1 -1
  242. package/src/snippet-insert.ts +21 -14
  243. package/src/snippet-session.ts +25 -24
  244. package/src/snippet-transform-format.ts +1 -1
  245. package/src/snippet-transform-queue.ts +5 -51
  246. package/src/snippet.ts +1 -1
  247. package/src/surround-constructs.ts +1 -1
  248. package/src/surround.ts +24 -12
  249. package/src/symbol-links.ts +1 -1
  250. package/src/symbol-picker-model.ts +1 -4
  251. package/src/symbol-picker.ts +6 -7
  252. package/src/symbols.ts +3 -4
  253. package/src/template-builtins.ts +1 -2
  254. package/src/template-context.ts +5 -14
  255. package/src/template-types.ts +43 -0
  256. package/src/templates.ts +9 -45
  257. package/src/testing.ts +52 -0
  258. package/src/use-problem-counts.ts +1 -1
  259. package/src/word-diff.ts +17 -28
  260. package/src/workspace-edit.ts +1 -34
  261. package/dist/locales/en.json +0 -356
  262. package/dist/locales/nl.json +0 -356
  263. package/src/locales/en.json +0 -356
  264. package/src/locales/nl.json +0 -356
@@ -1,9 +1,9 @@
1
1
  import { followModKey } from './definition-link.js';
2
- import { comparePositions } from './diagnostics-model.js';
3
2
  import { messageOf } from './error-message.js';
4
3
  import { hoverTextOf, isEmptyHover } from './hover-content.js';
5
4
  import { SHOW_DELAY_MS } from './hover.js';
6
5
  import { lineTextOf } from './line-text.js';
6
+ import { comparePositions } from './positions.js';
7
7
  import { Refresher } from './refresher.js';
8
8
  import { realTimers } from './timers.js';
9
9
  const METHOD = 'textDocument/inlayHint';
@@ -14,14 +14,14 @@ const PAUSE_MS = 300;
14
14
  const DOUBLE_PRESS_MS = 500;
15
15
  /* Lines asked for above and below what is in view, so a little scrolling stays inside what is already drawn. */
16
16
  const MARGIN_LINES = 60;
17
- export function hintLabelOf(hint) {
17
+ function hintLabelOf(hint) {
18
18
  return typeof hint.label === 'string' ? hint.label : hint.label.map(part => part.value).join('');
19
19
  }
20
- export function drawableHints(hints) {
20
+ function drawableHints(hints) {
21
21
  return hints.filter(hint => hintLabelOf(hint) !== '').sort((left, right) => comparePositions(left.position, right.position));
22
22
  }
23
23
  /* A hint as the editor draws it: a label with parts keeps them apart so each can be pointed at. */
24
- export function editorHintOf(hint, id) {
24
+ function editorHintOf(hint, id) {
25
25
  return {
26
26
  id,
27
27
  position: hint.position,
@@ -52,7 +52,7 @@ export function covers(asked, visible) {
52
52
  return asked.start.line <= visible.start.line && asked.end.line >= visible.end.line;
53
53
  }
54
54
  /* The words of a tooltip: plain text is escaped so it reads as typed, Markdown goes through the hover card's own rendering. */
55
- export function tooltipTextOf(tooltip) {
55
+ function tooltipTextOf(tooltip) {
56
56
  if (tooltip === undefined) {
57
57
  return null;
58
58
  }
@@ -77,7 +77,7 @@ export function tooltipOf(hint, index) {
77
77
  return tooltipTextOf(hint.label.find(candidate => candidate.tooltip !== undefined)?.tooltip);
78
78
  }
79
79
  /* Whether a server could still say more about the hint: nothing in it gives a tooltip, a place or a command yet. */
80
- export function lacksInfo(hint, index) {
80
+ function lacksInfo(hint, index) {
81
81
  if (hint.tooltip !== undefined) {
82
82
  return false;
83
83
  }
@@ -85,7 +85,7 @@ export function lacksInfo(hint, index) {
85
85
  return !parts.some(part => part !== undefined && (part.tooltip !== undefined || part.location !== undefined || part.command !== undefined));
86
86
  }
87
87
  /* Whether the edits fit the text as it is now: positions inside it, each range in order, none overlapping the next. */
88
- export function editsFit(editor, edits) {
88
+ function editsFit(editor, edits) {
89
89
  const end = editor.positionAt(Number.MAX_SAFE_INTEGER);
90
90
  const inside = position => Number.isInteger(position.line) && Number.isInteger(position.character) && position.line >= 0 && position.character >= 0 && position.line <= end.line && position.character <= lineTextOf(editor, position.line).length;
91
91
  const before = (left, right) => comparePositions(left, right) <= 0;
@@ -96,7 +96,7 @@ export function editsFit(editor, edits) {
96
96
  });
97
97
  }
98
98
  /* What a press does, from what is known of the hint: a double click inserts it and nothing else, Mod+click follows a part's place, a plain click runs its command. */
99
- export function actionOf(hint, click) {
99
+ function actionOf(hint, click) {
100
100
  if (click.clicks === 2) {
101
101
  return hint.textEdits !== undefined && hint.textEdits.length > 0 ? {
102
102
  kind: 'insert',
@@ -126,9 +126,9 @@ export function actionOf(hint, click) {
126
126
  */
127
127
  export class InlayHintsFeature {
128
128
  language;
129
+ peers;
129
130
  timers;
130
131
  refresher;
131
- /* The lines the hints on screen were asked for. */
132
132
  asked = null;
133
133
  entries = new Map();
134
134
  shown = [];
@@ -144,8 +144,9 @@ export class InlayHintsFeature {
144
144
  pressCount = 0;
145
145
  /* Counts what the pointer does, so a tooltip that was waited for is dropped once the pointer has moved on. */
146
146
  request = 0;
147
- constructor(language, timers = realTimers) {
147
+ constructor(language, peers, timers = realTimers) {
148
148
  this.language = language;
149
+ this.peers = peers;
149
150
  this.timers = timers;
150
151
  const {
151
152
  editor,
@@ -247,7 +248,7 @@ export class InlayHintsFeature {
247
248
  this.updateLink();
248
249
  if (target === null) {
249
250
  if (this.cardOpen()) {
250
- this.language.hover.release();
251
+ this.peers.hover.release();
251
252
  }
252
253
  return;
253
254
  }
@@ -264,12 +265,12 @@ export class InlayHintsFeature {
264
265
  this.target = null;
265
266
  this.updateLink();
266
267
  if (this.cardOpen()) {
267
- this.language.hover.hide();
268
+ this.peers.hover.hide();
268
269
  }
269
270
  }
270
271
  /* Whether the card up is a tooltip, which is the only kind that has no footer. */
271
272
  cardOpen() {
272
- return this.language.popups.getState().hover?.info?.plain === true;
273
+ return this.language.popups.slot('hover').get()?.info?.plain === true;
273
274
  }
274
275
  /* The card for a hint or part, once the server has said what it can. Says whether it opened. */
275
276
  async showTooltip(target, request, pointer = true) {
@@ -287,11 +288,11 @@ export class InlayHintsFeature {
287
288
  const text = tooltipOf(entry.hint, target.part);
288
289
  if (text === null) {
289
290
  if (this.cardOpen()) {
290
- this.language.hover.hide();
291
+ this.peers.hover.hide();
291
292
  }
292
293
  return false;
293
294
  }
294
- this.language.hover.showText(entry.hint.position, text);
295
+ this.peers.hover.showText(entry.hint.position, text);
295
296
  return true;
296
297
  }
297
298
  /* Asks the server for more of a hint, once; what it says is kept only while the text is the one the hint was made for. */
@@ -1,39 +1,59 @@
1
1
  import type { EditorPosition } from '@adecore/editor';
2
2
  import type { InlineCompletionItem, InlineCompletionResult, Range } from '@adecore/lsp';
3
- import type { EditorLanguage } from './editor-language.ts';
3
+ import type { LanguageContext } from './language-context.ts';
4
4
  import { type Timers } from './timers.ts';
5
5
  export interface InlineSuggestion {
6
- readonly item: InlineCompletionItem;
7
6
  readonly text: string;
8
7
  readonly range: Range;
9
8
  readonly rest: string;
9
+ readonly item?: InlineCompletionItem;
10
+ readonly accessory?: (container: HTMLElement) => (() => void) | void;
11
+ readonly words?: boolean;
12
+ }
13
+ export interface InlineSuggestionRequest {
14
+ readonly caret: EditorPosition;
15
+ readonly triggerKind: 1 | 2;
16
+ readonly signal: AbortSignal;
17
+ }
18
+ export interface InlineSuggestionSource {
19
+ readonly enabled: boolean;
20
+ readonly automatic: boolean;
21
+ suggest(request: InlineSuggestionRequest): Promise<readonly InlineSuggestion[]>;
22
+ accepted?(suggestion: InlineSuggestion): void;
10
23
  }
11
24
  export declare function itemsOf(result: InlineCompletionResult): InlineCompletionItem[];
12
25
  export declare function suggestionOf(item: InlineCompletionItem, caret: EditorPosition, textOf: (range: Range) => string): InlineSuggestion | null;
26
+ export declare function firstWord(text: string): string;
13
27
  export declare class InlineCompletionFeature {
14
28
  private readonly language;
15
29
  private readonly timers;
16
- private enabled;
17
- private suggestions;
18
- private index;
19
- private timer;
20
- private controller;
21
- private revision;
30
+ private readonly servers;
31
+ private readonly sources;
32
+ private phase;
22
33
  private accepting;
23
- constructor(language: EditorLanguage, timers?: Timers);
34
+ constructor(language: LanguageContext, timers?: Timers);
24
35
  get supported(): boolean;
25
36
  get isEnabled(): boolean;
26
37
  get current(): InlineSuggestion | null;
38
+ holds(source: InlineSuggestionSource): boolean;
39
+ addSource(source: InlineSuggestionSource, priority?: number): () => void;
27
40
  configure(settings: {
28
41
  readonly enabled?: boolean;
29
42
  }): void;
30
- trigger(): void;
43
+ private uses;
44
+ private asks;
45
+ trigger(): boolean;
46
+ triggerSource(source: InlineSuggestionSource): Promise<void>;
31
47
  accept(): boolean;
48
+ acceptWord(): boolean;
32
49
  cycle(step: 1 | -1): void;
33
50
  hide(): void;
51
+ private enter;
52
+ private insert;
34
53
  private tab;
35
54
  private key;
36
55
  private edited;
56
+ private fire;
37
57
  private moved;
38
58
  private ask;
39
59
  private draw;