@adecore/editor-react 0.31.11 → 0.32.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 (137) hide show
  1. package/dist/AnchoredPopup.js +73 -19
  2. package/dist/AttributionCard.js +162 -4
  3. package/dist/BaselineStatus.js +62 -8
  4. package/dist/CallHierarchyPanel.js +977 -60
  5. package/dist/ChangeReview.js +76 -25
  6. package/dist/CodeAuthorsCard.js +314 -14
  7. package/dist/CompletionPopup.js +490 -83
  8. package/dist/DiffView.js +548 -181
  9. package/dist/EditorContextMenu.js +352 -34
  10. package/dist/EditorView.js +276 -99
  11. package/dist/FindReplace.js +525 -67
  12. package/dist/HoverCard.js +378 -38
  13. package/dist/HoverSections.js +367 -56
  14. package/dist/LanguagePopups.js +95 -34
  15. package/dist/Markdown.js +41 -6
  16. package/dist/PanelResizeHandle.js +199 -66
  17. package/dist/PathText.js +49 -7
  18. package/dist/PeekPanel.js +675 -72
  19. package/dist/PickPopup.js +304 -34
  20. package/dist/RenameCard.js +679 -85
  21. package/dist/RenderedDocs.js +329 -58
  22. package/dist/SignatureCard.js +91 -7
  23. package/dist/SplitDiffView.js +344 -254
  24. package/dist/SymbolPicker.js +440 -85
  25. package/dist/call-hierarchy-model.js +102 -68
  26. package/dist/call-hierarchy.js +458 -359
  27. package/dist/code-actions-model.js +88 -76
  28. package/dist/code-actions.js +372 -283
  29. package/dist/code-authors.js +64 -55
  30. package/dist/code-vision-model.js +134 -127
  31. package/dist/code-vision.js +224 -206
  32. package/dist/completion-call.js +94 -67
  33. package/dist/completion-model.js +334 -244
  34. package/dist/completion.js +840 -649
  35. package/dist/conflict-model.js +35 -29
  36. package/dist/context-menu-rows.js +42 -17
  37. package/dist/context-menu.js +64 -46
  38. package/dist/definition-link.js +88 -85
  39. package/dist/diagnostics-model.js +74 -55
  40. package/dist/diagnostics.js +121 -100
  41. package/dist/diff-expansion.js +38 -35
  42. package/dist/diff-overlays.js +144 -22
  43. package/dist/diff-syntax.js +65 -42
  44. package/dist/diff-wordmarks.js +26 -23
  45. package/dist/doc-comment-model.js +265 -216
  46. package/dist/editor-language.js +177 -152
  47. package/dist/error-message.js +2 -2
  48. package/dist/find-query.js +49 -36
  49. package/dist/folding.js +81 -62
  50. package/dist/format-on-type.js +86 -67
  51. package/dist/highlight-layers.js +19 -20
  52. package/dist/highlights.js +105 -83
  53. package/dist/history.js +44 -38
  54. package/dist/holder.js +18 -18
  55. package/dist/host-types.js +1 -1
  56. package/dist/hover-content.js +167 -129
  57. package/dist/hover.js +285 -245
  58. package/dist/index.js +10 -10
  59. package/dist/inlay-hints.js +369 -324
  60. package/dist/key-priority.js +34 -31
  61. package/dist/language-ids.js +45 -42
  62. package/dist/line-edits.js +74 -28
  63. package/dist/line-text.js +18 -3
  64. package/dist/locales/en.json +38 -38
  65. package/dist/locales/nl.json +41 -41
  66. package/dist/models.js +1 -1
  67. package/dist/navigation-history.js +40 -41
  68. package/dist/navigation.js +141 -123
  69. package/dist/panel-size.js +8 -8
  70. package/dist/patch-decorations.js +236 -160
  71. package/dist/patch-layout.js +331 -262
  72. package/dist/paths.js +3 -3
  73. package/dist/peek-model.js +86 -69
  74. package/dist/peek.js +254 -192
  75. package/dist/pick.js +164 -157
  76. package/dist/popup-focus.js +5 -5
  77. package/dist/popup-placement.js +36 -21
  78. package/dist/popups.js +13 -13
  79. package/dist/project-language.js +228 -211
  80. package/dist/project-problems.js +81 -69
  81. package/dist/proposal-model.js +163 -126
  82. package/dist/recent-choices.js +25 -25
  83. package/dist/refresher.js +44 -49
  84. package/dist/rename-model.js +113 -113
  85. package/dist/rename.js +321 -233
  86. package/dist/rendered-docs.d.ts +4 -2
  87. package/dist/rendered-docs.js +384 -318
  88. package/dist/rendering-context.js +5 -3
  89. package/dist/rendering.js +22 -4
  90. package/dist/review-group.js +42 -39
  91. package/dist/row-host.d.ts +4 -2
  92. package/dist/row-host.js +90 -78
  93. package/dist/selection-ranges.js +21 -17
  94. package/dist/semantic-delta.js +22 -19
  95. package/dist/semantic-model.js +86 -73
  96. package/dist/semantic-tokens.js +201 -162
  97. package/dist/shortcut-keys.js +16 -10
  98. package/dist/signature-model.js +34 -28
  99. package/dist/signature.js +177 -129
  100. package/dist/snippet-field-transforms.js +118 -106
  101. package/dist/snippet-indent.js +48 -43
  102. package/dist/snippet-range-order.js +11 -11
  103. package/dist/snippet-session.js +703 -667
  104. package/dist/snippet-transform-client.js +59 -59
  105. package/dist/snippet-transform-format.js +285 -263
  106. package/dist/snippet-transform-protocol.js +1 -1
  107. package/dist/snippet-transform-queue.js +163 -153
  108. package/dist/snippet-transform-worker.js +42 -35
  109. package/dist/snippet-variable-names.js +1 -36
  110. package/dist/snippet-variables.js +53 -63
  111. package/dist/snippet.js +477 -405
  112. package/dist/split-alignment.js +47 -35
  113. package/dist/split-scroll.js +42 -40
  114. package/dist/symbol-links.js +33 -25
  115. package/dist/symbol-picker-model.js +126 -116
  116. package/dist/symbol-picker.js +98 -59
  117. package/dist/symbols.js +117 -88
  118. package/dist/testing.js +248 -165
  119. package/dist/timers.js +35 -30
  120. package/dist/use-panel-body.js +49 -8
  121. package/dist/use-problem-counts.js +29 -15
  122. package/dist/view-state.js +54 -33
  123. package/dist/word-diff.js +18 -18
  124. package/dist/workspace-edit.js +300 -249
  125. package/package.json +6 -6
  126. package/src/CallHierarchyPanel.tsx +2 -2
  127. package/src/DiffView.tsx +3 -3
  128. package/src/FindReplace.tsx +2 -2
  129. package/src/LanguagePopups.tsx +2 -0
  130. package/src/PeekPanel.tsx +3 -3
  131. package/src/RenderedDocs.tsx +9 -10
  132. package/src/SymbolPicker.tsx +2 -2
  133. package/src/diff-overlays.tsx +6 -4
  134. package/src/locales/en.json +38 -38
  135. package/src/locales/nl.json +41 -41
  136. package/src/rendered-docs.ts +14 -3
  137. package/src/row-host.ts +14 -3
@@ -2,32 +2,32 @@
2
2
  "language": {
3
3
  "hover": {
4
4
  "quickFix": "Quick fix…",
5
- "quickFixNone": "Deze language server biedt geen quick fixes",
5
+ "quickFixNone": "Geen quick fixes",
6
6
  "definition": "Ga naar definitie",
7
7
  "references_one": "{{formatted}} referentie",
8
8
  "references_other": "{{formatted}} referenties",
9
9
  "line": "Regel {{line}}",
10
- "none": "Geen informatie voor deze plek"
10
+ "none": "Hier geen informatie"
11
11
  },
12
12
  "inlay": {
13
- "failed": "De actie van de hint is mislukt: {{message}}"
13
+ "failed": "Kon de hintactie niet uitvoeren: {{message}}"
14
14
  },
15
15
  "edit": {
16
- "staged_one": "{{count}} bestand gewijzigd en nog niet opgeslagen",
17
- "staged_other": "{{count}} bestanden gewijzigd en nog niet opgeslagen",
16
+ "staged_one": "{{count}} niet-opgeslagen bestand",
17
+ "staged_other": "{{count}} niet-opgeslagen bestanden",
18
18
  "stagedMore": "{{names}} en nog {{count}}",
19
19
  "saveAll": "Alles opslaan",
20
- "notSaved": "{{name}} kon niet worden opgeslagen"
20
+ "notSaved": "Kon {{name}} niet opslaan"
21
21
  },
22
22
  "actions": {
23
23
  "show": "Toon code actions",
24
24
  "none": "Geen code actions hier",
25
- "unavailable": "Geen language server biedt hier code actions",
26
- "organized": "De imports zijn al georganiseerd",
27
- "noFormatter": "Geen language server formatteert dit bestand",
28
- "readOnly": "Dit bestand is alleen-lezen",
29
- "failed": "De actie kon niet worden toegepast: {{message}}",
30
- "refused": "De wijziging is geweigerd",
25
+ "unavailable": "Hier geen code actions beschikbaar",
26
+ "organized": "Imports zijn al georganiseerd",
27
+ "noFormatter": "Geen formatter voor dit bestand",
28
+ "readOnly": "Bestand is alleen-lezen",
29
+ "failed": "Kon de actie niet toepassen: {{message}}",
30
+ "refused": "Wijziging geweigerd",
31
31
  "moreLines": "nog {{count}} regels",
32
32
  "otherFiles_one": "en nog {{count}} bestand",
33
33
  "otherFiles_other": "en nog {{count}} bestanden",
@@ -49,11 +49,11 @@
49
49
  }
50
50
  },
51
51
  "rename": {
52
- "unavailable": "Geen language server hernoemt in dit bestand",
53
- "nothing": "Hier is niets om te hernoemen",
54
- "refused": "De language server weigerde de nieuwe naam",
55
- "stale": "De tekst veranderde terwijl de hernoeming werd opgevraagd",
56
- "failed": "Hernoemen mislukt: {{message}}",
52
+ "unavailable": "Hernoemen niet beschikbaar in dit bestand",
53
+ "nothing": "Niets om te hernoemen",
54
+ "refused": "Nieuwe naam geweigerd",
55
+ "stale": "De tekst veranderde voordat de hernoeming klaar was. Probeer het opnieuw.",
56
+ "failed": "Kon niet hernoemen: {{message}}",
57
57
  "occurrences_one": "{{formatted}} voorkomen",
58
58
  "occurrences_other": "{{formatted}} voorkomens",
59
59
  "occurrencesFiles_one": "{{formatted}} voorkomen in {{files}} bestanden",
@@ -71,9 +71,9 @@
71
71
  }
72
72
  },
73
73
  "navigation": {
74
- "unavailable": "Geen language server die dat hier beantwoordt",
74
+ "unavailable": "Hier niet beschikbaar",
75
75
  "none": "Niets gevonden",
76
- "failed": "Opzoeken mislukt: {{message}}",
76
+ "failed": "Kon het niet opzoeken: {{message}}",
77
77
  "titles": {
78
78
  "definition": "Definities",
79
79
  "declaration": "Declaraties",
@@ -86,9 +86,9 @@
86
86
  "resize": "Paneel vergroten of verkleinen"
87
87
  },
88
88
  "peek": {
89
- "unavailable": "Geen language server vindt referenties in dit bestand",
89
+ "unavailable": "Referenties niet beschikbaar in dit bestand",
90
90
  "none": "Geen referenties gevonden",
91
- "failed": "Referenties opzoeken mislukt: {{message}}",
91
+ "failed": "Kon de referenties niet opzoeken: {{message}}",
92
92
  "references_one": "{{formatted}} referentie",
93
93
  "references_other": "{{formatted}} referenties",
94
94
  "close": "Sluit",
@@ -97,12 +97,12 @@
97
97
  "definitions_one": "{{formatted}} definitie",
98
98
  "definitions_other": "{{formatted}} definities",
99
99
  "noDefinition": "Geen definitie gevonden",
100
- "unavailableDefinition": "Geen language server vindt definities in dit bestand"
100
+ "unavailableDefinition": "Definities niet beschikbaar in dit bestand"
101
101
  },
102
102
  "callHierarchy": {
103
- "unavailable": "Geen language server vindt aanroepen in dit bestand",
104
- "none": "Hier is geen symbool met aanroepen gevonden",
105
- "failed": "Aanroepen opzoeken mislukt: {{message}}",
103
+ "unavailable": "Aanroepen niet beschikbaar in dit bestand",
104
+ "none": "Hier geen aanroepen",
105
+ "failed": "Kon de aanroepen niet opzoeken: {{message}}",
106
106
  "label": "Aanroephiërarchie",
107
107
  "direction": "Richting",
108
108
  "incoming": "Aanroepers",
@@ -111,7 +111,7 @@
111
111
  "loading": "Laden…",
112
112
  "noIncoming": "Geen aanroepers",
113
113
  "noOutgoing": "Roept niets aan",
114
- "retry": "Aanroepen laden mislukt: {{message}}. Druk om opnieuw te proberen",
114
+ "retry": "Kon de aanroepen niet laden: {{message}}. Klik om het opnieuw te proberen",
115
115
  "more_one": "Toon nog {{formatted}} aanroep ({{hidden}} over)",
116
116
  "more_other": "Toon nog {{formatted}} aanroepen ({{hidden}} over)",
117
117
  "sites_one": "{{formatted}} aanroep",
@@ -133,20 +133,20 @@
133
133
  "newCode": "nieuw *",
134
134
  "lines_one": "{{formatted}} regel",
135
135
  "lines_other": "{{formatted}} regels",
136
- "uncommitted": "Nog niet gecommit",
136
+ "uncommitted": "Niet gecommit",
137
137
  "latest": "Laatste wijziging",
138
138
  "showCommit": "Commit tonen"
139
139
  },
140
140
  "symbols": {
141
- "unavailable": "Geen language server kent de symbolen van dit bestand",
142
- "failed": "De symbolen konden niet worden gelezen: {{message}}",
141
+ "unavailable": "Symbolen niet beschikbaar in dit bestand",
142
+ "failed": "Kon de symbolen niet lezen: {{message}}",
143
143
  "placeholder": "Ga naar symbool in {{file}}",
144
144
  "navigate": "Navigeer",
145
145
  "open": "Open",
146
146
  "workspace": "Symbolen in het project",
147
147
  "line": "Ga naar regel",
148
148
  "none": "Geen symbolen gevonden",
149
- "workspaceHint": "Typ de naam van een symbool in het project",
149
+ "workspaceHint": "Typ een symboolnaam",
150
150
  "lineHint": "Typ een regelnummer",
151
151
  "goToLine": "Ga naar regel {{line}}",
152
152
  "groups": {
@@ -180,14 +180,14 @@
180
180
  "choices": "Snippetkeuze"
181
181
  },
182
182
  "completion": {
183
- "tooLarge": "Deze aanvulling is te groot om in te voegen",
183
+ "tooLarge": "Te groot om in te voegen",
184
184
  "insert": "Invoegen",
185
185
  "replace": "Vervangen",
186
186
  "details": "Details",
187
187
  "none": "Geen suggesties",
188
- "transformBusy": "Snippettransformaties zijn bezig; probeer het opnieuw",
189
- "transformFailed": "Snippettransformatie kon niet worden toegepast",
190
- "failed": "De suggestie kon niet worden ingevoegd: {{message}}"
188
+ "transformBusy": "Het snippet is nog niet klaar. Probeer het opnieuw.",
189
+ "transformFailed": "Kon het snippet niet invullen",
190
+ "failed": "Kon de suggestie niet invoegen: {{message}}"
191
191
  },
192
192
  "history": {
193
193
  "recent": "Recente plekken"
@@ -265,21 +265,21 @@
265
265
  "toggle": "Vervangen tonen",
266
266
  "hide": "Vervangen verbergen",
267
267
  "failed": {
268
- "limit": "Te veel om ineens te vervangen ({{edits}} edits of {{characters}} uitvoertekens)",
269
- "timeout": "Vervangen duurde te lang; de tekst is niet gewijzigd",
270
- "unavailable": "Vervangen vereist de zoekworker",
271
- "error": "Vervangen is niet gelukt; de tekst is niet gewijzigd"
268
+ "limit": "Te veel om ineens te vervangen (meer dan {{edits}} treffers of {{characters}} tekens)",
269
+ "timeout": "Vervangen duurde te lang. Er is niets gewijzigd",
270
+ "unavailable": "Vervangen is nu niet beschikbaar",
271
+ "error": "Kon niet vervangen. Er is niets gewijzigd"
272
272
  }
273
273
  },
274
274
  "countMore": "{{total}}+ resultaten",
275
275
  "searching": "Zoeken…",
276
- "large": "Groot document: druk op Enter om te zoeken",
276
+ "large": "Dit document is groot. Druk op Enter om te zoeken",
277
277
  "replaced": "{{count}} resultaten vervangen",
278
278
  "failed": {
279
- "timeout": "Zoeken duurde te lang; druk op Enter om opnieuw te proberen",
279
+ "timeout": "Zoeken duurde te lang. Druk op Enter om het opnieuw te proberen",
280
280
  "unavailable": "Zoeken met regex is niet beschikbaar",
281
281
  "invalid": "Ongeldige reguliere expressie",
282
- "error": "Zoeken kon niet worden voltooid"
282
+ "error": "Kon de zoekopdracht niet voltooien"
283
283
  }
284
284
  },
285
285
  "diff": {
package/dist/models.js CHANGED
@@ -19,4 +19,4 @@ export { replacedWords } from './word-diff.js';
19
19
  export { EMPTY_FIND_QUERY, MATCH_LIMIT, compileFind, matchesIn, stepIndex } from './find-query.js';
20
20
  export {} from './popup-placement.js';
21
21
  export { planConflict } from './conflict-model.js';
22
- export { patchLayoutOf } from './patch-layout.js';
22
+ export { patchLayoutOf } from './patch-layout.js';
@@ -1,7 +1,7 @@
1
1
  const LIMIT = 100;
2
2
  /* Two places on one line of one file are one place: a jump lands wherever, and walking back should not stop twice on the same line. */
3
3
  function samePlace(left, right) {
4
- return left.uri === right.uri && left.position.line === right.position.line;
4
+ return left.uri === right.uri && left.position.line === right.position.line;
5
5
  }
6
6
  /*
7
7
  * Where the caret was before each jump, for Back and Forward. A jump records the place it left and
@@ -9,45 +9,44 @@ function samePlace(left, right) {
9
9
  * One history serves every editor of a project, so it walks across files.
10
10
  */
11
11
  export class NavigationHistory {
12
- backs = [];
13
- forwards = [];
14
- record(from) {
15
- if (this.backs.length > 0 && samePlace(this.backs[this.backs.length - 1], from)) {
16
- this.backs[this.backs.length - 1] = from;
17
- }
18
- else {
19
- this.backs.push(from);
20
- if (this.backs.length > LIMIT) {
21
- this.backs.shift();
22
- }
23
- }
24
- this.forwards = [];
12
+ backs = [];
13
+ forwards = [];
14
+ record(from) {
15
+ if (this.backs.length > 0 && samePlace(this.backs[this.backs.length - 1], from)) {
16
+ this.backs[this.backs.length - 1] = from;
17
+ } else {
18
+ this.backs.push(from);
19
+ if (this.backs.length > LIMIT) {
20
+ this.backs.shift();
21
+ }
25
22
  }
26
- /* The place before `current`, which Forward then returns to; null when there is none. */
27
- back(current) {
28
- return this.walk(this.backs, this.forwards, current);
23
+ this.forwards = [];
24
+ }
25
+ /* The place before `current`, which Forward then returns to; null when there is none. */
26
+ back(current) {
27
+ return this.walk(this.backs, this.forwards, current);
28
+ }
29
+ forward(current) {
30
+ return this.walk(this.forwards, this.backs, current);
31
+ }
32
+ canGoBack(current) {
33
+ return this.backs.some(place => !samePlace(place, current));
34
+ }
35
+ canGoForward(current) {
36
+ return this.forwards.some(place => !samePlace(place, current));
37
+ }
38
+ /* Every place in the history but the one the caret is on, the latest first: where Back would go, then where Forward would. */
39
+ recent(current) {
40
+ return [...this.backs.toReversed(), ...this.forwards.toReversed()].filter(place => !samePlace(place, current));
41
+ }
42
+ walk(from, to, current) {
43
+ while (from.length > 0) {
44
+ const place = from.pop();
45
+ if (!samePlace(place, current)) {
46
+ to.push(current);
47
+ return place;
48
+ }
29
49
  }
30
- forward(current) {
31
- return this.walk(this.forwards, this.backs, current);
32
- }
33
- canGoBack(current) {
34
- return this.backs.some((place) => !samePlace(place, current));
35
- }
36
- canGoForward(current) {
37
- return this.forwards.some((place) => !samePlace(place, current));
38
- }
39
- /* Every place in the history but the one the caret is on, the latest first: where Back would go, then where Forward would. */
40
- recent(current) {
41
- return [...this.backs.toReversed(), ...this.forwards.toReversed()].filter((place) => !samePlace(place, current));
42
- }
43
- walk(from, to, current) {
44
- while (from.length > 0) {
45
- const place = from.pop();
46
- if (!samePlace(place, current)) {
47
- to.push(current);
48
- return place;
49
- }
50
- }
51
- return null;
52
- }
53
- }
50
+ return null;
51
+ }
52
+ }
@@ -6,44 +6,51 @@ import { placesOfName } from './symbol-links.js';
6
6
  import { isShortcut } from './shortcut-keys.js';
7
7
  import { messageOf } from './error-message.js';
8
8
  const METHODS = {
9
- definition: 'textDocument/definition',
10
- declaration: 'textDocument/declaration',
11
- typeDefinition: 'textDocument/typeDefinition',
12
- implementation: 'textDocument/implementation'
9
+ definition: 'textDocument/definition',
10
+ declaration: 'textDocument/declaration',
11
+ typeDefinition: 'textDocument/typeDefinition',
12
+ implementation: 'textDocument/implementation'
13
13
  };
14
14
  const REQUESTS = {
15
- definition: (service, uri, position) => service.definition(uri, position),
16
- declaration: (service, uri, position) => service.declaration(uri, position),
17
- typeDefinition: (service, uri, position) => service.typeDefinition(uri, position),
18
- implementation: (service, uri, position) => service.implementation(uri, position)
15
+ definition: (service, uri, position) => service.definition(uri, position),
16
+ declaration: (service, uri, position) => service.declaration(uri, position),
17
+ typeDefinition: (service, uri, position) => service.typeDefinition(uri, position),
18
+ implementation: (service, uri, position) => service.implementation(uri, position)
19
19
  };
20
- const SHORTCUT_KINDS = [
21
- ['definition', 'goToDefinition'],
22
- ['typeDefinition', 'goToTypeDefinition'],
23
- ['implementation', 'goToImplementation']
24
- ];
20
+ const SHORTCUT_KINDS = [['definition', 'goToDefinition'], ['typeDefinition', 'goToTypeDefinition'], ['implementation', 'goToImplementation']];
25
21
  const TOAST_ID = 'language-navigation';
26
22
  /* The places of a result, each once: the two servers of a Vue file may both know the same one. `target` is the whole declaration when the server gave it. */
27
23
  export function uniquePlaces(result) {
28
- const seen = new Set();
29
- const list = result === null ? [] : Array.isArray(result) ? result : [result];
30
- return list
31
- .map((entry) => 'targetUri' in entry
32
- ? { location: { uri: entry.targetUri, range: entry.targetSelectionRange }, target: entry.targetRange }
33
- : { location: entry, target: null })
34
- .filter(({ location }) => {
35
- const { start } = location.range;
36
- const key = `${location.uri}\0${start.line}\0${start.character}`;
37
- if (seen.has(key)) {
38
- return false;
39
- }
40
- seen.add(key);
41
- return true;
42
- });
24
+ const seen = new Set();
25
+ const list = result === null ? [] : Array.isArray(result) ? result : [result];
26
+ return list.map(entry => 'targetUri' in entry ? {
27
+ location: {
28
+ uri: entry.targetUri,
29
+ range: entry.targetSelectionRange
30
+ },
31
+ target: entry.targetRange
32
+ } : {
33
+ location: entry,
34
+ target: null
35
+ }).filter(({
36
+ location
37
+ }) => {
38
+ const {
39
+ start
40
+ } = location.range;
41
+ const key = `${location.uri}\0${start.line}\0${start.character}`;
42
+ if (seen.has(key)) {
43
+ return false;
44
+ }
45
+ seen.add(key);
46
+ return true;
47
+ });
43
48
  }
44
49
  /* The places of a result, each once. */
45
50
  export function uniqueLocations(result) {
46
- return uniquePlaces(result).map(({ location }) => location);
51
+ return uniquePlaces(result).map(({
52
+ location
53
+ }) => location);
47
54
  }
48
55
  /*
49
56
  * Going to where a name is defined, declared, typed or implemented: Mod+click on the name or a shortcut
@@ -51,106 +58,117 @@ export function uniqueLocations(result) {
51
58
  * the host; several are listed under the name to choose from.
52
59
  */
53
60
  export class NavigationFeature {
54
- language;
55
- constructor(language) {
56
- this.language = language;
57
- const { editor } = language;
58
- const offs = [
59
- editor.onClick((click) => {
60
- if (!click.mod || click.alt || click.shift || !this.supports('definition')) {
61
- return false;
62
- }
63
- void this.go('definition', click.position);
64
- return true;
65
- }),
66
- language.onKey((event) => {
67
- const found = SHORTCUT_KINDS.find(([, name]) => isShortcut(this.language.shortcuts[name], event));
68
- if (found === undefined) {
69
- return false;
70
- }
71
- void this.go(found[0]);
72
- return true;
73
- }, KEY_PRIORITY.navigation)
74
- ];
75
- language.onDispose(() => {
76
- for (const off of offs) {
77
- off();
78
- }
79
- });
61
+ language;
62
+ constructor(language) {
63
+ this.language = language;
64
+ const {
65
+ editor
66
+ } = language;
67
+ const offs = [editor.onClick(click => {
68
+ if (!click.mod || click.alt || click.shift || !this.supports('definition')) {
69
+ return false;
70
+ }
71
+ void this.go('definition', click.position);
72
+ return true;
73
+ }), language.onKey(event => {
74
+ const found = SHORTCUT_KINDS.find(([, name]) => isShortcut(this.language.shortcuts[name], event));
75
+ if (found === undefined) {
76
+ return false;
77
+ }
78
+ void this.go(found[0]);
79
+ return true;
80
+ }, KEY_PRIORITY.navigation)];
81
+ language.onDispose(() => {
82
+ for (const off of offs) {
83
+ off();
84
+ }
85
+ });
86
+ }
87
+ supports(kind) {
88
+ return this.language.project.service.supports(METHODS[kind], this.language.uri);
89
+ }
90
+ async go(kind, position = this.language.editor.getCaret()) {
91
+ const {
92
+ project,
93
+ uri,
94
+ editor
95
+ } = this.language;
96
+ if (!this.supports(kind)) {
97
+ this.tell(this.say('unavailable'));
98
+ return;
80
99
  }
81
- supports(kind) {
82
- return this.language.project.service.supports(METHODS[kind], this.language.uri);
100
+ let result;
101
+ try {
102
+ result = await REQUESTS[kind](project.service, uri, position);
103
+ } catch (error) {
104
+ if (!(error instanceof StaleResultError)) {
105
+ this.tell(this.say('failed', {
106
+ message: messageOf(error)
107
+ }));
108
+ }
109
+ return;
83
110
  }
84
- async go(kind, position = this.language.editor.getCaret()) {
85
- const { project, uri, editor } = this.language;
86
- if (!this.supports(kind)) {
87
- this.tell(this.say('unavailable'));
88
- return;
89
- }
90
- let result;
91
- try {
92
- result = await REQUESTS[kind](project.service, uri, position);
93
- }
94
- catch (error) {
95
- if (!(error instanceof StaleResultError)) {
96
- this.tell(this.say('failed', { message: messageOf(error) }));
97
- }
98
- return;
99
- }
100
- const places = uniqueLocations(result);
101
- if (places.length === 0) {
102
- this.tell(this.say('none'));
103
- }
104
- else if (kind === 'definition' && places.length === 1 && places[0].uri === uri && rangeHolds(places[0].range, position)) {
105
- // The name is its own definition, so what a person wants to see is where it is used.
106
- void this.language.peek.open(position);
107
- }
108
- else if (places.length === 1) {
109
- this.language.goTo(places[0]);
110
- }
111
- else {
112
- this.language.locations(places, position, this.say(`titles.${kind}`));
113
- }
114
- editor.focus();
111
+ const places = uniqueLocations(result);
112
+ if (places.length === 0) {
113
+ this.tell(this.say('none'));
114
+ } else if (kind === 'definition' && places.length === 1 && places[0].uri === uri && rangeHolds(places[0].range, position)) {
115
+ // The name is its own definition, so what a person wants to see is where it is used.
116
+ void this.language.peek.open(position);
117
+ } else if (places.length === 1) {
118
+ this.language.goTo(places[0]);
119
+ } else {
120
+ this.language.locations(places, position, this.say(`titles.${kind}`));
115
121
  }
116
- /*
117
- * A name in the signature of a hover, which is a snippet and no document a server can be asked about by position.
118
- * The symbol the signature declares goes to the definition the hover already knows; any other name is looked
119
- * up by name among the symbols of the project. One match goes there at once, several are listed, and none says nothing.
120
- */
121
- async goToName(name, anchor, own) {
122
- const { project, uri, editor } = this.language;
123
- if (own !== null) {
124
- this.language.goTo(own);
125
- return;
126
- }
127
- if (!project.service.supports('workspace/symbol', uri)) {
128
- return;
129
- }
130
- try {
131
- const places = placesOfName(await project.service.workspaceSymbols(uri, name), name, editor.getText());
132
- if (places.length === 1) {
133
- this.language.goTo(places[0]);
134
- }
135
- else if (places.length > 1) {
136
- this.language.locations(places, anchor, this.say('titles.symbol'));
137
- }
138
- }
139
- catch {
140
- // A name that cannot be found is a link that does nothing, not an error.
141
- }
122
+ editor.focus();
123
+ }
124
+ /*
125
+ * A name in the signature of a hover, which is a snippet and no document a server can be asked about by position.
126
+ * The symbol the signature declares goes to the definition the hover already knows; any other name is looked
127
+ * up by name among the symbols of the project. One match goes there at once, several are listed, and none says nothing.
128
+ */
129
+ async goToName(name, anchor, own) {
130
+ const {
131
+ project,
132
+ uri,
133
+ editor
134
+ } = this.language;
135
+ if (own !== null) {
136
+ this.language.goTo(own);
137
+ return;
142
138
  }
143
- tell(title) {
144
- this.language.project.host.notify?.({ id: TOAST_ID, kind: 'error', title });
139
+ if (!project.service.supports('workspace/symbol', uri)) {
140
+ return;
145
141
  }
146
- say(key, options) {
147
- return this.language.project.i18n.t(`editor:language.navigation.${key}`, options);
142
+ try {
143
+ const places = placesOfName(await project.service.workspaceSymbols(uri, name), name, editor.getText());
144
+ if (places.length === 1) {
145
+ this.language.goTo(places[0]);
146
+ } else if (places.length > 1) {
147
+ this.language.locations(places, anchor, this.say('titles.symbol'));
148
+ }
149
+ } catch {
150
+ // A name that cannot be found is a link that does nothing, not an error.
148
151
  }
152
+ }
153
+ tell(title) {
154
+ this.language.project.host.notify?.({
155
+ id: TOAST_ID,
156
+ kind: 'error',
157
+ title
158
+ });
159
+ }
160
+ say(key, options) {
161
+ return this.language.project.i18n.t(`editor:language.navigation.${key}`, options);
162
+ }
149
163
  }
150
164
  /* How a place reads in a list: the file and the line, with the folder it is in. */
151
165
  export function locationRow(location, stored) {
152
- const path = stored ?? fileUriToPath(location.uri) ?? location.uri;
153
- const name = basenameOf(path);
154
- const folder = path.slice(0, Math.max(0, path.length - name.length)).replace(/\/$/, '');
155
- return { label: `${name}:${location.range.start.line + 1}`, detail: folder, path: true };
156
- }
166
+ const path = stored ?? fileUriToPath(location.uri) ?? location.uri;
167
+ const name = basenameOf(path);
168
+ const folder = path.slice(0, Math.max(0, path.length - name.length)).replace(/\/$/, '');
169
+ return {
170
+ label: `${name}:${location.range.start.line + 1}`,
171
+ detail: folder,
172
+ path: true
173
+ };
174
+ }
@@ -10,16 +10,16 @@ const PANEL_FALLBACK_AVAILABLE = 800;
10
10
  export const PANEL_KEY_STEP = 22;
11
11
  /* The tallest body for an editor that is `available` pixels high; never below the minimum, so a tiny editor still gets a usable panel. */
12
12
  export function panelBodyMax(available) {
13
- return Math.max(PANEL_BODY_MIN, Math.floor(available * PANEL_MAX_SHARE) - PANEL_CHROME);
13
+ return Math.max(PANEL_BODY_MIN, Math.floor(available * PANEL_MAX_SHARE) - PANEL_CHROME);
14
14
  }
15
15
  export function clampPanelBody(height, available = PANEL_FALLBACK_AVAILABLE) {
16
- if (!Number.isFinite(height)) {
17
- return PANEL_BODY_HEIGHT;
18
- }
19
- return Math.min(panelBodyMax(available), Math.max(PANEL_BODY_MIN, Math.round(height)));
16
+ if (!Number.isFinite(height)) {
17
+ return PANEL_BODY_HEIGHT;
18
+ }
19
+ return Math.min(panelBodyMax(available), Math.max(PANEL_BODY_MIN, Math.round(height)));
20
20
  }
21
21
  /* The height of the editor's scrolling area around a panel's row; the fallback stands in where nothing is laid out. */
22
22
  export function availableHeightOf(container) {
23
- const height = container?.closest('.se-viewport')?.clientHeight ?? 0;
24
- return height > 0 ? height : PANEL_FALLBACK_AVAILABLE;
25
- }
23
+ const height = container?.closest('.se-viewport')?.clientHeight ?? 0;
24
+ return height > 0 ? height : PANEL_FALLBACK_AVAILABLE;
25
+ }