@adecore/editor-react 0.31.12 → 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
@@ -6,8 +6,8 @@ const LINE_BREAK = /^\r?\n[ \t]*(\r?\n[ \t]*)?$/;
6
6
  const DEDENTED = /^[ \t]+(\S)$/u;
7
7
  /* The overlapping edits of a server answer have no single meaning, so an answer that has them is not applied. */
8
8
  function overlaps(edits) {
9
- const ordered = [...edits].sort((left, right) => comparePositions(left.range.start, right.range.start));
10
- return ordered.some((edit, index) => index > 0 && comparePositions(ordered[index - 1].range.end, edit.range.start) > 0);
9
+ const ordered = [...edits].sort((left, right) => comparePositions(left.range.start, right.range.start));
10
+ return ordered.some((edit, index) => index > 0 && comparePositions(ordered[index - 1].range.end, edit.range.start) > 0);
11
11
  }
12
12
  /*
13
13
  * Formatting while typing: after a person types one of the characters the server named in
@@ -23,73 +23,92 @@ function overlaps(edits) {
23
23
  * The edits join the undo step of the typed character, so one undo takes both back. Off by default; a host enables it explicitly with `configure(true)`.
24
24
  */
25
25
  export class FormatOnTypeFeature {
26
- language;
27
- enabled = false;
28
- /* Raised by every change of the text, so an answer for an older text is told from the one for the text that is. */
29
- revision = 0;
30
- controller = new AbortController();
31
- constructor(language) {
32
- this.language = language;
33
- const off = language.editor.onTextChange((change) => this.typed(change));
34
- language.onDispose(() => {
35
- off();
36
- this.controller.abort();
37
- });
26
+ language;
27
+ enabled = false;
28
+ /* Raised by every change of the text, so an answer for an older text is told from the one for the text that is. */
29
+ revision = 0;
30
+ controller = new AbortController();
31
+ constructor(language) {
32
+ this.language = language;
33
+ const off = language.editor.onTextChange(change => this.typed(change));
34
+ language.onDispose(() => {
35
+ off();
36
+ this.controller.abort();
37
+ });
38
+ }
39
+ get isEnabled() {
40
+ return this.enabled;
41
+ }
42
+ /* Whether the server of this document formats on type and the service can ask it. */
43
+ get supported() {
44
+ const {
45
+ project,
46
+ uri
47
+ } = this.language;
48
+ return project.service.onTypeFormatting !== undefined && project.service.supports(METHOD, uri);
49
+ }
50
+ configure(enabled) {
51
+ this.enabled = enabled;
52
+ if (!enabled) {
53
+ this.controller.abort();
38
54
  }
39
- get isEnabled() {
40
- return this.enabled;
55
+ }
56
+ /* The characters that ask the server, the first one and the more. */
57
+ triggerCharacters() {
58
+ const options = this.language.project.service.providerOptions(METHOD, this.language.uri);
59
+ return options === undefined ? [] : [...(options.firstTriggerCharacter === undefined ? [] : [options.firstTriggerCharacter]), ...(options.moreTriggerCharacter ?? [])];
60
+ }
61
+ typed(change) {
62
+ const revision = ++this.revision;
63
+ this.controller.abort();
64
+ if (!this.enabled || change.source !== 'input' && change.typed !== true || change.changes.length !== 1 || !this.supported) {
65
+ return;
41
66
  }
42
- /* Whether the server of this document formats on type and the service can ask it. */
43
- get supported() {
44
- const { project, uri } = this.language;
45
- return project.service.onTypeFormatting !== undefined && project.service.supports(METHOD, uri);
67
+ const {
68
+ editor,
69
+ snippets
70
+ } = this.language;
71
+ const {
72
+ text
73
+ } = change.changes[0];
74
+ const typed = LINE_BREAK.test(text) ? '\n' : Array.from(text).length === 1 ? text : DEDENTED.exec(text)?.[1] ?? null;
75
+ if (typed === null || !this.triggerCharacters().includes(typed)) {
76
+ return;
46
77
  }
47
- configure(enabled) {
48
- this.enabled = enabled;
49
- if (!enabled) {
50
- this.controller.abort();
51
- }
78
+ if (snippets.isActive || editor.isReadOnly?.() === true || editor.getSelections().length !== 1) {
79
+ return;
52
80
  }
53
- /* The characters that ask the server, the first one and the more. */
54
- triggerCharacters() {
55
- const options = this.language.project.service.providerOptions(METHOD, this.language.uri);
56
- return options === undefined
57
- ? []
58
- : [...(options.firstTriggerCharacter === undefined ? [] : [options.firstTriggerCharacter]), ...(options.moreTriggerCharacter ?? [])];
81
+ this.controller = new AbortController();
82
+ void this.ask(revision, typed, editor.getCaret(), this.controller.signal);
83
+ }
84
+ async ask(revision, typed, caret, signal) {
85
+ const {
86
+ editor,
87
+ project,
88
+ uri,
89
+ document
90
+ } = this.language;
91
+ try {
92
+ // The change of the typed character reaches the server before this question does.
93
+ await document.ready;
94
+ const edits = await project.service.onTypeFormatting(uri, caret, typed, {
95
+ ...editor.getIndentation()
96
+ }, {
97
+ signal
98
+ });
99
+ const here = editor.getCaret();
100
+ const stale = revision !== this.revision || this.language.isDisposed || comparePositions(here, caret) !== 0;
101
+ if (stale || edits === null || edits.length === 0 || overlaps(edits)) {
102
+ return;
103
+ }
104
+ editor.applyEdits(edits.map(edit => ({
105
+ range: edit.range,
106
+ text: edit.newText
107
+ })), {
108
+ mergeUndo: true
109
+ });
110
+ } catch {
111
+ // A refusal or a failing server is not worth a notice per keystroke; the next trigger character asks again.
59
112
  }
60
- typed(change) {
61
- const revision = ++this.revision;
62
- this.controller.abort();
63
- if (!this.enabled || (change.source !== 'input' && change.typed !== true) || change.changes.length !== 1 || !this.supported) {
64
- return;
65
- }
66
- const { editor, snippets } = this.language;
67
- const { text } = change.changes[0];
68
- const typed = LINE_BREAK.test(text) ? '\n' : Array.from(text).length === 1 ? text : (DEDENTED.exec(text)?.[1] ?? null);
69
- if (typed === null || !this.triggerCharacters().includes(typed)) {
70
- return;
71
- }
72
- if (snippets.isActive || editor.isReadOnly?.() === true || editor.getSelections().length !== 1) {
73
- return;
74
- }
75
- this.controller = new AbortController();
76
- void this.ask(revision, typed, editor.getCaret(), this.controller.signal);
77
- }
78
- async ask(revision, typed, caret, signal) {
79
- const { editor, project, uri, document } = this.language;
80
- try {
81
- // The change of the typed character reaches the server before this question does.
82
- await document.ready;
83
- const edits = await project.service.onTypeFormatting(uri, caret, typed, { ...editor.getIndentation() }, { signal });
84
- const here = editor.getCaret();
85
- const stale = revision !== this.revision || this.language.isDisposed || comparePositions(here, caret) !== 0;
86
- if (stale || edits === null || edits.length === 0 || overlaps(edits)) {
87
- return;
88
- }
89
- editor.applyEdits(edits.map((edit) => ({ range: edit.range, text: edit.newText })), { mergeUndo: true });
90
- }
91
- catch {
92
- // A refusal or a failing server is not worth a notice per keystroke; the next trigger character asks again.
93
- }
94
- }
95
- }
113
+ }
114
+ }
@@ -4,27 +4,26 @@
4
4
  * another's from before an edit.
5
5
  */
6
6
  export class HighlightLayers {
7
- editor;
8
- owners = new Map();
9
- constructor(editor) {
10
- this.editor = editor;
11
- }
12
- set(owner, provider) {
13
- if (provider === null) {
14
- this.owners.delete(owner);
15
- }
16
- else {
17
- this.owners.set(owner, provider);
18
- }
19
- this.editor.setLineHighlights([...this.owners.values()].flatMap((read) => read()));
7
+ editor;
8
+ owners = new Map();
9
+ constructor(editor) {
10
+ this.editor = editor;
11
+ }
12
+ set(owner, provider) {
13
+ if (provider === null) {
14
+ this.owners.delete(owner);
15
+ } else {
16
+ this.owners.set(owner, provider);
20
17
  }
18
+ this.editor.setLineHighlights([...this.owners.values()].flatMap(read => read()));
19
+ }
21
20
  }
22
21
  const layers = new WeakMap();
23
22
  export function highlightLayers(editor) {
24
- let found = layers.get(editor);
25
- if (found === undefined) {
26
- found = new HighlightLayers(editor);
27
- layers.set(editor, found);
28
- }
29
- return found;
30
- }
23
+ let found = layers.get(editor);
24
+ if (found === undefined) {
25
+ found = new HighlightLayers(editor);
26
+ layers.set(editor, found);
27
+ }
28
+ return found;
29
+ }
@@ -6,98 +6,120 @@ import { isShortcut } from './shortcut-keys.js';
6
6
  import { realTimers } from './timers.js';
7
7
  const METHOD = 'textDocument/documentHighlight';
8
8
  const PAUSE_MS = 150;
9
- const KINDS = { 1: 'text', 2: 'read', 3: 'write' };
9
+ const KINDS = {
10
+ 1: 'text',
11
+ 2: 'read',
12
+ 3: 'write'
13
+ };
10
14
  export function editorHighlightsOf(highlights) {
11
- return highlights
12
- .filter((highlight) => comparePositions(highlight.range.start, highlight.range.end) < 0)
13
- .map((highlight) => ({ range: highlight.range, kind: KINDS[highlight.kind ?? 1] ?? 'text' }))
14
- .sort((left, right) => comparePositions(left.range.start, right.range.start));
15
+ return highlights.filter(highlight => comparePositions(highlight.range.start, highlight.range.end) < 0).map(highlight => ({
16
+ range: highlight.range,
17
+ kind: KINDS[highlight.kind ?? 1] ?? 'text'
18
+ })).sort((left, right) => comparePositions(left.range.start, right.range.start));
15
19
  }
16
20
  /* The range before the caret when stepping back, or after it when stepping forward, wrapping round the document; null for no ranges. */
17
21
  export function neighborRange(ranges, from, direction) {
18
- if (ranges.length === 0) {
19
- return null;
20
- }
21
- const ordered = [...ranges].sort((left, right) => comparePositions(left.start, right.start));
22
- if (direction === 1) {
23
- return ordered.find((range) => comparePositions(range.start, from) > 0) ?? ordered[0];
24
- }
25
- return [...ordered].reverse().find((range) => comparePositions(range.start, from) < 0) ?? ordered[ordered.length - 1];
22
+ if (ranges.length === 0) {
23
+ return null;
24
+ }
25
+ const ordered = [...ranges].sort((left, right) => comparePositions(left.start, right.start));
26
+ if (direction === 1) {
27
+ return ordered.find(range => comparePositions(range.start, from) > 0) ?? ordered[0];
28
+ }
29
+ return [...ordered].reverse().find(range => comparePositions(range.start, from) < 0) ?? ordered[ordered.length - 1];
26
30
  }
27
31
  /*
28
32
  * The other uses of the name at the caret, drawn softly in the text, which the next and previous highlight
29
33
  * keys step through. They are asked for when the caret rests on a name and go with the next edit.
30
34
  */
31
35
  export class HighlightsFeature {
32
- language;
33
- refresher;
34
- current = [];
35
- constructor(language, timers = realTimers) {
36
- this.language = language;
37
- const { editor, project, uri } = language;
38
- this.refresher = new Refresher(async (signal) => {
39
- if (!project.service.supports(METHOD, uri) || !this.onName()) {
40
- this.clear();
41
- return;
42
- }
43
- const result = await project.service.documentHighlights(uri, editor.getCaret(), { signal });
44
- if (!signal.aborted) {
45
- this.set(result === null ? [] : editorHighlightsOf(result));
46
- }
47
- }, PAUSE_MS, timers);
48
- const offs = [
49
- editor.onCaret((position) => {
50
- // Moving along the same name keeps its marks, which is what makes stepping through them quiet.
51
- if (!this.current.some((highlight) => rangeHolds(highlight.range, position))) {
52
- this.clear();
53
- }
54
- this.refresher.later();
55
- }),
56
- editor.onTextChange(() => {
57
- // The editor drops its marks with the edit; this follows, and asks again when the caret settles.
58
- this.current = [];
59
- this.refresher.later();
60
- }),
61
- language.onKey((event) => {
62
- const next = isShortcut(this.language.shortcuts.nextHighlight, event);
63
- if (!next && !isShortcut(this.language.shortcuts.previousHighlight, event)) {
64
- return false;
65
- }
66
- return this.step(next ? 1 : -1);
67
- }, KEY_PRIORITY.highlights)
68
- ];
69
- language.onDispose(() => {
70
- for (const off of offs) {
71
- off();
72
- }
73
- this.refresher.dispose();
74
- editor.setHighlights([]);
75
- });
76
- }
77
- /* Puts the caret on the next use of the name, or the one before; false when there are none. */
78
- step(direction) {
79
- const { editor } = this.language;
80
- const target = neighborRange(this.current.map((highlight) => highlight.range), editor.getCaret(), direction);
81
- if (target === null) {
82
- return false;
83
- }
84
- editor.setCaret(target.start, comparePositions(target.start, editor.getCaret()) > 0 ? 'centerDown' : 'centerUp');
85
- return true;
36
+ language;
37
+ refresher;
38
+ current = [];
39
+ constructor(language, timers = realTimers) {
40
+ this.language = language;
41
+ const {
42
+ editor,
43
+ project,
44
+ uri
45
+ } = language;
46
+ this.refresher = new Refresher(async signal => {
47
+ if (!project.service.supports(METHOD, uri) || !this.onName()) {
48
+ this.clear();
49
+ return;
50
+ }
51
+ const result = await project.service.documentHighlights(uri, editor.getCaret(), {
52
+ signal
53
+ });
54
+ if (!signal.aborted) {
55
+ this.set(result === null ? [] : editorHighlightsOf(result));
56
+ }
57
+ }, PAUSE_MS, timers);
58
+ const offs = [editor.onCaret(position => {
59
+ // Moving along the same name keeps its marks, which is what makes stepping through them quiet.
60
+ if (!this.current.some(highlight => rangeHolds(highlight.range, position))) {
61
+ this.clear();
62
+ }
63
+ this.refresher.later();
64
+ }), editor.onTextChange(() => {
65
+ // The editor drops its marks with the edit; this follows, and asks again when the caret settles.
66
+ this.current = [];
67
+ this.refresher.later();
68
+ }), language.onKey(event => {
69
+ const next = isShortcut(this.language.shortcuts.nextHighlight, event);
70
+ if (!next && !isShortcut(this.language.shortcuts.previousHighlight, event)) {
71
+ return false;
72
+ }
73
+ return this.step(next ? 1 : -1);
74
+ }, KEY_PRIORITY.highlights)];
75
+ language.onDispose(() => {
76
+ for (const off of offs) {
77
+ off();
78
+ }
79
+ this.refresher.dispose();
80
+ editor.setHighlights([]);
81
+ });
82
+ }
83
+ /* Puts the caret on the next use of the name, or the one before; false when there are none. */
84
+ step(direction) {
85
+ const {
86
+ editor
87
+ } = this.language;
88
+ const target = neighborRange(this.current.map(highlight => highlight.range), editor.getCaret(), direction);
89
+ if (target === null) {
90
+ return false;
86
91
  }
87
- onName() {
88
- const { editor } = this.language;
89
- const caret = editor.getCaret();
90
- const before = caret.character > 0 ? editor.textInRange({ start: { line: caret.line, character: caret.character - 1 }, end: caret }) : '';
91
- const after = editor.textInRange({ start: caret, end: { line: caret.line, character: caret.character + 1 } });
92
- return (before !== '' && isIdentifierCharacter(before)) || (after !== '' && isIdentifierCharacter(after));
92
+ editor.setCaret(target.start, comparePositions(target.start, editor.getCaret()) > 0 ? 'centerDown' : 'centerUp');
93
+ return true;
94
+ }
95
+ onName() {
96
+ const {
97
+ editor
98
+ } = this.language;
99
+ const caret = editor.getCaret();
100
+ const before = caret.character > 0 ? editor.textInRange({
101
+ start: {
102
+ line: caret.line,
103
+ character: caret.character - 1
104
+ },
105
+ end: caret
106
+ }) : '';
107
+ const after = editor.textInRange({
108
+ start: caret,
109
+ end: {
110
+ line: caret.line,
111
+ character: caret.character + 1
112
+ }
113
+ });
114
+ return before !== '' && isIdentifierCharacter(before) || after !== '' && isIdentifierCharacter(after);
115
+ }
116
+ set(highlights) {
117
+ this.current = highlights;
118
+ this.language.editor.setHighlights(highlights);
119
+ }
120
+ clear() {
121
+ if (this.current.length > 0) {
122
+ this.set([]);
93
123
  }
94
- set(highlights) {
95
- this.current = highlights;
96
- this.language.editor.setHighlights(highlights);
97
- }
98
- clear() {
99
- if (this.current.length > 0) {
100
- this.set([]);
101
- }
102
- }
103
- }
124
+ }
125
+ }
package/dist/history.js CHANGED
@@ -2,43 +2,49 @@ import { KEY_PRIORITY } from './key-priority.js';
2
2
  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
- language;
6
- constructor(language) {
7
- this.language = language;
8
- const off = language.onKey((event) => {
9
- if (isShortcut(this.language.shortcuts.historyBack, event)) {
10
- this.back();
11
- return true;
12
- }
13
- if (isShortcut(this.language.shortcuts.historyForward, event)) {
14
- this.forward();
15
- return true;
16
- }
17
- if (isShortcut(this.language.shortcuts.recentLocations, event)) {
18
- this.recent();
19
- return true;
20
- }
21
- return false;
22
- }, KEY_PRIORITY.history);
23
- language.onDispose(off);
24
- }
25
- /* Returns to where the caret was before the last jump; false when there is no such place. */
26
- back() {
27
- return this.visit(this.language.project.history.back(this.language.place));
28
- }
29
- forward() {
30
- return this.visit(this.language.project.history.forward(this.language.place));
31
- }
32
- /* Lists the places of the history under the caret; choosing one jumps there like any other jump. */
33
- recent() {
34
- const places = this.language.project.history.recent(this.language.place);
35
- this.language.locations(places.map((place) => ({ uri: place.uri, range: { start: place.position, end: place.position } })), this.language.editor.getCaret(), this.language.project.i18n.t('editor:language.history.recent'));
36
- }
37
- visit(place) {
38
- if (place === null) {
39
- return false;
40
- }
41
- this.language.visit(place);
5
+ language;
6
+ constructor(language) {
7
+ this.language = language;
8
+ const off = language.onKey(event => {
9
+ if (isShortcut(this.language.shortcuts.historyBack, event)) {
10
+ this.back();
11
+ return true;
12
+ }
13
+ if (isShortcut(this.language.shortcuts.historyForward, event)) {
14
+ this.forward();
15
+ return true;
16
+ }
17
+ if (isShortcut(this.language.shortcuts.recentLocations, event)) {
18
+ this.recent();
42
19
  return true;
20
+ }
21
+ return false;
22
+ }, KEY_PRIORITY.history);
23
+ language.onDispose(off);
24
+ }
25
+ /* Returns to where the caret was before the last jump; false when there is no such place. */
26
+ back() {
27
+ return this.visit(this.language.project.history.back(this.language.place));
28
+ }
29
+ forward() {
30
+ return this.visit(this.language.project.history.forward(this.language.place));
31
+ }
32
+ /* Lists the places of the history under the caret; choosing one jumps there like any other jump. */
33
+ recent() {
34
+ const places = this.language.project.history.recent(this.language.place);
35
+ this.language.locations(places.map(place => ({
36
+ uri: place.uri,
37
+ range: {
38
+ start: place.position,
39
+ end: place.position
40
+ }
41
+ })), this.language.editor.getCaret(), this.language.project.i18n.t('editor:language.history.recent'));
42
+ }
43
+ visit(place) {
44
+ if (place === null) {
45
+ return false;
43
46
  }
44
- }
47
+ this.language.visit(place);
48
+ return true;
49
+ }
50
+ }
package/dist/holder.js CHANGED
@@ -1,20 +1,20 @@
1
1
  /* One value that an effect sets and a render reads through `useSyncExternalStore`, without a state update inside the effect. */
2
2
  export function createHolder() {
3
- let value = null;
4
- const listeners = new Set();
5
- return {
6
- get: () => value,
7
- set: (next) => {
8
- value = next;
9
- for (const listener of [...listeners]) {
10
- listener();
11
- }
12
- },
13
- subscribe: (listener) => {
14
- listeners.add(listener);
15
- return () => {
16
- listeners.delete(listener);
17
- };
18
- }
19
- };
20
- }
3
+ let value = null;
4
+ const listeners = new Set();
5
+ return {
6
+ get: () => value,
7
+ set: next => {
8
+ value = next;
9
+ for (const listener of [...listeners]) {
10
+ listener();
11
+ }
12
+ },
13
+ subscribe: listener => {
14
+ listeners.add(listener);
15
+ return () => {
16
+ listeners.delete(listener);
17
+ };
18
+ }
19
+ };
20
+ }
@@ -1 +1 @@
1
- export {};
1
+ export {};