@adecore/editor-react 0.41.1 → 0.43.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 (124) hide show
  1. package/dist/CallHierarchyPanel.js +177 -181
  2. package/dist/EditorContextMenu.js +118 -105
  3. package/dist/EditorView.js +7 -1
  4. package/dist/LanguagePopups.js +7 -0
  5. package/dist/PickPopup.js +190 -70
  6. package/dist/WrapCard.d.ts +8 -0
  7. package/dist/WrapCard.js +172 -0
  8. package/dist/call-hierarchy-model.d.ts +4 -2
  9. package/dist/call-hierarchy-model.js +20 -0
  10. package/dist/call-hierarchy.d.ts +3 -0
  11. package/dist/call-hierarchy.js +54 -22
  12. package/dist/clipboard-history.d.ts +31 -0
  13. package/dist/clipboard-history.js +70 -0
  14. package/dist/code-actions.d.ts +3 -1
  15. package/dist/code-actions.js +50 -10
  16. package/dist/code-vision.js +2 -3
  17. package/dist/completion.js +10 -15
  18. package/dist/context-menu-rows.d.ts +1 -1
  19. package/dist/context-menu-rows.js +4 -0
  20. package/dist/definition-link.js +15 -5
  21. package/dist/document-colors.d.ts +24 -0
  22. package/dist/document-colors.js +194 -0
  23. package/dist/document-links.d.ts +22 -0
  24. package/dist/document-links.js +133 -0
  25. package/dist/document-query.d.ts +15 -0
  26. package/dist/document-query.js +54 -0
  27. package/dist/edit-locations.d.ts +20 -0
  28. package/dist/edit-locations.js +136 -0
  29. package/dist/editor-language.d.ts +19 -1
  30. package/dist/editor-language.js +77 -2
  31. package/dist/emmet.d.ts +13 -0
  32. package/dist/emmet.js +62 -0
  33. package/dist/folding.js +2 -3
  34. package/dist/format-on-type.js +3 -5
  35. package/dist/highlights.js +2 -3
  36. package/dist/history.d.ts +7 -0
  37. package/dist/history.js +79 -1
  38. package/dist/host-types.d.ts +6 -0
  39. package/dist/index.d.ts +11 -2
  40. package/dist/index.js +8 -0
  41. package/dist/inlay-hints.js +2 -2
  42. package/dist/inline-completion.d.ts +39 -0
  43. package/dist/inline-completion.js +221 -0
  44. package/dist/key-priority.d.ts +8 -5
  45. package/dist/key-priority.js +9 -6
  46. package/dist/linked-editing.d.ts +26 -0
  47. package/dist/linked-editing.js +215 -0
  48. package/dist/locales/en.json +31 -2
  49. package/dist/locales/nl.json +31 -2
  50. package/dist/markup-context.d.ts +37 -0
  51. package/dist/markup-context.js +291 -0
  52. package/dist/markup.d.ts +36 -0
  53. package/dist/markup.js +453 -0
  54. package/dist/navigation.js +4 -6
  55. package/dist/paste-history.d.ts +7 -0
  56. package/dist/paste-history.js +104 -0
  57. package/dist/peek.js +3 -4
  58. package/dist/pick.d.ts +20 -2
  59. package/dist/pick.js +141 -18
  60. package/dist/popups.d.ts +9 -0
  61. package/dist/popups.js +2 -1
  62. package/dist/project-language.d.ts +18 -1
  63. package/dist/project-language.js +129 -18
  64. package/dist/rename.js +8 -11
  65. package/dist/rendered-docs.js +1 -2
  66. package/dist/selection-ranges.js +2 -3
  67. package/dist/shortcut-keys.d.ts +27 -0
  68. package/dist/signature.js +3 -6
  69. package/dist/snippet-session.d.ts +2 -2
  70. package/dist/snippet-session.js +3 -3
  71. package/dist/symbol-picker.js +4 -6
  72. package/dist/symbols.js +22 -3
  73. package/dist/testing.d.ts +23 -1
  74. package/dist/testing.js +114 -0
  75. package/package.json +7 -6
  76. package/src/CallHierarchyPanel.tsx +26 -11
  77. package/src/EditorContextMenu.tsx +7 -0
  78. package/src/EditorView.tsx +9 -0
  79. package/src/LanguagePopups.tsx +4 -0
  80. package/src/PickPopup.tsx +40 -5
  81. package/src/WrapCard.tsx +64 -0
  82. package/src/call-hierarchy-model.ts +25 -3
  83. package/src/call-hierarchy.ts +62 -20
  84. package/src/clipboard-history.ts +102 -0
  85. package/src/code-actions.ts +48 -11
  86. package/src/code-vision.ts +3 -3
  87. package/src/completion.ts +15 -15
  88. package/src/context-menu-rows.ts +3 -2
  89. package/src/definition-link.ts +17 -5
  90. package/src/document-colors.ts +189 -0
  91. package/src/document-links.ts +129 -0
  92. package/src/document-query.ts +71 -0
  93. package/src/edit-locations.ts +162 -0
  94. package/src/editor-language.ts +80 -3
  95. package/src/emmet-module.d.ts +44 -0
  96. package/src/emmet.ts +73 -0
  97. package/src/folding.ts +3 -3
  98. package/src/format-on-type.ts +5 -5
  99. package/src/highlights.ts +3 -3
  100. package/src/history.ts +81 -1
  101. package/src/host-types.ts +10 -0
  102. package/src/index.ts +12 -3
  103. package/src/inlay-hints.ts +2 -2
  104. package/src/inline-completion.ts +221 -0
  105. package/src/key-priority.ts +9 -6
  106. package/src/linked-editing.ts +199 -0
  107. package/src/locales/en.json +31 -2
  108. package/src/locales/nl.json +31 -2
  109. package/src/markup-context.ts +262 -0
  110. package/src/markup.ts +367 -0
  111. package/src/navigation.ts +6 -6
  112. package/src/paste-history.ts +111 -0
  113. package/src/peek.ts +4 -4
  114. package/src/pick.ts +201 -19
  115. package/src/popups.ts +19 -1
  116. package/src/project-language.ts +136 -19
  117. package/src/rename.ts +11 -11
  118. package/src/rendered-docs.ts +2 -2
  119. package/src/selection-ranges.ts +3 -3
  120. package/src/signature.ts +6 -6
  121. package/src/snippet-session.ts +9 -4
  122. package/src/symbol-picker.ts +6 -6
  123. package/src/symbols.ts +30 -4
  124. package/src/testing.ts +126 -1
@@ -1,4 +1,8 @@
1
1
  import { KEYMAP } from '@adecore/editor/keymap';
2
+ import { DocumentColorsFeature } from './document-colors.js';
3
+ import { DocumentLinksFeature } from './document-links.js';
4
+ import { InlineCompletionFeature } from './inline-completion.js';
5
+ import { LinkedEditingFeature } from './linked-editing.js';
2
6
  import { CallHierarchyFeature } from './call-hierarchy.js';
3
7
  import { CodeActionsFeature } from './code-actions.js';
4
8
  import { CodeVisionFeature } from './code-vision.js';
@@ -12,7 +16,9 @@ import { HighlightsFeature } from './highlights.js';
12
16
  import { HistoryFeature } from './history.js';
13
17
  import { HoverFeature } from './hover.js';
14
18
  import { KeyDispatcher } from './key-priority.js';
19
+ import { MarkupFeature } from './markup.js';
15
20
  import { NavigationFeature, locationRow } from './navigation.js';
21
+ import { PasteHistoryFeature } from './paste-history.js';
16
22
  import { PeekFeature } from './peek.js';
17
23
  import { PickFeature } from './pick.js';
18
24
  import { SymbolPickerFeature } from './symbol-picker.js';
@@ -27,6 +33,8 @@ import { SemanticTokensFeature } from './semantic-tokens.js';
27
33
  import { SignatureFeature } from './signature.js';
28
34
  import { SnippetFeature } from './snippet-session.js';
29
35
  import { SymbolsFeature } from './symbols.js';
36
+ /* How long the edits servers want before a save are waited for. */
37
+ const SAVE_PARTICIPANT_MS = 1_000;
30
38
  /*
31
39
  * The one place that connects an editor to the language servers: it opens the file's document for
32
40
  * the editor and lets go of it again. Every language feature of the editor hangs off this object.
@@ -39,6 +47,8 @@ export class EditorLanguage {
39
47
  project;
40
48
  document;
41
49
  languageId;
50
+ /* Whether a server serves this document; read it where a host meant "a language server is behind this editor". */
51
+ served;
42
52
  /* What the features of this editor have open over it: the hover card, the suggestions, the signature. */
43
53
  popups = createPopupStore();
44
54
  diagnostics;
@@ -47,6 +57,7 @@ export class EditorLanguage {
47
57
  completion;
48
58
  signature;
49
59
  snippets;
60
+ markup;
50
61
  highlights;
51
62
  pick;
52
63
  codeActions;
@@ -62,8 +73,14 @@ export class EditorLanguage {
62
73
  codeVision;
63
74
  formatOnType;
64
75
  renderedDocs;
76
+ pasteHistory;
77
+ links;
78
+ colors;
79
+ linkedEditing;
80
+ inlineCompletion;
65
81
  disposers = [];
66
82
  keys = new KeyDispatcher();
83
+ timers;
67
84
  disposed = false;
68
85
  constructor(project, editor, uri, languageId, timers = realTimers, options = {}) {
69
86
  this.editor = editor;
@@ -72,13 +89,18 @@ export class EditorLanguage {
72
89
  this.shortcuts = shortcutsOf(this.keymap, this.apple);
73
90
  this.project = project;
74
91
  this.languageId = languageId;
75
- this.document = project.acquire(uri, languageId, editor);
92
+ this.served = options.serve ?? true;
93
+ this.document = project.acquire(uri, languageId, editor, {
94
+ serve: this.served
95
+ });
96
+ this.timers = timers;
76
97
  this.onDispose(editor.onKeyDown(event => this.keys.dispatch(event)));
77
98
  this.pick = new PickFeature(this, timers);
78
99
  this.diagnostics = new DiagnosticsFeature(this);
79
100
  this.hover = new HoverFeature(this, timers);
80
101
  this.completion = new CompletionFeature(this, timers);
81
102
  this.snippets = new SnippetFeature(this, timers);
103
+ this.markup = new MarkupFeature(this);
82
104
  this.signature = new SignatureFeature(this, timers);
83
105
  this.highlights = new HighlightsFeature(this, timers);
84
106
  this.symbols = new SymbolsFeature(this, timers);
@@ -87,6 +109,11 @@ export class EditorLanguage {
87
109
  this.inlayHints = new InlayHintsFeature(this, timers);
88
110
  this.codeActions = new CodeActionsFeature(this, timers);
89
111
  this.rename = new RenameFeature(this);
112
+ // Before navigation, whose Mod+click goes to a definition: a link under the pointer goes first.
113
+ this.links = new DocumentLinksFeature(this, timers);
114
+ this.colors = new DocumentColorsFeature(this, timers);
115
+ this.linkedEditing = new LinkedEditingFeature(this, timers);
116
+ this.inlineCompletion = new InlineCompletionFeature(this, timers);
90
117
  this.navigation = new NavigationFeature(this);
91
118
  this.peek = new PeekFeature(this, timers);
92
119
  this.callHierarchy = new CallHierarchyFeature(this, timers);
@@ -97,13 +124,26 @@ export class EditorLanguage {
97
124
  this.codeVision = new CodeVisionFeature(this, listener => this.symbols.onResult(listener), timers);
98
125
  this.formatOnType = new FormatOnTypeFeature(this);
99
126
  this.renderedDocs = new RenderedDocsFeature(this, timers);
127
+ this.pasteHistory = new PasteHistoryFeature(this);
100
128
  new FoldingFeature(this, listener => this.symbols.onResult(listener), timers);
129
+ const copies = editor.onCopy?.(copy => project.clipboard.add(copy.text, {
130
+ wholeLines: copy.wholeLines
131
+ }));
132
+ if (copies !== undefined) {
133
+ this.onDispose(copies);
134
+ }
135
+ editor.setWordSources?.(() => this.otherTexts());
136
+ this.onDispose(() => editor.setWordSources?.(null));
101
137
  this.placeOpenedCaret(editor.getCaret());
102
138
  this.onDispose(editor.onCaret(position => this.placeOpenedCaret(position)));
103
139
  }
104
140
  get uri() {
105
141
  return this.document.uri;
106
142
  }
143
+ /* The service this document is asked through: the project's, or one that answers nothing when no server serves it. */
144
+ get service() {
145
+ return this.document.service;
146
+ }
107
147
  get isDisposed() {
108
148
  return this.disposed;
109
149
  }
@@ -169,7 +209,7 @@ export class EditorLanguage {
169
209
  listener();
170
210
  }
171
211
  }, () => undefined);
172
- const providers = this.project.service.onProvidersChanged(uri => {
212
+ const providers = this.service.onProvidersChanged(uri => {
173
213
  if (uri === this.uri) {
174
214
  listener();
175
215
  }
@@ -186,6 +226,37 @@ export class EditorLanguage {
186
226
  onKey(handler, priority = 0) {
187
227
  return this.keys.add(handler, priority);
188
228
  }
229
+ /*
230
+ * Lets the servers in before the host writes the file: tells them a save is coming and applies the edits they
231
+ * want made first, such as organized imports. A server that has not answered within a second is passed over,
232
+ * as the specification allows. Call it, then save, then let the service send `didSave`.
233
+ */
234
+ async prepareSave(reason = 1) {
235
+ const {
236
+ service
237
+ } = this.project;
238
+ await service.willSave?.(this.uri, reason).catch(() => undefined);
239
+ if (service.willSaveWaitUntil === undefined) {
240
+ return;
241
+ }
242
+ const controller = new AbortController();
243
+ const timer = this.timers.set(() => controller.abort(), SAVE_PARTICIPANT_MS);
244
+ try {
245
+ const edits = await service.willSaveWaitUntil(this.uri, reason, {
246
+ signal: controller.signal
247
+ });
248
+ if (!controller.signal.aborted && edits !== null && edits.length > 0) {
249
+ this.editor.applyEdits(edits.map(edit => ({
250
+ range: edit.range,
251
+ text: edit.newText
252
+ })));
253
+ }
254
+ } catch {
255
+ // A server that fails or is too slow does not keep the file from being saved.
256
+ } finally {
257
+ this.timers.clear(timer);
258
+ }
259
+ }
189
260
  /* Runs `dispose` when the editor lets go of its document. */
190
261
  onDispose(dispose) {
191
262
  this.disposers.push(dispose);
@@ -200,6 +271,10 @@ export class EditorLanguage {
200
271
  }
201
272
  this.document.release();
202
273
  }
274
+ /* The texts of the other open editors of the project, which Hippie completion takes words from. */
275
+ otherTexts() {
276
+ return this.project.openEditors().filter(open => open.uri !== this.uri).map(open => open.editor.getText());
277
+ }
203
278
  /* A file opened from another one lands on the line; this puts the caret on the column the jump meant. */
204
279
  placeOpenedCaret(position) {
205
280
  const column = this.project.takeCaret(this.uri, position.line);
@@ -0,0 +1,13 @@
1
+ import type { MarkupSyntax } from './markup-context.ts';
2
+ export interface AbbreviationOptions {
3
+ readonly syntax: MarkupSyntax;
4
+ readonly indent: string;
5
+ readonly wrap?: readonly string[];
6
+ }
7
+ export interface FoundAbbreviation {
8
+ readonly abbreviation: string;
9
+ readonly start: number;
10
+ readonly end: number;
11
+ }
12
+ export declare function abbreviationBefore(line: string, character: number): FoundAbbreviation | null;
13
+ export declare function expandAbbreviation(abbreviation: string, options: AbbreviationOptions): string | null;
package/dist/emmet.js ADDED
@@ -0,0 +1,62 @@
1
+ // A reference and no import, so an app that type-checks this source reads the declaration of the package too.
2
+ // oxlint-disable-next-line typescript/triple-slash-reference
3
+ /// <reference path="./emmet-module.d.ts" />
4
+ import { extract, markup, markupAbbreviation, resolveConfig } from 'emmet';
5
+ /* A text of an expansion is snippet syntax, where these mean a tab stop or end one. */
6
+ function escapeText(text) {
7
+ return text.replace(/[$}\\]/g, '\\$&');
8
+ }
9
+ function field(index, placeholder) {
10
+ return placeholder === '' ? `\${${index}}` : `\${${index}:${escapeText(placeholder)}}`;
11
+ }
12
+ /* `lipsum` is the other name of `lorem` that IntelliJ and the Emmet documentation accept. */
13
+ function renameLipsum(node) {
14
+ if (node.name !== undefined && /^lipsum(?=\d|$)/i.test(node.name)) {
15
+ node.name = 'lorem' + node.name.slice(6);
16
+ }
17
+ for (const child of node.children) {
18
+ renameLipsum(child);
19
+ }
20
+ }
21
+ /* The abbreviation that ends at `character` of a line, or null where nothing before the caret reads as one. */
22
+ export function abbreviationBefore(line, character) {
23
+ const found = extract(line, character, {
24
+ type: 'markup',
25
+ lookAhead: true
26
+ });
27
+ if (found === undefined || !/^[A-Za-z!.#([{]/.test(found.abbreviation)) {
28
+ return null;
29
+ }
30
+ return {
31
+ abbreviation: found.abbreviation,
32
+ start: found.start,
33
+ end: found.end
34
+ };
35
+ }
36
+ /*
37
+ * The expansion of an abbreviation as snippet text, its places to fill as tab stops; null when it does not
38
+ * read as one. Lorem ipsum words after the first sentence differ per expansion.
39
+ */
40
+ export function expandAbbreviation(abbreviation, options) {
41
+ const text = options.wrap === undefined ? undefined : [...options.wrap];
42
+ try {
43
+ const tree = markupAbbreviation(abbreviation, {
44
+ text
45
+ });
46
+ for (const child of tree.children) {
47
+ renameLipsum(child);
48
+ }
49
+ const expanded = markup(tree, resolveConfig({
50
+ syntax: options.syntax === 'xml' ? 'xml' : 'html',
51
+ text,
52
+ options: {
53
+ 'output.field': field,
54
+ 'output.text': escapeText,
55
+ 'output.indent': options.indent
56
+ }
57
+ }));
58
+ return expanded === '' ? null : expanded;
59
+ } catch {
60
+ return null;
61
+ }
62
+ }
package/dist/folding.js CHANGED
@@ -60,14 +60,13 @@ export class FoldingFeature {
60
60
  this.language = language;
61
61
  const {
62
62
  editor,
63
- project,
64
63
  uri
65
64
  } = language;
66
65
  this.refresher = new Refresher(async signal => {
67
- if (!project.service.supports(METHOD, uri)) {
66
+ if (!language.service.supports(METHOD, uri)) {
68
67
  return;
69
68
  }
70
- const ranges = await project.service.foldingRanges(uri, {
69
+ const ranges = await language.service.foldingRanges(uri, {
71
70
  signal
72
71
  });
73
72
  if (!signal.aborted) {
@@ -38,10 +38,9 @@ export class FormatOnTypeFeature {
38
38
  /* Whether the server of this document formats on type and the service can ask it. */
39
39
  get supported() {
40
40
  const {
41
- project,
42
41
  uri
43
42
  } = this.language;
44
- return project.service.onTypeFormatting !== undefined && project.service.supports(METHOD, uri);
43
+ return this.language.service.onTypeFormatting !== undefined && this.language.service.supports(METHOD, uri);
45
44
  }
46
45
  configure(enabled) {
47
46
  this.enabled = enabled;
@@ -51,7 +50,7 @@ export class FormatOnTypeFeature {
51
50
  }
52
51
  /* The characters that ask the server, the first one and the more. */
53
52
  triggerCharacters() {
54
- const options = this.language.project.service.providerOptions(METHOD, this.language.uri);
53
+ const options = this.language.service.providerOptions(METHOD, this.language.uri);
55
54
  return options === undefined ? [] : [...(options.firstTriggerCharacter === undefined ? [] : [options.firstTriggerCharacter]), ...(options.moreTriggerCharacter ?? [])];
56
55
  }
57
56
  typed(change) {
@@ -80,14 +79,13 @@ export class FormatOnTypeFeature {
80
79
  async ask(revision, typed, caret, signal) {
81
80
  const {
82
81
  editor,
83
- project,
84
82
  uri,
85
83
  document
86
84
  } = this.language;
87
85
  try {
88
86
  // The change of the typed character reaches the server before this question does.
89
87
  await document.ready;
90
- const edits = await project.service.onTypeFormatting(uri, caret, typed, {
88
+ const edits = await this.language.service.onTypeFormatting(uri, caret, typed, {
91
89
  ...editor.getIndentation()
92
90
  }, {
93
91
  signal
@@ -40,15 +40,14 @@ export class HighlightsFeature {
40
40
  this.language = language;
41
41
  const {
42
42
  editor,
43
- project,
44
43
  uri
45
44
  } = language;
46
45
  this.refresher = new Refresher(async signal => {
47
- if (!project.service.supports(METHOD, uri) || !this.onName()) {
46
+ if (!language.service.supports(METHOD, uri) || !this.onName()) {
48
47
  this.clear();
49
48
  return;
50
49
  }
51
- const result = await project.service.documentHighlights(uri, editor.getCaret(), {
50
+ const result = await language.service.documentHighlights(uri, editor.getCaret(), {
52
51
  signal
53
52
  });
54
53
  if (!signal.aborted) {
package/dist/history.d.ts CHANGED
@@ -1,9 +1,16 @@
1
1
  import type { EditorLanguage } from './editor-language.ts';
2
2
  export declare class HistoryFeature {
3
3
  private readonly language;
4
+ private editing;
4
5
  constructor(language: EditorLanguage);
6
+ lastEdit(): boolean;
7
+ nextEdit(): boolean;
5
8
  back(): boolean;
6
9
  forward(): boolean;
7
10
  recent(): void;
11
+ private currentEdit;
12
+ private edited;
13
+ private moved;
14
+ private visitEdit;
8
15
  private visit;
9
16
  }
package/dist/history.js CHANGED
@@ -3,6 +3,7 @@ import { isShortcut } from './shortcut-keys.js';
3
3
  /* Back, Forward and the list of recent locations over the history the whole project shares. */
4
4
  export class HistoryFeature {
5
5
  language;
6
+ editing = false;
6
7
  constructor(language) {
7
8
  this.language = language;
8
9
  const off = language.onKey(event => {
@@ -18,9 +19,37 @@ export class HistoryFeature {
18
19
  this.recent();
19
20
  return true;
20
21
  }
22
+ if (isShortcut(this.language.shortcuts.lastEditLocation, event)) {
23
+ this.lastEdit();
24
+ return true;
25
+ }
26
+ if (isShortcut(this.language.shortcuts.nextEditLocation, event)) {
27
+ this.nextEdit();
28
+ return true;
29
+ }
21
30
  return false;
22
31
  }, KEY_PRIORITY.history);
23
- language.onDispose(off);
32
+ // A jump of the editor's own, such as Method Down, is a place Back returns to like any other jump.
33
+ const navigations = language.editor.onNavigate?.(from => language.project.history.record({
34
+ uri: language.uri,
35
+ position: from
36
+ }));
37
+ const changes = language.editor.onTextChange(change => this.edited(change));
38
+ const carets = language.editor.onCaret(position => this.moved(position));
39
+ language.onDispose(() => {
40
+ off();
41
+ navigations?.();
42
+ changes();
43
+ carets();
44
+ });
45
+ }
46
+ /* Goes to where the project was edited before the carets' place; false when there is no such place. */
47
+ lastEdit() {
48
+ return this.visitEdit(this.language.project.edits.previous(this.currentEdit()));
49
+ }
50
+ /* Goes to where the project was edited after the place Last Edit Location came back to. */
51
+ nextEdit() {
52
+ return this.visitEdit(this.language.project.edits.next(this.currentEdit()));
24
53
  }
25
54
  /* Returns to where the caret was before the last jump; false when there is no such place. */
26
55
  back() {
@@ -40,6 +69,55 @@ export class HistoryFeature {
40
69
  }
41
70
  })), this.language.editor.getCaret(), this.language.project.i18n.t('editor:language.history.recent'));
42
71
  }
72
+ currentEdit() {
73
+ return {
74
+ uri: this.language.uri,
75
+ selections: this.language.editor.getSelections()
76
+ };
77
+ }
78
+ /* Every edit moves the places of the file; one a person made counts as an edit location once the caret has settled. */
79
+ edited(change) {
80
+ const {
81
+ editor,
82
+ project,
83
+ uri
84
+ } = this.language;
85
+ project.edits.map(uri, change.changes);
86
+ this.editing = true;
87
+ queueMicrotask(() => {
88
+ this.editing = false;
89
+ if (change.source !== 'external' && editor.hasFocus?.() !== false && !this.language.isDisposed) {
90
+ project.edits.record(this.currentEdit());
91
+ }
92
+ });
93
+ }
94
+ /* A caret that moves on its own ends the walk through the edits, unless an edit moved it. */
95
+ moved(position) {
96
+ if (!this.editing) {
97
+ this.language.project.edits.moved(this.language.uri, position);
98
+ }
99
+ }
100
+ visitEdit(place) {
101
+ if (place === null) {
102
+ return false;
103
+ }
104
+ const {
105
+ editor,
106
+ project,
107
+ uri
108
+ } = this.language;
109
+ if (place.uri === uri) {
110
+ editor.setSelections(place.selections, 'center');
111
+ editor.focus();
112
+ } else {
113
+ // Another file opens on one caret, the primary.
114
+ project.openPlace({
115
+ uri: place.uri,
116
+ position: place.selections.at(-1).end
117
+ });
118
+ }
119
+ return true;
120
+ }
43
121
  visit(place) {
44
122
  if (place === null) {
45
123
  return false;
@@ -2,9 +2,11 @@ import type { WorkerRequestPort } from '@adecore/editor/worker-client';
2
2
  import type { EditorPosition, EditorRange } from '@adecore/editor';
3
3
  import type { i18n } from 'i18next';
4
4
  import type { Keymap } from '@adecore/editor/keymap';
5
+ import type { ClipboardHistory } from './clipboard-history.ts';
5
6
  import type { ProjectFiles } from './workspace-edit.ts';
6
7
  import type { Place } from './navigation-history.ts';
7
8
  import type { ProblemSource } from './project-problems.ts';
9
+ import type { ServerMessage } from '@adecore/lsp';
8
10
  export interface DiskText {
9
11
  text: string;
10
12
  mtime: number;
@@ -55,13 +57,17 @@ export interface LanguageHost {
55
57
  readonly files?: ProjectFiles;
56
58
  readonly apple?: boolean;
57
59
  readonly keymap?: Keymap;
60
+ readonly clipboard?: ClipboardHistory;
61
+ readonly editHistoryLimit?: number;
58
62
  readonly panelBodyHeight?: number;
59
63
  onPanelResize?(height: number): void;
60
64
  readonly problemSource?: ProblemSource;
61
65
  openPlace?(place: Place): void;
66
+ openExternal?(url: string): void;
62
67
  pathOfUri?(uri: string): string | null;
63
68
  serverNames?(uri: string): readonly string[];
64
69
  notify?(notification: EditorNotification): void;
70
+ onServerMessage?(message: ServerMessage): void;
65
71
  resolveSnippetVariable?(name: string, context: SnippetVariableContext): string | undefined;
66
72
  suggestNames?(request: RenameSuggestionsRequest, signal: AbortSignal): Promise<readonly string[]>;
67
73
  }
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { KEY_PRIORITY } from './key-priority.ts';
3
3
  export { realTimers, type Timers } from './timers.ts';
4
4
  export { type SemanticTokensOptions } from './semantic-tokens.ts';
5
5
  export { ProjectLanguage, type FileOperationTarget } from './project-language.ts';
6
- export type { LanguageDocumentHandle } from './project-language.ts';
6
+ export type { AcquireOptions, LanguageDocumentHandle } from './project-language.ts';
7
7
  export type { SnippetVariableContext, LanguageHost, DiskText, GitBlameCommit, GitBlameResult, EditorNotification, RenameSuggestionsRequest } from './host-types.ts';
8
8
  export { EditorView } from './EditorView.tsx';
9
9
  export { createHolder } from './holder.ts';
@@ -13,6 +13,10 @@ export type { LanguagePopupsProps } from './LanguagePopups.tsx';
13
13
  export { AnchoredPopup } from './AnchoredPopup.tsx';
14
14
  export { SignatureCard } from './SignatureCard.tsx';
15
15
  export { type RenderedDocsFeature } from './rendered-docs.ts';
16
+ export { type DocumentLinksFeature } from './document-links.ts';
17
+ export { type DocumentColorsFeature } from './document-colors.ts';
18
+ export { type LinkedEditingFeature } from './linked-editing.ts';
19
+ export { type InlineCompletionFeature, type InlineSuggestion } from './inline-completion.ts';
16
20
  export type { RenderedDocEntry, RenderedDocsSettings } from './rendered-docs.ts';
17
21
  export type { DocTagEntry, DocTagSection, ParsedDocComment } from './doc-comment-model.ts';
18
22
  export { EditorRenderingProvider } from './rendering.tsx';
@@ -28,12 +32,17 @@ export { useProblemCounts } from './use-problem-counts.ts';
28
32
  export type { ProblemCounts } from './diagnostics.ts';
29
33
  export type { BlameSource, CodeVisionSettings } from './code-vision.ts';
30
34
  export type { HoverSettings } from './hover.ts';
31
- export type { PopupState, PopupStore, HoverInfo, HoverView, CompletionView, CompletionDocs, CompletionRow, SignatureView, RenameView, RenameFileView, PeekView, CallHierarchyView, PickView, PickGroup, PickRow, PickPreview, SymbolsView, MenuView, AuthorsView } from './popups.ts';
35
+ export type { PopupState, PopupStore, HoverInfo, HoverView, CompletionView, CompletionDocs, CompletionRow, SignatureView, RenameView, RenameFileView, PeekView, CallHierarchyView, PickView, PickGroup, PickRow, PickPreview, SymbolsView, MenuView, AuthorsView, WrapView } from './popups.ts';
36
+ export { type MarkupFeature } from './markup.ts';
37
+ export type { MarkupSettings } from './markup.ts';
32
38
  export { RowHost, LineActionHost } from './row-host.ts';
33
39
  export type { HostedRow, HostedAction } from './row-host.ts';
34
40
  export { type HighlightLayers, highlightLayers } from './highlight-layers.ts';
35
41
  export { type NavigationHistory } from './navigation-history.ts';
36
42
  export type { Place } from './navigation-history.ts';
43
+ export { EditLocations, type EditPlace } from './edit-locations.ts';
44
+ export { ClipboardHistory, type ClipboardEntry, type ClipboardHistoryOptions } from './clipboard-history.ts';
45
+ export { type PasteHistoryFeature } from './paste-history.ts';
37
46
  export { openingPlace, viewStates, followViewStates, viewStateKey, forgetMovesFrom } from './view-state.ts';
38
47
  export type { ViewState, RevealLineRequest } from './view-state.ts';
39
48
  export { lspLanguageIdOf, shikiLanguageOf, shikiLanguageOfPath } from './language-ids.ts';
package/dist/index.js CHANGED
@@ -9,15 +9,23 @@ export { LanguagePopups } from "./LanguagePopups.js";
9
9
  export { AnchoredPopup } from "./AnchoredPopup.js";
10
10
  export { SignatureCard } from "./SignatureCard.js";
11
11
  export {} from './rendered-docs.js';
12
+ export {} from './document-links.js';
13
+ export {} from './document-colors.js';
14
+ export {} from './linked-editing.js';
15
+ export {} from './inline-completion.js';
12
16
  export { EditorRenderingProvider } from "./rendering.js";
13
17
  export { FindReplace } from "./FindReplace.js";
14
18
  export { ChangeReview } from "./ChangeReview.js";
15
19
  export { ProjectProblems, serviceProblems, countsOf } from './project-problems.js';
16
20
  export { applyWorkspaceEdit, supportedResourceOperations } from './workspace-edit.js';
17
21
  export { useProblemCounts } from './use-problem-counts.js';
22
+ export {} from './markup.js';
18
23
  export { RowHost, LineActionHost } from './row-host.js';
19
24
  export { highlightLayers } from './highlight-layers.js';
20
25
  export {} from './navigation-history.js';
26
+ export { EditLocations } from './edit-locations.js';
27
+ export { ClipboardHistory } from './clipboard-history.js';
28
+ export {} from './paste-history.js';
21
29
  export { openingPlace, viewStates, followViewStates, viewStateKey, forgetMovesFrom } from './view-state.js';
22
30
  export { lspLanguageIdOf, shikiLanguageOf, shikiLanguageOfPath } from './language-ids.js';
23
31
  export { AttributionCard } from "./AttributionCard.js";
@@ -321,7 +321,7 @@ export class InlayHintsFeature {
321
321
  }
322
322
  /* Whether asking the server could still change what the hint offers. */
323
323
  resolvable(entry) {
324
- return !entry.answered && entry.epoch === this.epoch && this.language.project.service.supports(RESOLVE_METHOD, this.language.uri);
324
+ return !entry.answered && entry.epoch === this.epoch && this.language.service.supports(RESOLVE_METHOD, this.language.uri);
325
325
  }
326
326
  /* Underlines the part under the pointer when a press would do something with it: a command always, a place while the key is down. */
327
327
  updateLink() {
@@ -398,7 +398,7 @@ export class InlayHintsFeature {
398
398
  this.cancelHover();
399
399
  this.language.goTo(action.location);
400
400
  } else if (action.kind === 'run') {
401
- await project.service.executeCommand(uri, action.command);
401
+ await this.language.service.executeCommand(uri, action.command);
402
402
  } else if (entry.epoch === this.epoch && editsFit(editor, action.edits)) {
403
403
  this.cancelHover();
404
404
  const applied = editor.applyEdits(action.edits.map(edit => ({
@@ -0,0 +1,39 @@
1
+ import type { EditorPosition } from '@adecore/editor';
2
+ import type { InlineCompletionItem, InlineCompletionResult, Range } from '@adecore/lsp';
3
+ import type { EditorLanguage } from './editor-language.ts';
4
+ import { type Timers } from './timers.ts';
5
+ export interface InlineSuggestion {
6
+ readonly item: InlineCompletionItem;
7
+ readonly text: string;
8
+ readonly range: Range;
9
+ readonly rest: string;
10
+ }
11
+ export declare function itemsOf(result: InlineCompletionResult): InlineCompletionItem[];
12
+ export declare function suggestionOf(item: InlineCompletionItem, caret: EditorPosition, textOf: (range: Range) => string): InlineSuggestion | null;
13
+ export declare class InlineCompletionFeature {
14
+ private readonly language;
15
+ private readonly timers;
16
+ private enabled;
17
+ private suggestions;
18
+ private index;
19
+ private timer;
20
+ private controller;
21
+ private revision;
22
+ private accepting;
23
+ constructor(language: EditorLanguage, timers?: Timers);
24
+ get supported(): boolean;
25
+ get isEnabled(): boolean;
26
+ get current(): InlineSuggestion | null;
27
+ configure(settings: {
28
+ readonly enabled?: boolean;
29
+ }): void;
30
+ trigger(): void;
31
+ accept(): boolean;
32
+ cycle(step: 1 | -1): void;
33
+ hide(): void;
34
+ private key;
35
+ private edited;
36
+ private moved;
37
+ private ask;
38
+ private draw;
39
+ }