@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.
- package/README.md +2 -2
- package/dist/AnchoredPopup.d.ts +2 -1
- package/dist/CompletionPopup.js +0 -2
- package/dist/DiffView.d.ts +1 -28
- package/dist/EditorView.js +0 -1
- package/dist/HoverSections.d.ts +1 -8
- package/dist/HoverSections.js +2 -2
- package/dist/LanguagePopups.js +30 -14
- package/dist/PanelResizeHandle.js +0 -1
- package/dist/PeekPanel.js +0 -1
- package/dist/PickPopup.js +0 -1
- package/dist/RenderedDocs.js +0 -2
- package/dist/SplitDiffView.d.ts +1 -1
- package/dist/SymbolPicker.js +0 -1
- package/dist/call-hierarchy-model.js +0 -4
- package/dist/call-hierarchy.d.ts +9 -2
- package/dist/call-hierarchy.js +51 -67
- package/dist/clipboard-history.d.ts +3 -0
- package/dist/clipboard-history.js +0 -1
- package/dist/code-actions-model.js +1 -1
- package/dist/code-actions.d.ts +14 -2
- package/dist/code-actions.js +14 -9
- package/dist/code-authors.js +4 -12
- package/dist/code-vision-model.d.ts +0 -1
- package/dist/code-vision-model.js +1 -2
- package/dist/code-vision.d.ts +11 -3
- package/dist/code-vision.js +13 -18
- package/dist/completion-call.d.ts +1 -1
- package/dist/completion-call.js +2 -1
- package/dist/completion-model.d.ts +5 -4
- package/dist/completion-model.js +4 -4
- package/dist/completion.d.ts +13 -4
- package/dist/completion.js +19 -18
- package/dist/context-menu-rows.d.ts +2 -1
- package/dist/context-menu.d.ts +9 -3
- package/dist/context-menu.js +17 -19
- package/dist/definition-link.d.ts +8 -2
- package/dist/definition-link.js +4 -2
- package/dist/diagnostics-model.d.ts +6 -8
- package/dist/diagnostics-model.js +1 -54
- package/dist/diagnostics.d.ts +9 -7
- package/dist/diagnostics.js +6 -4
- package/dist/diff-view-props.d.ts +28 -0
- package/dist/diff-view-props.js +1 -0
- package/dist/doc-comment-model.js +0 -2
- package/dist/document-colors.d.ts +9 -4
- package/dist/document-colors.js +7 -4
- package/dist/document-links.d.ts +2 -3
- package/dist/document-links.js +2 -3
- package/dist/document-query.d.ts +2 -2
- package/dist/edit-locations.js +4 -22
- package/dist/editor-language.d.ts +12 -7
- package/dist/editor-language.js +54 -45
- package/dist/emmet.d.ts +3 -2
- package/dist/folding.d.ts +2 -4
- package/dist/folding.js +1 -2
- package/dist/format-on-type.d.ts +8 -2
- package/dist/format-on-type.js +8 -6
- package/dist/highlights.d.ts +2 -6
- package/dist/highlights.js +3 -3
- package/dist/history.d.ts +8 -2
- package/dist/history.js +4 -2
- package/dist/host-types.d.ts +39 -22
- package/dist/hover-content.js +0 -1
- package/dist/hover.d.ts +13 -2
- package/dist/hover.js +25 -28
- package/dist/index.d.ts +19 -9
- package/dist/index.js +5 -2
- package/dist/inlay-hints.d.ts +12 -21
- package/dist/inlay-hints.js +16 -15
- package/dist/inline-completion.d.ts +30 -10
- package/dist/inline-completion.js +346 -102
- package/dist/key-priority.d.ts +1 -1
- package/dist/key-priority.js +2 -2
- package/dist/language-context.d.ts +30 -0
- package/dist/language-context.js +1 -0
- package/dist/language-ids.d.ts +0 -1
- package/dist/language-ids.js +0 -32
- package/dist/line-text.js +0 -1
- package/dist/linked-editing.d.ts +2 -4
- package/dist/linked-editing.js +1 -3
- package/dist/live-templates.d.ts +14 -2
- package/dist/live-templates.js +15 -10
- package/dist/locales/en.d.ts +357 -0
- package/dist/locales/en.js +356 -0
- package/dist/locales/nl.d.ts +357 -0
- package/dist/locales/nl.js +356 -0
- package/dist/markup-context.d.ts +7 -6
- package/dist/markup-context.js +0 -1
- package/dist/markup.d.ts +8 -2
- package/dist/markup.js +19 -20
- package/dist/models.d.ts +2 -1
- package/dist/models.js +2 -1
- package/dist/navigation-history.d.ts +7 -0
- package/dist/navigation.d.ts +11 -8
- package/dist/navigation.js +9 -20
- package/dist/panel-size.d.ts +4 -0
- package/dist/paste-history.d.ts +8 -2
- package/dist/paste-history.js +4 -2
- package/dist/patch-layout.d.ts +0 -4
- package/dist/patch-layout.js +1 -1
- package/dist/peek-model.js +0 -1
- package/dist/peek.d.ts +8 -2
- package/dist/peek.js +31 -42
- package/dist/pick.d.ts +4 -2
- package/dist/pick.js +38 -15
- package/dist/popups.d.ts +25 -20
- package/dist/popups.js +31 -15
- package/dist/positions.d.ts +7 -0
- package/dist/positions.js +54 -0
- package/dist/postfix.d.ts +11 -2
- package/dist/postfix.js +10 -6
- package/dist/project-language.d.ts +11 -3
- package/dist/project-language.js +40 -9
- package/dist/project-problems.d.ts +7 -1
- package/dist/project-problems.js +2 -1
- package/dist/rename-model.js +1 -1
- package/dist/rename.d.ts +2 -2
- package/dist/rename.js +17 -22
- package/dist/rendered-docs.d.ts +8 -2
- package/dist/rendered-docs.js +5 -4
- package/dist/selection-ranges.d.ts +2 -2
- package/dist/semantic-tokens.d.ts +2 -4
- package/dist/semantic-tokens.js +2 -2
- package/dist/shortcut-keys.d.ts +2 -1
- package/dist/signature.d.ts +2 -2
- package/dist/signature.js +9 -15
- package/dist/snippet-field-transforms.js +1 -1
- package/dist/snippet-insert.d.ts +4 -2
- package/dist/snippet-insert.js +9 -15
- package/dist/snippet-session.d.ts +9 -4
- package/dist/snippet-session.js +14 -14
- package/dist/snippet-transform-format.d.ts +2 -1
- package/dist/snippet-transform-queue.d.ts +2 -4
- package/dist/snippet-transform-queue.js +5 -37
- package/dist/snippet.d.ts +2 -1
- package/dist/surround-constructs.d.ts +1 -1
- package/dist/surround.d.ts +13 -2
- package/dist/surround.js +15 -8
- package/dist/symbol-links.d.ts +0 -1
- package/dist/symbol-links.js +1 -1
- package/dist/symbol-picker-model.d.ts +0 -1
- package/dist/symbol-picker-model.js +1 -2
- package/dist/symbol-picker.d.ts +2 -2
- package/dist/symbol-picker.js +5 -10
- package/dist/symbols.d.ts +4 -3
- package/dist/template-builtins.d.ts +1 -1
- package/dist/template-builtins.js +0 -1
- package/dist/template-context.d.ts +3 -3
- package/dist/template-context.js +2 -11
- package/dist/template-types.d.ts +20 -0
- package/dist/template-types.js +1 -0
- package/dist/templates.d.ts +5 -20
- package/dist/templates.js +0 -1
- package/dist/testing.d.ts +6 -0
- package/dist/testing.js +42 -0
- package/dist/use-problem-counts.d.ts +1 -1
- package/dist/word-diff.d.ts +1 -1
- package/dist/word-diff.js +16 -25
- package/dist/workspace-edit.d.ts +1 -24
- package/dist/workspace-edit.js +0 -1
- package/package.json +10 -9
- package/src/AnchoredPopup.tsx +1 -1
- package/src/CompletionPopup.tsx +0 -2
- package/src/DiffView.tsx +6 -38
- package/src/EditorView.tsx +0 -1
- package/src/HoverSections.tsx +2 -2
- package/src/LanguagePopups.tsx +20 -14
- package/src/PanelResizeHandle.tsx +0 -1
- package/src/PeekPanel.tsx +0 -1
- package/src/PickPopup.tsx +0 -1
- package/src/RenderedDocs.tsx +0 -2
- package/src/SplitDiffView.tsx +1 -1
- package/src/SymbolPicker.tsx +0 -1
- package/src/call-hierarchy-model.ts +0 -7
- package/src/call-hierarchy.ts +32 -31
- package/src/clipboard-history.ts +5 -2
- package/src/code-actions-model.ts +1 -4
- package/src/code-actions.ts +26 -10
- package/src/code-authors.ts +4 -15
- package/src/code-vision-model.ts +1 -2
- package/src/code-vision.ts +23 -19
- package/src/completion-call.ts +2 -2
- package/src/completion-model.ts +12 -7
- package/src/completion.ts +31 -16
- package/src/context-menu-rows.ts +1 -1
- package/src/context-menu.ts +19 -10
- package/src/definition-link.ts +12 -4
- package/src/diagnostics-model.ts +8 -55
- package/src/diagnostics.ts +11 -20
- package/src/diff-view-props.ts +38 -0
- package/src/doc-comment-model.ts +0 -2
- package/src/document-colors.ts +14 -6
- package/src/document-links.ts +5 -6
- package/src/document-query.ts +3 -3
- package/src/edit-locations.ts +4 -19
- package/src/editor-language.ts +74 -39
- package/src/emmet.ts +2 -3
- package/src/folding.ts +4 -5
- package/src/format-on-type.ts +14 -7
- package/src/highlights.ts +6 -6
- package/src/history.ts +12 -4
- package/src/host-types.ts +52 -33
- package/src/hover-content.ts +0 -1
- package/src/hover.ts +29 -22
- package/src/index.ts +25 -14
- package/src/inlay-hints.ts +23 -17
- package/src/inline-completion.ts +340 -90
- package/src/key-priority.ts +2 -2
- package/src/language-context.ts +60 -0
- package/src/language-ids.ts +0 -34
- package/src/line-text.ts +0 -1
- package/src/linked-editing.ts +4 -6
- package/src/live-templates.ts +27 -13
- package/src/locales/en.ts +356 -0
- package/src/locales/nl.ts +356 -0
- package/src/markup-context.ts +6 -9
- package/src/markup.ts +19 -10
- package/src/models.ts +2 -1
- package/src/navigation-history.ts +11 -0
- package/src/navigation.ts +18 -20
- package/src/panel-size.ts +8 -0
- package/src/paste-history.ts +12 -4
- package/src/patch-layout.ts +1 -1
- package/src/peek-model.ts +0 -1
- package/src/peek.ts +22 -18
- package/src/pick.ts +30 -16
- package/src/popups.ts +61 -40
- package/src/positions.ts +54 -0
- package/src/postfix.ts +21 -8
- package/src/project-language.ts +63 -14
- package/src/project-problems.ts +10 -2
- package/src/proposal-model.ts +0 -1
- package/src/rename-model.ts +1 -1
- package/src/rename.ts +21 -24
- package/src/rendered-docs.ts +13 -6
- package/src/selection-ranges.ts +2 -2
- package/src/semantic-tokens.ts +5 -5
- package/src/shortcut-keys.ts +1 -1
- package/src/signature.ts +8 -8
- package/src/snippet-field-transforms.ts +1 -1
- package/src/snippet-insert.ts +21 -14
- package/src/snippet-session.ts +25 -24
- package/src/snippet-transform-format.ts +1 -1
- package/src/snippet-transform-queue.ts +5 -51
- package/src/snippet.ts +1 -1
- package/src/surround-constructs.ts +1 -1
- package/src/surround.ts +24 -12
- package/src/symbol-links.ts +1 -1
- package/src/symbol-picker-model.ts +1 -4
- package/src/symbol-picker.ts +6 -7
- package/src/symbols.ts +3 -4
- package/src/template-builtins.ts +1 -2
- package/src/template-context.ts +5 -14
- package/src/template-types.ts +43 -0
- package/src/templates.ts +9 -45
- package/src/testing.ts +52 -0
- package/src/use-problem-counts.ts +1 -1
- package/src/word-diff.ts +17 -28
- package/src/workspace-edit.ts +1 -34
- package/dist/locales/en.json +0 -356
- package/dist/locales/nl.json +0 -356
- package/src/locales/en.json +0 -356
- package/src/locales/nl.json +0 -356
package/src/format-on-type.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { EditorTextChange } from '@adecore/editor';
|
|
2
2
|
import type { TextEdit } from '@adecore/lsp';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import type { LanguageContext } from './language-context.ts';
|
|
4
|
+
import { comparePositions } from './positions.ts';
|
|
5
|
+
import type { SnippetFeature } from './snippet-session.ts';
|
|
5
6
|
|
|
6
7
|
const METHOD = 'textDocument/onTypeFormatting';
|
|
7
8
|
|
|
@@ -18,6 +19,11 @@ function overlaps(edits: readonly TextEdit[]): boolean {
|
|
|
18
19
|
return ordered.some((edit, index) => index > 0 && comparePositions(ordered[index - 1]!.range.end, edit.range.start) > 0);
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
/* The sibling features FormatOnTypeFeature drives, which the editor language hands over. */
|
|
23
|
+
interface FormatOnTypePeers {
|
|
24
|
+
readonly snippets: Pick<SnippetFeature, 'applyEdits' | 'isActive' | 'token'>;
|
|
25
|
+
}
|
|
26
|
+
|
|
21
27
|
/*
|
|
22
28
|
* Formatting while typing: after one of the server's trigger characters is typed, the server is asked what
|
|
23
29
|
* to change around the caret, and its edits join the undo step of the typed character.
|
|
@@ -28,7 +34,8 @@ function overlaps(edits: readonly TextEdit[]): boolean {
|
|
|
28
34
|
* An answer is applied only while the text and the caret are what it was asked about. Off until `configure(true)`.
|
|
29
35
|
*/
|
|
30
36
|
export class FormatOnTypeFeature {
|
|
31
|
-
private readonly language:
|
|
37
|
+
private readonly language: LanguageContext;
|
|
38
|
+
private readonly peers: FormatOnTypePeers;
|
|
32
39
|
private enabled = false;
|
|
33
40
|
|
|
34
41
|
/* Raised by every change of the text, so an answer for an older text is told from the one for the text that is. */
|
|
@@ -36,8 +43,9 @@ export class FormatOnTypeFeature {
|
|
|
36
43
|
|
|
37
44
|
private controller = new AbortController();
|
|
38
45
|
|
|
39
|
-
constructor(language:
|
|
46
|
+
constructor(language: LanguageContext, peers: FormatOnTypePeers) {
|
|
40
47
|
this.language = language;
|
|
48
|
+
this.peers = peers;
|
|
41
49
|
const off = language.editor.onTextChange((change) => this.typed(change));
|
|
42
50
|
|
|
43
51
|
language.onDispose(() => {
|
|
@@ -50,7 +58,6 @@ export class FormatOnTypeFeature {
|
|
|
50
58
|
return this.enabled;
|
|
51
59
|
}
|
|
52
60
|
|
|
53
|
-
/* Whether the server of this document formats on type and the service can ask it. */
|
|
54
61
|
get supported(): boolean {
|
|
55
62
|
const { uri } = this.language;
|
|
56
63
|
|
|
@@ -65,7 +72,6 @@ export class FormatOnTypeFeature {
|
|
|
65
72
|
}
|
|
66
73
|
}
|
|
67
74
|
|
|
68
|
-
/* The characters that ask the server, the first one and the more. */
|
|
69
75
|
triggerCharacters(): readonly string[] {
|
|
70
76
|
const options = this.language.service.providerOptions(METHOD, this.language.uri);
|
|
71
77
|
|
|
@@ -82,7 +88,8 @@ export class FormatOnTypeFeature {
|
|
|
82
88
|
return;
|
|
83
89
|
}
|
|
84
90
|
|
|
85
|
-
const { editor
|
|
91
|
+
const { editor } = this.language;
|
|
92
|
+
const { snippets } = this.peers;
|
|
86
93
|
const { text } = change.changes[0]!;
|
|
87
94
|
const typed = LINE_BREAK.test(text) ? '\n' : Array.from(text).length === 1 ? text : (DEDENTED.exec(text)?.[1] ?? null);
|
|
88
95
|
|
package/src/highlights.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { EditorHighlight, EditorHighlightKind, EditorPosition, EditorRange } from '@adecore/editor';
|
|
2
2
|
import type { DocumentHighlight } from '@adecore/lsp';
|
|
3
3
|
import { isIdentifierCharacter } from './completion-model.ts';
|
|
4
|
-
import { comparePositions, rangeHolds } from './diagnostics-model.ts';
|
|
5
|
-
import type { EditorLanguage } from './editor-language.ts';
|
|
6
4
|
import { KEY_PRIORITY } from './key-priority.ts';
|
|
5
|
+
import type { LanguageContext } from './language-context.ts';
|
|
6
|
+
import { comparePositions, rangeHolds } from './positions.ts';
|
|
7
7
|
import { Refresher } from './refresher.ts';
|
|
8
8
|
import { isShortcut } from './shortcut-keys.ts';
|
|
9
9
|
import { realTimers, type Timers } from './timers.ts';
|
|
@@ -13,7 +13,7 @@ const PAUSE_MS = 150;
|
|
|
13
13
|
|
|
14
14
|
const KINDS: Record<number, EditorHighlightKind> = { 1: 'text', 2: 'read', 3: 'write' };
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
function editorHighlightsOf(highlights: readonly DocumentHighlight[]): EditorHighlight[] {
|
|
17
17
|
return highlights
|
|
18
18
|
.filter((highlight) => comparePositions(highlight.range.start, highlight.range.end) < 0)
|
|
19
19
|
.map((highlight) => ({ range: highlight.range, kind: KINDS[highlight.kind ?? 1] ?? 'text' }))
|
|
@@ -21,7 +21,7 @@ export function editorHighlightsOf(highlights: readonly DocumentHighlight[]): Ed
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/* The range before the caret when stepping back, or after it when stepping forward, wrapping round the document; null for no ranges. */
|
|
24
|
-
|
|
24
|
+
function neighborRange(ranges: readonly EditorRange[], from: EditorPosition, direction: 1 | -1): EditorRange | null {
|
|
25
25
|
if (ranges.length === 0) {
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
@@ -40,11 +40,11 @@ export function neighborRange(ranges: readonly EditorRange[], from: EditorPositi
|
|
|
40
40
|
* keys step through. They are asked for when the caret rests on a name and go with the next edit.
|
|
41
41
|
*/
|
|
42
42
|
export class HighlightsFeature {
|
|
43
|
-
private readonly language:
|
|
43
|
+
private readonly language: LanguageContext;
|
|
44
44
|
private readonly refresher: Refresher;
|
|
45
45
|
private current: readonly EditorHighlight[] = [];
|
|
46
46
|
|
|
47
|
-
constructor(language:
|
|
47
|
+
constructor(language: LanguageContext, timers: Timers = realTimers) {
|
|
48
48
|
this.language = language;
|
|
49
49
|
const { editor, uri } = language;
|
|
50
50
|
|
package/src/history.ts
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import type { EditorPosition, EditorTextChange } from '@adecore/editor';
|
|
2
2
|
import type { EditPlace } from './edit-locations.ts';
|
|
3
|
-
import type { EditorLanguage } from './editor-language.ts';
|
|
4
3
|
import { KEY_PRIORITY } from './key-priority.ts';
|
|
4
|
+
import type { LanguageContext } from './language-context.ts';
|
|
5
5
|
import type { Place } from './navigation-history.ts';
|
|
6
|
+
import type { PickFeature } from './pick.ts';
|
|
6
7
|
import { isShortcut } from './shortcut-keys.ts';
|
|
7
8
|
|
|
9
|
+
/* The sibling features HistoryFeature drives, which the editor language hands over. */
|
|
10
|
+
interface HistoryPeers {
|
|
11
|
+
readonly pick: Pick<PickFeature, 'locations'>;
|
|
12
|
+
}
|
|
13
|
+
|
|
8
14
|
/* Back, Forward and the list of recent locations over the history the whole project shares. */
|
|
9
15
|
export class HistoryFeature {
|
|
10
|
-
private readonly language:
|
|
16
|
+
private readonly language: LanguageContext;
|
|
17
|
+
private readonly peers: HistoryPeers;
|
|
11
18
|
private editing = false;
|
|
12
19
|
|
|
13
|
-
constructor(language:
|
|
20
|
+
constructor(language: LanguageContext, peers: HistoryPeers) {
|
|
14
21
|
this.language = language;
|
|
22
|
+
this.peers = peers;
|
|
15
23
|
|
|
16
24
|
const off = language.onKey((event) => {
|
|
17
25
|
if (isShortcut(this.language.shortcuts.historyBack, event)) {
|
|
@@ -83,7 +91,7 @@ export class HistoryFeature {
|
|
|
83
91
|
recent(): void {
|
|
84
92
|
const places = this.language.project.history.recent(this.language.place);
|
|
85
93
|
|
|
86
|
-
this.
|
|
94
|
+
this.peers.pick.locations(
|
|
87
95
|
places.map((place) => ({ uri: place.uri, range: { start: place.position, end: place.position } })),
|
|
88
96
|
this.language.editor.getCaret(),
|
|
89
97
|
this.language.project.i18n.t('editor:language.history.recent')
|
package/src/host-types.ts
CHANGED
|
@@ -3,17 +3,47 @@ import type { Keymap } from '@adecore/editor/keymap';
|
|
|
3
3
|
import type { WorkerRequestPort } from '@adecore/editor/worker-client';
|
|
4
4
|
import type { ServerMessage } from '@adecore/lsp';
|
|
5
5
|
import type { i18n } from 'i18next';
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
6
|
+
import type { ClipboardHost } from './clipboard-history.ts';
|
|
7
|
+
import type { NavigationHost } from './navigation-history.ts';
|
|
8
|
+
import type { PanelsHost } from './panel-size.ts';
|
|
9
|
+
import type { ProblemsHost } from './project-problems.ts';
|
|
10
|
+
import type { TemplatesHost } from './templates.ts';
|
|
11
11
|
|
|
12
12
|
export interface DiskText {
|
|
13
13
|
text: string;
|
|
14
14
|
mtime: number;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/* A file that changed without an editor of this project holding it: its new text waits as an unsaved draft. */
|
|
18
|
+
export interface StagedFile {
|
|
19
|
+
readonly path: string;
|
|
20
|
+
readonly disk: DiskText;
|
|
21
|
+
readonly text: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ProjectFiles {
|
|
25
|
+
/* The text of a file that is no open document, as a draft holds it or the machine has it; null when it is not a text file. */
|
|
26
|
+
read(path: string): Promise<DiskText | null>;
|
|
27
|
+
/* Puts the new texts in the files' drafts and tells the person. Nothing is written to disk. */
|
|
28
|
+
stage(files: readonly StagedFile[]): void;
|
|
29
|
+
/* Writes the new texts through the machine; the reason of the first file that could not be saved, or null. */
|
|
30
|
+
save(files: readonly StagedFile[]): Promise<string | null>;
|
|
31
|
+
/* Moves a file or folder on the machine, with what is open on it, and tells the servers it moved; the reason it could not, or null. Without `exists` an edit cannot tell whether the target is there, so refuse a target that is. With `overwrite` the target is there and is replaced, which needs `supportsOverwrite`; what is open on the replaced target is the host's to close or reload. */
|
|
32
|
+
rename(from: string, to: string, options?: { readonly overwrite: boolean }): Promise<string | null>;
|
|
33
|
+
/* Makes a file with its text, through the machine, and tells the servers it was made; the reason it could not, or null. Without it no edit creates a file. Without `exists`, refuse a file that is there. With `overwrite` the file is there and its content becomes `text`, which needs `supportsOverwrite`; an editor still open on it is set to `text` by the edit itself. */
|
|
34
|
+
create?(path: string, text: string, options?: { readonly overwrite: boolean }): Promise<string | null>;
|
|
35
|
+
/* Deletes a file, or a folder with what is in it when `recursive`, and tells the servers it is gone; the reason it could not, or null. Without it no edit deletes anything. */
|
|
36
|
+
delete?(path: string, options: { readonly recursive: boolean }): Promise<string | null>;
|
|
37
|
+
/* Whether `create` and `rename` take `overwrite`. Without it an edit that asks to overwrite a file is refused, since the file is there. */
|
|
38
|
+
readonly supportsOverwrite?: boolean;
|
|
39
|
+
/* Whether a draft or an open editor at the path, or under it for a folder, holds text that is not saved. A delete that would lose it is refused. */
|
|
40
|
+
isUnsaved?(path: string): boolean;
|
|
41
|
+
/* Whether anything is at the path, a file of any kind or a folder. Without it, an edit cannot tell whether something that is no text file exists. It may move or delete it and leave the outcome to the machine, and `ignoreIfNotExists` cannot be honored. */
|
|
42
|
+
exists?(path: string): Promise<boolean>;
|
|
43
|
+
/* Whether the path is a folder. Without it, deleting anything that is no text file needs `recursive`. */
|
|
44
|
+
isFolder?(path: string): Promise<boolean>;
|
|
45
|
+
}
|
|
46
|
+
|
|
17
47
|
export interface GitBlameCommit {
|
|
18
48
|
hash: string;
|
|
19
49
|
shortHash: string;
|
|
@@ -59,39 +89,28 @@ export interface SnippetVariableContext {
|
|
|
59
89
|
readonly path?: string;
|
|
60
90
|
}
|
|
61
91
|
|
|
62
|
-
|
|
92
|
+
/* What the editors of a project ask of the app that hosts them, in the part each feature reads. */
|
|
93
|
+
export interface SnippetsHost {
|
|
63
94
|
readonly snippetTransformWorker?: () => WorkerRequestPort;
|
|
95
|
+
/* Synchronous overrides; undefined delegates to built-ins or an editable unknown-variable placeholder. */
|
|
96
|
+
resolveSnippetVariable?(name: string, context: SnippetVariableContext): string | undefined;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface MessagesHost {
|
|
100
|
+
notify?(notification: EditorNotification): void;
|
|
101
|
+
/* A message of a server for a person, or a line for its log; without it the messages are not shown. */
|
|
102
|
+
onServerMessage?(message: ServerMessage): void;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface RenameHost {
|
|
106
|
+
suggestNames?(request: RenameSuggestionsRequest, signal: AbortSignal): Promise<readonly string[]>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface LanguageHost extends SnippetsHost, MessagesHost, RenameHost, NavigationHost, PanelsHost, ProblemsHost, TemplatesHost, ClipboardHost {
|
|
64
110
|
/* The instance the app hands `UIProvider`, which the features read their words from too; the default instance without one. */
|
|
65
111
|
readonly i18n?: i18n;
|
|
66
112
|
readonly folder?: string;
|
|
67
113
|
readonly files?: ProjectFiles;
|
|
68
114
|
readonly apple?: boolean;
|
|
69
115
|
readonly keymap?: Keymap;
|
|
70
|
-
/* What Paste from History lists. A new `ClipboardHistory` that lives as long as the project without one; pass one to choose its size or to keep its entries. */
|
|
71
|
-
readonly clipboard?: ClipboardHistory;
|
|
72
|
-
/* What templates the editors of the project know. A registry of the built-in ones that lives as long as the project without one. */
|
|
73
|
-
readonly templates?: TemplateRegistry;
|
|
74
|
-
/* Save as Live Template: the host opens its own form with this draft. Without it the command does nothing. */
|
|
75
|
-
saveAsLiveTemplate?(draft: LiveTemplateDraft): void;
|
|
76
|
-
/* The last row of the template lists, "Configure live templates…"; the row is left out without it. */
|
|
77
|
-
openTemplateSettings?(): void;
|
|
78
|
-
/* How many places Last Edit Location and Next Edit Location remember; 150 without one. */
|
|
79
|
-
readonly editHistoryLimit?: number;
|
|
80
|
-
/* The height in pixels of the list-and-preview area of the peek and the call hierarchy, so a person's drag outlives the panel; 180 without one. */
|
|
81
|
-
readonly panelBodyHeight?: number;
|
|
82
|
-
/* A person finished resizing a peek or call hierarchy panel; the height is already within what the editor allows. */
|
|
83
|
-
onPanelResize?(height: number): void;
|
|
84
|
-
/* Where `project.problems` reads its reports, such as a machine that also reports files no editor here holds; the service's diagnostics without one. */
|
|
85
|
-
readonly problemSource?: ProblemSource;
|
|
86
|
-
openPlace?(place: Place): void;
|
|
87
|
-
/* Opens a web address outside the editor, from a link in the text or a server; a new browser window without it. */
|
|
88
|
-
openExternal?(url: string): void;
|
|
89
|
-
pathOfUri?(uri: string): string | null;
|
|
90
|
-
serverNames?(uri: string): readonly string[];
|
|
91
|
-
notify?(notification: EditorNotification): void;
|
|
92
|
-
/* A message of a server for a person, or a line for its log; without it the messages are not shown. */
|
|
93
|
-
onServerMessage?(message: ServerMessage): void;
|
|
94
|
-
/* Synchronous overrides; undefined delegates to built-ins or an editable unknown-variable placeholder. */
|
|
95
|
-
resolveSnippetVariable?(name: string, context: SnippetVariableContext): string | undefined;
|
|
96
|
-
suggestNames?(request: RenameSuggestionsRequest, signal: AbortSignal): Promise<readonly string[]>;
|
|
97
116
|
}
|
package/src/hover-content.ts
CHANGED
|
@@ -62,7 +62,6 @@ export function hoverTextOf(hover: Hover): HoverText {
|
|
|
62
62
|
return contents.kind === 'plaintext' ? { signatures: [], markdown: escapeMarkdown(contents.value).trim() } : splitSignatures(contents.value);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
/* Plain text as markdown that reads the same, its markdown characters escaped. */
|
|
66
65
|
export function escapeMarkdown(text: string): string {
|
|
67
66
|
return text.replace(/([\\`*_{}[\]()#+\-.!|<>~])/g, '\\$1');
|
|
68
67
|
}
|
package/src/hover.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { EditorHover, EditorPosition, EditorRange } from '@adecore/editor';
|
|
2
|
-
import {
|
|
3
|
-
import type { EditorLanguage } from './editor-language.ts';
|
|
2
|
+
import { type Problem } from './diagnostics-model.ts';
|
|
4
3
|
import { hoverTextOf, isEmptyHover, locationsOf, type HoverText } from './hover-content.ts';
|
|
5
4
|
import { KEY_PRIORITY } from './key-priority.ts';
|
|
5
|
+
import type { LanguageContext } from './language-context.ts';
|
|
6
6
|
import { lineTextOf } from './line-text.ts';
|
|
7
7
|
import type { HoverInfo } from './popups.ts';
|
|
8
|
+
import { rangeHolds } from './positions.ts';
|
|
8
9
|
import { wordRangeAt } from './rename-model.ts';
|
|
9
10
|
import { isShortcut } from './shortcut-keys.ts';
|
|
10
11
|
import { realTimers, type Timers } from './timers.ts';
|
|
@@ -23,13 +24,20 @@ export interface HoverSettings {
|
|
|
23
24
|
readonly referenceCount?: boolean;
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
/* The sibling features HoverFeature drives, which the editor language hands over. */
|
|
28
|
+
interface HoverPeers {
|
|
29
|
+
readonly diagnostics: { at(position: EditorPosition): Problem[] };
|
|
30
|
+
readonly inlayHints: { showTooltipAt(position: EditorPosition): Promise<boolean> };
|
|
31
|
+
}
|
|
32
|
+
|
|
26
33
|
/*
|
|
27
34
|
* The card under a character the pointer rests on: the problems there, and what the language servers
|
|
28
35
|
* say about the symbol. It opens after the pointer has stayed a moment, stays while the pointer is on
|
|
29
36
|
* the word or on the card itself, and goes when the text, the scroll or the focus moves.
|
|
30
37
|
*/
|
|
31
38
|
export class HoverFeature {
|
|
32
|
-
private readonly language:
|
|
39
|
+
private readonly language: LanguageContext;
|
|
40
|
+
private readonly peers: HoverPeers;
|
|
33
41
|
private readonly timers: Timers;
|
|
34
42
|
|
|
35
43
|
/* The counts asked for since the text last changed, by the symbol's position, so moving back to a name does not ask again. */
|
|
@@ -52,8 +60,9 @@ export class HoverFeature {
|
|
|
52
60
|
/* The card is being read: an explanation runs in it or is shown, so the pointer going elsewhere neither closes nor replaces it. */
|
|
53
61
|
private held = false;
|
|
54
62
|
|
|
55
|
-
constructor(language:
|
|
63
|
+
constructor(language: LanguageContext, peers: HoverPeers, timers: Timers = realTimers) {
|
|
56
64
|
this.language = language;
|
|
65
|
+
this.peers = peers;
|
|
57
66
|
this.timers = timers;
|
|
58
67
|
const { editor } = language;
|
|
59
68
|
|
|
@@ -87,7 +96,7 @@ export class HoverFeature {
|
|
|
87
96
|
return true;
|
|
88
97
|
}
|
|
89
98
|
|
|
90
|
-
if (event.key === 'Escape' && this.language.popups.
|
|
99
|
+
if (event.key === 'Escape' && this.language.popups.slot('hover').get() !== null && this.language.popups.slot('callHierarchy').get() === null) {
|
|
91
100
|
this.hide();
|
|
92
101
|
|
|
93
102
|
return true;
|
|
@@ -134,7 +143,7 @@ export class HoverFeature {
|
|
|
134
143
|
|
|
135
144
|
/* The problems at a position as a card, at once; what the servers say about the symbol is left for the pointer and Quick Info. */
|
|
136
145
|
showProblemsAt(position: EditorPosition): boolean {
|
|
137
|
-
const problems = this.
|
|
146
|
+
const problems = this.peers.diagnostics.at(position);
|
|
138
147
|
|
|
139
148
|
if (problems.length === 0) {
|
|
140
149
|
return false;
|
|
@@ -182,8 +191,8 @@ export class HoverFeature {
|
|
|
182
191
|
this.timers.clear(this.countTimer);
|
|
183
192
|
this.inCard = false;
|
|
184
193
|
|
|
185
|
-
if (this.language.popups.
|
|
186
|
-
this.language.popups.
|
|
194
|
+
if (this.language.popups.slot('hover').get() !== null) {
|
|
195
|
+
this.language.popups.slot('hover').set(null);
|
|
187
196
|
}
|
|
188
197
|
}
|
|
189
198
|
|
|
@@ -201,7 +210,7 @@ export class HoverFeature {
|
|
|
201
210
|
return;
|
|
202
211
|
}
|
|
203
212
|
|
|
204
|
-
const shown = this.language.popups.
|
|
213
|
+
const shown = this.language.popups.slot('hover').get();
|
|
205
214
|
|
|
206
215
|
if (shown !== null && rangeHolds(shown.subject, hover.position)) {
|
|
207
216
|
this.timers.clear(this.hideTimer);
|
|
@@ -217,7 +226,7 @@ export class HoverFeature {
|
|
|
217
226
|
private scheduleHide(): void {
|
|
218
227
|
this.timers.clear(this.hideTimer);
|
|
219
228
|
|
|
220
|
-
if (this.language.popups.
|
|
229
|
+
if (this.language.popups.slot('hover').get() === null || this.inCard || this.held) {
|
|
221
230
|
return;
|
|
222
231
|
}
|
|
223
232
|
|
|
@@ -268,7 +277,7 @@ export class HoverFeature {
|
|
|
268
277
|
}
|
|
269
278
|
|
|
270
279
|
private async show(position: EditorPosition, request: number, pinned: boolean): Promise<void> {
|
|
271
|
-
const problems = this.
|
|
280
|
+
const problems = this.peers.diagnostics.at(position);
|
|
272
281
|
this.lookup?.abort();
|
|
273
282
|
const controller = new AbortController();
|
|
274
283
|
this.lookup = controller;
|
|
@@ -281,7 +290,7 @@ export class HoverFeature {
|
|
|
281
290
|
if (problems.length === 0 && info === null) {
|
|
282
291
|
this.hide();
|
|
283
292
|
|
|
284
|
-
if (pinned && (await this.
|
|
293
|
+
if (pinned && (await this.peers.inlayHints.showTooltipAt(position))) {
|
|
285
294
|
this.pinned = true;
|
|
286
295
|
|
|
287
296
|
return;
|
|
@@ -306,14 +315,12 @@ export class HoverFeature {
|
|
|
306
315
|
const subject = range ?? { start: position, end: position };
|
|
307
316
|
this.timers.clear(this.hideTimer);
|
|
308
317
|
|
|
309
|
-
this.language.popups.
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
info
|
|
316
|
-
}
|
|
318
|
+
this.language.popups.slot('hover').set({
|
|
319
|
+
anchor: subject.start.line === position.line ? subject.start : position,
|
|
320
|
+
position,
|
|
321
|
+
subject,
|
|
322
|
+
problems,
|
|
323
|
+
info
|
|
317
324
|
});
|
|
318
325
|
}
|
|
319
326
|
|
|
@@ -351,10 +358,10 @@ export class HoverFeature {
|
|
|
351
358
|
}
|
|
352
359
|
|
|
353
360
|
private showCount(count: number, request: number): void {
|
|
354
|
-
const shown = this.language.popups.
|
|
361
|
+
const shown = this.language.popups.slot('hover').get();
|
|
355
362
|
|
|
356
363
|
if (request === this.request && shown?.info != null) {
|
|
357
|
-
this.language.popups.
|
|
364
|
+
this.language.popups.slot('hover').set({ ...shown, info: { ...shown.info, references: count } });
|
|
358
365
|
}
|
|
359
366
|
}
|
|
360
367
|
|
package/src/index.ts
CHANGED
|
@@ -3,11 +3,19 @@ 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 {
|
|
6
|
+
export type { NavigationHost } from './navigation-history.ts';
|
|
7
|
+
export type { PanelsHost } from './panel-size.ts';
|
|
8
|
+
export type { ProblemsHost } from './project-problems.ts';
|
|
9
|
+
export type { TemplatesHost } from './templates.ts';
|
|
10
|
+
export type { ClipboardHost } from './clipboard-history.ts';
|
|
11
|
+
export type { AcquireOptions, LanguageDocumentHandle, LanguageServiceFactory } from './project-language.ts';
|
|
7
12
|
|
|
8
13
|
export type {
|
|
9
14
|
SnippetVariableContext,
|
|
10
15
|
LanguageHost,
|
|
16
|
+
SnippetsHost,
|
|
17
|
+
MessagesHost,
|
|
18
|
+
RenameHost,
|
|
11
19
|
DiskText,
|
|
12
20
|
GitBlameCommit,
|
|
13
21
|
GitBlameResult,
|
|
@@ -26,7 +34,13 @@ export { type RenderedDocsFeature } from './rendered-docs.ts';
|
|
|
26
34
|
export { type DocumentLinksFeature } from './document-links.ts';
|
|
27
35
|
export { type DocumentColorsFeature } from './document-colors.ts';
|
|
28
36
|
export { type LinkedEditingFeature } from './linked-editing.ts';
|
|
29
|
-
export {
|
|
37
|
+
export {
|
|
38
|
+
firstWord,
|
|
39
|
+
type InlineCompletionFeature,
|
|
40
|
+
type InlineSuggestion,
|
|
41
|
+
type InlineSuggestionRequest,
|
|
42
|
+
type InlineSuggestionSource
|
|
43
|
+
} from './inline-completion.ts';
|
|
30
44
|
export type { RenderedDocEntry, RenderedDocsSettings } from './rendered-docs.ts';
|
|
31
45
|
export type { DocTagEntry, DocTagSection, ParsedDocComment } from './doc-comment-model.ts';
|
|
32
46
|
export { EditorRenderingProvider } from './rendering.tsx';
|
|
@@ -37,19 +51,18 @@ export type { ChangeReviewProps } from './ChangeReview.tsx';
|
|
|
37
51
|
export { ProjectProblems, serviceProblems, countsOf } from './project-problems.ts';
|
|
38
52
|
export type { ProblemFile, ProblemRow, ProblemReport, ProblemSource } from './project-problems.ts';
|
|
39
53
|
export { applyWorkspaceEdit, supportedResourceOperations } from './workspace-edit.ts';
|
|
40
|
-
export type {
|
|
54
|
+
export type { WorkspaceEditHost } from './workspace-edit.ts';
|
|
55
|
+
export type { ProjectFiles, StagedFile } from './host-types.ts';
|
|
41
56
|
export { useProblemCounts } from './use-problem-counts.ts';
|
|
42
|
-
export type { ProblemCounts } from './diagnostics.ts';
|
|
57
|
+
export type { ProblemCounts } from './diagnostics-model.ts';
|
|
43
58
|
export type { BlameSource, CodeVisionSettings } from './code-vision.ts';
|
|
44
59
|
export type { HoverSettings } from './hover.ts';
|
|
45
60
|
|
|
61
|
+
export { Popups, PopupSlot, type PopupViews } from './popups.ts';
|
|
46
62
|
export type {
|
|
47
|
-
PopupState,
|
|
48
|
-
PopupStore,
|
|
49
63
|
HoverInfo,
|
|
50
64
|
HoverView,
|
|
51
65
|
CompletionView,
|
|
52
|
-
CompletionDocs,
|
|
53
66
|
CompletionRow,
|
|
54
67
|
SignatureView,
|
|
55
68
|
RenameView,
|
|
@@ -65,6 +78,7 @@ export type {
|
|
|
65
78
|
AuthorsView,
|
|
66
79
|
WrapView
|
|
67
80
|
} from './popups.ts';
|
|
81
|
+
export type { CompletionDocs } from './completion-model.ts';
|
|
68
82
|
export { type MarkupFeature } from './markup.ts';
|
|
69
83
|
export { type SurroundFeature } from './surround.ts';
|
|
70
84
|
export type { MarkupSettings } from './markup.ts';
|
|
@@ -76,30 +90,27 @@ export type { Place } from './navigation-history.ts';
|
|
|
76
90
|
export { EditLocations, type EditPlace } from './edit-locations.ts';
|
|
77
91
|
export { ClipboardHistory, type ClipboardEntry, type ClipboardHistoryOptions } from './clipboard-history.ts';
|
|
78
92
|
export { type PasteHistoryFeature } from './paste-history.ts';
|
|
93
|
+
export { type TemplatesFeature } from './live-templates.ts';
|
|
79
94
|
export {
|
|
80
95
|
TemplateRegistry,
|
|
81
96
|
checkTemplate,
|
|
82
97
|
BUILT_IN_LIVE_TEMPLATES,
|
|
83
98
|
BUILT_IN_POSTFIX_TEMPLATES,
|
|
84
|
-
type TemplatesFeature,
|
|
85
|
-
type LiveTemplate,
|
|
86
|
-
type PostfixTemplate,
|
|
87
99
|
type LiveTemplateDraft,
|
|
88
|
-
type TemplateLanguage,
|
|
89
|
-
type TemplatePlace,
|
|
90
100
|
type TemplateSettings,
|
|
91
101
|
type TemplateRegistryOptions,
|
|
92
102
|
type TemplateUpdate
|
|
93
103
|
} from './templates.ts';
|
|
104
|
+
export { type LiveTemplate, type PostfixTemplate, type TemplateLanguage, type TemplatePlace } from './template-types.ts';
|
|
94
105
|
export { openingPlace, viewStates, followViewStates, viewStateKey, forgetMovesFrom } from './view-state.ts';
|
|
95
106
|
export type { ViewState, RevealLineRequest } from './view-state.ts';
|
|
96
|
-
export {
|
|
107
|
+
export { shikiLanguageOf, shikiLanguageOfPath } from './language-ids.ts';
|
|
97
108
|
export { AttributionCard } from './AttributionCard.tsx';
|
|
98
109
|
export type { AttributionCardProps } from './AttributionCard.tsx';
|
|
99
110
|
export { ReviewGroup, joinReviewGroup } from './review-group.ts';
|
|
100
111
|
export type { ReviewMember } from './review-group.ts';
|
|
101
112
|
export { DiffView } from './DiffView.tsx';
|
|
102
|
-
export type { DiffSource, DiffViewProps } from './
|
|
113
|
+
export type { DiffSource, DiffViewProps } from './diff-view-props.ts';
|
|
103
114
|
export type { DiffLimits } from './diff-expansion.ts';
|
|
104
115
|
export { diffSyntaxDocument } from './diff-syntax.ts';
|
|
105
116
|
export type { DiffSourceSide, DiffSourceTokens, DiffSyntaxSources } from './diff-syntax.ts';
|
package/src/inlay-hints.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Editor, EditorInlayClick, EditorInlayHint, EditorPosition, EditorRange } from '@adecore/editor';
|
|
2
2
|
import type { Command, InlayHint, InlayHintLabelPart, Location, MarkupContent, TextEdit } from '@adecore/lsp';
|
|
3
3
|
import { followModKey } from './definition-link.ts';
|
|
4
|
-
import { comparePositions } from './diagnostics-model.ts';
|
|
5
|
-
import type { EditorLanguage } from './editor-language.ts';
|
|
6
4
|
import { messageOf } from './error-message.ts';
|
|
7
5
|
import { hoverTextOf, isEmptyHover, type HoverText } from './hover-content.ts';
|
|
8
6
|
import { SHOW_DELAY_MS } from './hover.ts';
|
|
7
|
+
import type { LanguageContext } from './language-context.ts';
|
|
9
8
|
import { lineTextOf } from './line-text.ts';
|
|
9
|
+
import { comparePositions } from './positions.ts';
|
|
10
10
|
import { Refresher } from './refresher.ts';
|
|
11
11
|
import { realTimers, type Timers } from './timers.ts';
|
|
12
12
|
|
|
@@ -21,16 +21,16 @@ const DOUBLE_PRESS_MS = 500;
|
|
|
21
21
|
/* Lines asked for above and below what is in view, so a little scrolling stays inside what is already drawn. */
|
|
22
22
|
const MARGIN_LINES = 60;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
function hintLabelOf(hint: InlayHint): string {
|
|
25
25
|
return typeof hint.label === 'string' ? hint.label : hint.label.map((part) => part.value).join('');
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
function drawableHints(hints: readonly InlayHint[]): InlayHint[] {
|
|
29
29
|
return hints.filter((hint) => hintLabelOf(hint) !== '').sort((left, right) => comparePositions(left.position, right.position));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/* A hint as the editor draws it: a label with parts keeps them apart so each can be pointed at. */
|
|
33
|
-
|
|
33
|
+
function editorHintOf(hint: InlayHint, id: string): EditorInlayHint {
|
|
34
34
|
return {
|
|
35
35
|
id,
|
|
36
36
|
position: hint.position,
|
|
@@ -53,7 +53,7 @@ export function covers(asked: EditorRange, visible: EditorRange): boolean {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/* The words of a tooltip: plain text is escaped so it reads as typed, Markdown goes through the hover card's own rendering. */
|
|
56
|
-
|
|
56
|
+
function tooltipTextOf(tooltip: string | MarkupContent | undefined): HoverText | null {
|
|
57
57
|
if (tooltip === undefined) {
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
@@ -80,7 +80,7 @@ export function tooltipOf(hint: InlayHint, index: number | null): HoverText | nu
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/* Whether a server could still say more about the hint: nothing in it gives a tooltip, a place or a command yet. */
|
|
83
|
-
|
|
83
|
+
function lacksInfo(hint: InlayHint, index: number | null): boolean {
|
|
84
84
|
if (hint.tooltip !== undefined) {
|
|
85
85
|
return false;
|
|
86
86
|
}
|
|
@@ -91,7 +91,7 @@ export function lacksInfo(hint: InlayHint, index: number | null): boolean {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/* Whether the edits fit the text as it is now: positions inside it, each range in order, none overlapping the next. */
|
|
94
|
-
|
|
94
|
+
function editsFit(editor: Editor, edits: readonly TextEdit[]): boolean {
|
|
95
95
|
const end = editor.positionAt(Number.MAX_SAFE_INTEGER);
|
|
96
96
|
|
|
97
97
|
const inside = (position: EditorPosition): boolean =>
|
|
@@ -124,7 +124,7 @@ type Action =
|
|
|
124
124
|
| { readonly kind: 'insert'; readonly edits: TextEdit[] };
|
|
125
125
|
|
|
126
126
|
/* 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. */
|
|
127
|
-
|
|
127
|
+
function actionOf(hint: InlayHint, click: Pick<EditorInlayClick, 'part' | 'mod' | 'clicks'>): Action | null {
|
|
128
128
|
if (click.clicks === 2) {
|
|
129
129
|
return hint.textEdits !== undefined && hint.textEdits.length > 0 ? { kind: 'insert', edits: hint.textEdits } : null;
|
|
130
130
|
}
|
|
@@ -148,6 +148,11 @@ interface Entry {
|
|
|
148
148
|
answered: boolean;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
/* The sibling features InlayHintsFeature drives, which the editor language hands over. */
|
|
152
|
+
interface InlayHintsPeers {
|
|
153
|
+
readonly hover: { hide(): void; release(): void; showText(position: EditorPosition, text: HoverText): void };
|
|
154
|
+
}
|
|
155
|
+
|
|
151
156
|
/*
|
|
152
157
|
* Types and parameter names the servers infer, asked for the lines in view and a margin around them. The
|
|
153
158
|
* last ones stay until the answer comes, so nothing blinks while typing.
|
|
@@ -158,11 +163,11 @@ interface Entry {
|
|
|
158
163
|
* shows the tooltip of a hint that sits there.
|
|
159
164
|
*/
|
|
160
165
|
export class InlayHintsFeature {
|
|
161
|
-
private readonly language:
|
|
166
|
+
private readonly language: LanguageContext;
|
|
167
|
+
private readonly peers: InlayHintsPeers;
|
|
162
168
|
private readonly timers: Timers;
|
|
163
169
|
private readonly refresher: Refresher;
|
|
164
170
|
|
|
165
|
-
/* The lines the hints on screen were asked for. */
|
|
166
171
|
private asked: EditorRange | null = null;
|
|
167
172
|
|
|
168
173
|
private readonly entries = new Map<string, Entry>();
|
|
@@ -185,8 +190,9 @@ export class InlayHintsFeature {
|
|
|
185
190
|
/* Counts what the pointer does, so a tooltip that was waited for is dropped once the pointer has moved on. */
|
|
186
191
|
private request = 0;
|
|
187
192
|
|
|
188
|
-
constructor(language:
|
|
193
|
+
constructor(language: LanguageContext, peers: InlayHintsPeers, timers: Timers = realTimers) {
|
|
189
194
|
this.language = language;
|
|
195
|
+
this.peers = peers;
|
|
190
196
|
this.timers = timers;
|
|
191
197
|
const { editor, project, uri } = language;
|
|
192
198
|
|
|
@@ -297,7 +303,7 @@ export class InlayHintsFeature {
|
|
|
297
303
|
|
|
298
304
|
if (target === null) {
|
|
299
305
|
if (this.cardOpen()) {
|
|
300
|
-
this.
|
|
306
|
+
this.peers.hover.release();
|
|
301
307
|
}
|
|
302
308
|
|
|
303
309
|
return;
|
|
@@ -319,13 +325,13 @@ export class InlayHintsFeature {
|
|
|
319
325
|
this.updateLink();
|
|
320
326
|
|
|
321
327
|
if (this.cardOpen()) {
|
|
322
|
-
this.
|
|
328
|
+
this.peers.hover.hide();
|
|
323
329
|
}
|
|
324
330
|
}
|
|
325
331
|
|
|
326
332
|
/* Whether the card up is a tooltip, which is the only kind that has no footer. */
|
|
327
333
|
private cardOpen(): boolean {
|
|
328
|
-
return this.language.popups.
|
|
334
|
+
return this.language.popups.slot('hover').get()?.info?.plain === true;
|
|
329
335
|
}
|
|
330
336
|
|
|
331
337
|
/* The card for a hint or part, once the server has said what it can. Says whether it opened. */
|
|
@@ -349,13 +355,13 @@ export class InlayHintsFeature {
|
|
|
349
355
|
|
|
350
356
|
if (text === null) {
|
|
351
357
|
if (this.cardOpen()) {
|
|
352
|
-
this.
|
|
358
|
+
this.peers.hover.hide();
|
|
353
359
|
}
|
|
354
360
|
|
|
355
361
|
return false;
|
|
356
362
|
}
|
|
357
363
|
|
|
358
|
-
this.
|
|
364
|
+
this.peers.hover.showText(entry.hint.position, text);
|
|
359
365
|
|
|
360
366
|
return true;
|
|
361
367
|
}
|