@adecore/editor 0.62.0 → 0.63.0-untangle.1

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 (95) hide show
  1. package/dist/attribution.js +0 -1
  2. package/dist/bidi.js +0 -1
  3. package/dist/column-selection.d.ts +0 -1
  4. package/dist/column-selection.js +1 -1
  5. package/dist/controller.d.ts +4 -2
  6. package/dist/controller.js +0 -5
  7. package/dist/engine.js +0 -3
  8. package/dist/fake.d.ts +3 -0
  9. package/dist/fake.js +29 -24
  10. package/dist/find.d.ts +3 -2
  11. package/dist/find.js +0 -2
  12. package/dist/geometry-stops.d.ts +1 -1
  13. package/dist/index.d.ts +3 -2
  14. package/dist/index.js +1 -1
  15. package/dist/keymap-table.d.ts +8 -1
  16. package/dist/keymap-table.js +0 -1
  17. package/dist/keymap.d.ts +2 -1
  18. package/dist/layout-changes.d.ts +2 -1
  19. package/dist/layout.d.ts +3 -57
  20. package/dist/layout.js +1 -6
  21. package/dist/line-geometry.d.ts +55 -0
  22. package/dist/line-geometry.js +1 -0
  23. package/dist/metrics.d.ts +1 -1
  24. package/dist/modifier-gesture.d.ts +2 -1
  25. package/dist/modifier-gesture.js +0 -1
  26. package/dist/native-input.d.ts +2 -1
  27. package/dist/outline.d.ts +3 -3
  28. package/dist/outline.js +0 -1
  29. package/dist/overview.d.ts +3 -2
  30. package/dist/paint.d.ts +5 -5
  31. package/dist/paint.js +3 -4
  32. package/dist/php-html.d.ts +0 -6
  33. package/dist/php-html.js +2 -2
  34. package/dist/pointer.d.ts +2 -1
  35. package/dist/scroll-animation.d.ts +0 -1
  36. package/dist/scroll-animation.js +1 -1
  37. package/dist/scroll.js +0 -1
  38. package/dist/search-client.d.ts +2 -2
  39. package/dist/shiki-document.js +1 -1
  40. package/dist/shiki-grammar.d.ts +7 -0
  41. package/dist/shiki-grammar.js +168 -0
  42. package/dist/shiki-worker.js +1 -1
  43. package/dist/shiki.d.ts +1 -7
  44. package/dist/shiki.js +1 -168
  45. package/dist/smart-keys.js +0 -1
  46. package/dist/testing.js +0 -2
  47. package/dist/todos.d.ts +2 -1
  48. package/dist/tokens.d.ts +2 -1
  49. package/dist/tokens.js +0 -1
  50. package/dist/touch.d.ts +2 -1
  51. package/dist/types.d.ts +5 -13
  52. package/dist/uniform-geometry.d.ts +1 -1
  53. package/dist/view.d.ts +12 -10
  54. package/dist/view.js +61 -38
  55. package/dist/zoom.d.ts +0 -2
  56. package/dist/zoom.js +2 -2
  57. package/package.json +8 -3
  58. package/src/attribution.ts +0 -1
  59. package/src/bidi.ts +0 -1
  60. package/src/column-selection.ts +1 -1
  61. package/src/controller.ts +3 -9
  62. package/src/engine.ts +0 -3
  63. package/src/fake.ts +38 -24
  64. package/src/find.ts +2 -4
  65. package/src/geometry-stops.ts +1 -1
  66. package/src/index.ts +2 -2
  67. package/src/keymap-table.ts +10 -3
  68. package/src/keymap.ts +2 -1
  69. package/src/layout-changes.ts +1 -1
  70. package/src/layout.ts +4 -81
  71. package/src/line-geometry.ts +69 -0
  72. package/src/metrics.ts +1 -1
  73. package/src/modifier-gesture.ts +1 -2
  74. package/src/native-input.ts +1 -1
  75. package/src/outline.ts +3 -5
  76. package/src/overview.ts +2 -2
  77. package/src/paint.ts +5 -11
  78. package/src/php-html.ts +2 -2
  79. package/src/pointer.ts +1 -4
  80. package/src/scroll-animation.ts +1 -1
  81. package/src/scroll.ts +0 -2
  82. package/src/search-client.ts +2 -2
  83. package/src/shiki-document.ts +1 -1
  84. package/src/shiki-grammar.ts +223 -0
  85. package/src/shiki-worker.ts +1 -1
  86. package/src/shiki.ts +1 -224
  87. package/src/smart-keys.ts +0 -1
  88. package/src/testing.ts +0 -2
  89. package/src/todos.ts +1 -1
  90. package/src/tokens.ts +1 -2
  91. package/src/touch.ts +1 -1
  92. package/src/types.ts +9 -22
  93. package/src/uniform-geometry.ts +1 -1
  94. package/src/view.ts +89 -56
  95. package/src/zoom.ts +2 -2
package/src/tokens.ts CHANGED
@@ -9,7 +9,7 @@ interface Entry {
9
9
  /* A line this long is left uncolored: a grammar can spend seconds on it, and nobody reads it in colors. */
10
10
  const LONGEST_COLORED_LINE = 20000;
11
11
 
12
- export interface TokenSource {
12
+ interface TokenSource {
13
13
  getLineCount(): number;
14
14
  getLineText(line: number): string;
15
15
  }
@@ -229,7 +229,6 @@ export class TokenCache {
229
229
  this.pivotLine = -1;
230
230
  }
231
231
 
232
- /* Whether lines through `line` are colored for the text as it is now. */
233
232
  covers(line: number): boolean {
234
233
  return this.frontier > line || this.frontier >= this.source.getLineCount();
235
234
  }
package/src/touch.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { DocumentModel } from '@adecore/editor-core';
2
2
 
3
- export interface TouchHost {
3
+ interface TouchHost {
4
4
  readonly model: DocumentModel;
5
5
  offsetAt(clientX: number, clientY: number): number;
6
6
  camelHumps(): boolean;
package/src/types.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import type { EditorCommand, FoldRole, TextPlaceKind, UnwrapKind, WhitespaceCleanupOptions } from '@adecore/editor-core';
2
- import type { Keymap } from './keymap-table.ts';
3
- import type { EditorSearchClientOptions } from './search-client.ts';
2
+ import type { KeyChord, Keymap } from './keymap-table.ts';
4
3
 
5
4
  export type { EditorCommand, FoldRole };
6
5
 
@@ -45,7 +44,6 @@ export interface EditorZoom {
45
44
  readonly wheel?: boolean;
46
45
  }
47
46
 
48
- /* Everything `runCommand` runs. */
49
47
  export type EditorRunCommand = EditorCommand | EditorViewCommand;
50
48
 
51
49
  /* Lines to fold, zero-based. */
@@ -115,7 +113,6 @@ export interface EditorOptions {
115
113
  readonly zoom?: EditorZoom;
116
114
  }
117
115
 
118
- /* The few sentences the editor says on its own. */
119
116
  export interface EditorMessages {
120
117
  /* Select next occurrence went past the last one. */
121
118
  readonly noMoreOccurrences: string;
@@ -224,7 +221,6 @@ export interface EditorRemoteCursor {
224
221
  readonly id: string;
225
222
  /* A line past the end is the last one, a character past the end of its line is the end of it. */
226
223
  readonly position: EditorPosition;
227
- /* What the label says, such as the agent's name. */
228
224
  readonly name: string;
229
225
  readonly color: EditorMarkColor;
230
226
  }
@@ -474,8 +470,8 @@ export interface EditorLineAction {
474
470
  readonly id: string;
475
471
  /* Zero-based; the action stays on its line through edits until its owner sets its actions again. */
476
472
  readonly line: number;
477
- /* Fills the element once; it is kept for as long as the action is. */
478
- render(container: HTMLElement): void;
473
+ /* Fills the element once; it is kept for as long as the action is. What it returns runs once, when the element is taken away. */
474
+ render(container: HTMLElement): (() => void) | void;
479
475
  }
480
476
 
481
477
  /* One thing a code vision row says, such as how many times a declaration is used. */
@@ -580,8 +576,8 @@ export interface EditorGhostText {
580
576
  /* Where the suggestion would be inserted; the caret stays in front of it. */
581
577
  readonly position: EditorPosition;
582
578
  readonly text: string;
583
- /* Fills the element drawn after the end of the first line's text, such as the keys that take the suggestion. */
584
- readonly accessory?: (container: HTMLElement) => void;
579
+ /* Fills the element drawn after the end of the first line's text, such as the keys that take the suggestion. What it returns runs once, when that element is taken away. */
580
+ readonly accessory?: (container: HTMLElement) => (() => void) | void;
585
581
  }
586
582
 
587
583
  /* A button in the gutter on one line, such as the lightbulb that offers code actions. */
@@ -620,6 +616,9 @@ export interface EditorIndentation {
620
616
  readonly insertSpaces: boolean;
621
617
  }
622
618
 
619
+ /* Starts the worker a find runs on, which only has to take and answer messages. */
620
+ export type EditorSearchWorkerFactory = () => Pick<Worker, 'addEventListener' | 'removeEventListener' | 'postMessage' | 'terminate'>;
621
+
623
622
  /* What a find bar asks the editor; the editor's own matcher reads it. */
624
623
  export interface EditorFindQuery {
625
624
  readonly text: string;
@@ -676,7 +675,6 @@ export interface Editor {
676
675
  /* An offset past the end, or a character past the end of its line, lands on the end. */
677
676
  positionAt(offset: number): EditorPosition;
678
677
  offsetAt(position: EditorPosition): number;
679
- /* The text of a range, such as the word before the caret. */
680
678
  textInRange(range: EditorRange): string;
681
679
  /* Mod+S from inside the editor; what happens then is the host's. */
682
680
  onSave(listener: () => void): () => void;
@@ -916,17 +914,6 @@ export interface EditorEngine {
916
914
  mount(element: HTMLElement, options: EditorOptions): Editor;
917
915
  }
918
916
 
919
- /* A shortcut: `mod` is Cmd on macOS and Ctrl elsewhere, `ctrl` and `meta` the physical keys. */
920
- export interface KeyChord {
921
- readonly mod: boolean;
922
- readonly ctrl: boolean;
923
- readonly meta: boolean;
924
- readonly alt: boolean;
925
- readonly shift: boolean;
926
- /* An uppercase letter, a digit, a punctuation mark or a named key such as `ArrowLeft`. */
927
- readonly key: string;
928
- }
929
-
930
917
  /* One stretch of a colored line. The tokens of a line add up to its length. */
931
918
  export interface LineToken {
932
919
  readonly length: number;
@@ -966,7 +953,7 @@ export type TokenizerSource = (language: string | undefined, theme: EditorTheme,
966
953
 
967
954
  export interface SmartEditorEngineOptions {
968
955
  /* One lazy search worker per mounted editor; regex search is unavailable without it. */
969
- readonly searchWorker?: EditorSearchClientOptions['workerFactory'];
956
+ readonly searchWorker?: EditorSearchWorkerFactory;
970
957
  /* The key table. A function is asked on every key press, so a rebind reaches the editors that are open. */
971
958
  readonly keymap?: Keymap | (() => Keymap);
972
959
  readonly tokenizer: TokenizerSource;
@@ -1,4 +1,4 @@
1
- import type { LayoutMetrics, LineGeometry } from './layout.ts';
1
+ import type { LayoutMetrics, LineGeometry } from './line-geometry.ts';
2
2
 
3
3
  export function uniformGeometry(
4
4
  line: { start: number; end: number; text: string; next?: number },
package/src/view.ts CHANGED
@@ -19,7 +19,6 @@ import {
19
19
  type BlockWidget,
20
20
  EditorLayout,
21
21
  type FoldState,
22
- type Inlay,
23
22
  type LayoutRect,
24
23
  type LayoutRow,
25
24
  RIGHT_PADDING,
@@ -27,6 +26,7 @@ import {
27
26
  subRowBand,
28
27
  type VerticalWindow
29
28
  } from './layout.ts';
29
+ import { type Inlay } from './line-geometry.ts';
30
30
  import { emit, subscribe } from './listeners.ts';
31
31
  import { createMetrics, type EditorFont, readEditorFont } from './metrics.ts';
32
32
  import { mapOffset, offsetMapper } from './offsets.ts';
@@ -110,16 +110,11 @@ export interface ViewSettings {
110
110
  smartKeys: EditorSmartKeys;
111
111
  messages: Partial<EditorMessages>;
112
112
  label: string;
113
- /* A line at each indentation level, and the one of the scope around the caret stronger. */
114
113
  guides: boolean;
115
- /* Spaces drawn as dots and tabs as arrows. */
116
114
  whitespace: boolean;
117
- /* The column a line is held to, drawn as a line; null for none. */
118
115
  rightMargin: number | null;
119
- /* When the arrow that folds a block shows in the gutter. */
120
116
  foldOutline: 'off' | 'hover' | 'always';
121
117
  folding?: boolean;
122
- /* The headers of the blocks scrolled out of sight stay pinned on top; on unless false. */
123
118
  stickyScroll?: boolean;
124
119
  /* The words that mark a TODO comment; the default ones without them, none drawn with an empty list. */
125
120
  todoWords?: readonly string[];
@@ -159,18 +154,21 @@ const STICKY_MAX_LINES = 5;
159
154
  /* A view shows at most this share of its rows as sticky headers, so a small node keeps most of its text. */
160
155
  const STICKY_ROW_SHARE = 4;
161
156
 
157
+ /* Fills an element of the host's; what it returns runs once, when the element is taken away. */
158
+ type HostMount = (container: HTMLElement) => (() => void) | void;
159
+
162
160
  /* A range of lines that folds: the document's own, or one a person made of a selection. */
163
- export type ViewFold = Omit<FoldingRange, 'kind'> & { kind: FoldingRange['kind'] | 'custom' };
161
+ type ViewFold = Omit<FoldingRange, 'kind'> & { kind: FoldingRange['kind'] | 'custom' };
164
162
 
165
163
  /* A mark the host asked for, such as every use of the name under the caret. */
166
- export interface Occurrence {
164
+ interface Occurrence {
167
165
  from: number;
168
166
  to: number;
169
167
  kind?: EditorHighlightKind;
170
168
  }
171
169
 
172
170
  /* A stretch of text the language servers classified, anchored to offsets that follow the text through edits. */
173
- export interface ViewSemanticToken {
171
+ interface ViewSemanticToken {
174
172
  from: number;
175
173
  to: number;
176
174
  scopes: readonly string[];
@@ -178,7 +176,7 @@ export interface ViewSemanticToken {
178
176
  }
179
177
 
180
178
  /* A problem the host marked, anchored to offsets that follow the text through edits. */
181
- export interface GutterMarker {
179
+ interface GutterMarker {
182
180
  id: string;
183
181
  line: number;
184
182
  label: string;
@@ -186,7 +184,7 @@ export interface GutterMarker {
186
184
  pressed?: boolean;
187
185
  }
188
186
 
189
- export interface ViewMarker {
187
+ interface ViewMarker {
190
188
  severity: EditorMarkerSeverity;
191
189
  from: number;
192
190
  to: number;
@@ -269,8 +267,8 @@ export class EditorView {
269
267
  private remoteCarets: { id: string; name: string; color: string; at: number }[] = [];
270
268
  private remoteKey: string | null = null;
271
269
  /* The host's DOM after the last character of a line, by owner; `at` is the start of its line and follows the text through edits. */
272
- private readonly lineActions = new Map<string, { id: string; at: number; render: (container: HTMLElement) => void }[]>();
273
- private readonly actionElements = new Map<string, HTMLElement>();
270
+ private readonly lineActions = new Map<string, { id: string; at: number; render: HostMount }[]>();
271
+ private readonly actionElements = new Map<string, { element: HTMLElement; dispose: (() => void) | void }>();
274
272
  private readonly attributionListeners = new Set<(hover: { id: string; rect: EditorRect } | null) => void>();
275
273
  private readonly changeListeners = new Set<(hover: EditorChangeMarkHover | null) => void>();
276
274
  private changeHover: EditorChangeMarkHover | null = null;
@@ -309,12 +307,11 @@ export class EditorView {
309
307
  private activeGuideCache: { key: string; guide: { column: number; first: number; last: number } | null } | undefined;
310
308
  /* Column mode: a drag or Shift with the arrows selects a box of columns, as Alt does for a drag. */
311
309
  columnMode = false;
312
- /* A scroll on its way: where it started and ends, when, and the frame that moves it. */
313
310
  private scrollRun: { frame: number; from: { x: number; y: number }; to: { x: number; y: number }; start: number | null; duration: number } | null = null;
314
311
  private selectionOccurrenceCache: { key: string; ranges: readonly { from: number; to: number }[] } = { key: '', ranges: [] };
315
312
  private link: { from: number; to: number } | null = null;
316
313
  private composition: string | undefined;
317
- private ghost: { at: number; text: string; accessory: ((container: HTMLElement) => void) | undefined } | null = null;
314
+ private ghost: { at: number; text: string; accessory: HostMount | undefined } | null = null;
318
315
  private ghostSerial = 0;
319
316
  private foldRanges: ViewFold[] = [];
320
317
  /* The folds made of a selection, which follow their text through edits. */
@@ -507,7 +504,6 @@ export class EditorView {
507
504
  this.refreshFont();
508
505
  }
509
506
 
510
- /* The size the code is drawn at, in pixels. */
511
507
  getFontSize(): number {
512
508
  return this.font.size;
513
509
  }
@@ -1028,7 +1024,7 @@ export class EditorView {
1028
1024
  }
1029
1025
 
1030
1026
  /* A suggestion after the caret: its first line in the text, the rest in rows under the line, and the host's accessory after the first line. */
1031
- setGhost(ghost: { at: number; text: string; accessory: ((container: HTMLElement) => void) | undefined } | null): void {
1027
+ setGhost(ghost: { at: number; text: string; accessory: HostMount | undefined } | null): void {
1032
1028
  this.ghost = ghost === null || ghost.text === '' ? null : ghost;
1033
1029
  this.layoutGhostParts();
1034
1030
  this.configureText();
@@ -1067,7 +1063,8 @@ export class EditorView {
1067
1063
  at: ghost.at,
1068
1064
  render: (container) => {
1069
1065
  container.classList.add('se-ghost-accessory');
1070
- ghost.accessory?.(container);
1066
+
1067
+ return ghost.accessory?.(container);
1071
1068
  }
1072
1069
  }
1073
1070
  ]
@@ -1659,7 +1656,6 @@ export class EditorView {
1659
1656
  return candidates.find((at) => at >= 0 && /[()[\]{}]/.test(this.model.slice(at, at + 1)));
1660
1657
  }
1661
1658
 
1662
- /* The offset a bracket at the caret pairs with, if it is one. */
1663
1659
  matchingBracket(selection: { anchor: number; head: number }): { at: number; mate: number | undefined } | null {
1664
1660
  const at = this.bracketAt(selection);
1665
1661
 
@@ -1859,7 +1855,6 @@ export class EditorView {
1859
1855
  };
1860
1856
  }
1861
1857
 
1862
- /* The arrows of the soft wraps in the rows on screen. */
1863
1858
  private wrapSigns(rows: readonly LayoutRow[]): WrapSign[] {
1864
1859
  if (!this.layout.wrapping) {
1865
1860
  return [];
@@ -2052,7 +2047,6 @@ export class EditorView {
2052
2047
  return { plain, active: marked };
2053
2048
  }
2054
2049
 
2055
- /* The selection under a point of the screen, which a press there may drag away. */
2056
2050
  selectionAtPoint(clientX: number, clientY: number): EditorSelection | null {
2057
2051
  const point = this.contentPoint(clientX, clientY);
2058
2052
  const rows = this.layout.visibleRows(this.viewport.scrollTop, this.viewportHeight, 0);
@@ -2077,7 +2071,6 @@ export class EditorView {
2077
2071
  this.root.dataset.column = String(on);
2078
2072
  }
2079
2073
 
2080
- /* Where text being carried would land, drawn as a caret of its own. */
2081
2074
  setDropCaret(offset: number | null): void {
2082
2075
  this.dropCaret = offset;
2083
2076
  this.render();
@@ -2107,7 +2100,6 @@ export class EditorView {
2107
2100
  return { id: element.dataset.inlayId, part: part === null ? null : Number(part.dataset.part), element: part ?? element };
2108
2101
  }
2109
2102
 
2110
- /* Says which hint the pointer is on, or that it left them all. */
2111
2103
  setInlayHover(target: EventTarget | null): void {
2112
2104
  const found = this.inlayAt(target);
2113
2105
 
@@ -2320,7 +2312,6 @@ export class EditorView {
2320
2312
  this.revealOffset(this.model.getPrimary().head, kind);
2321
2313
  }
2322
2314
 
2323
- /* What a regular expression replacement writes for the match the find is on, drawn under that match; null takes it away. */
2324
2315
  setReplacePreview(replacement: string | null, preserveCase = false): void {
2325
2316
  this.replacePreview = replacement === null ? null : { text: replacement, preserveCase };
2326
2317
  this.find.setPreview(replacement !== null);
@@ -2891,7 +2882,7 @@ export class EditorView {
2891
2882
  }
2892
2883
 
2893
2884
  /* The host's own DOM after the end of a line, which stays on its line through edits until the owner sets its actions again. */
2894
- setLineActions(owner: string, actions: readonly { id: string; at: number; render: (container: HTMLElement) => void }[]): void {
2885
+ setLineActions(owner: string, actions: readonly { id: string; at: number; render: HostMount }[]): void {
2895
2886
  if (actions.length === 0) {
2896
2887
  if (!this.lineActions.has(owner)) {
2897
2888
  return;
@@ -2904,51 +2895,92 @@ export class EditorView {
2904
2895
 
2905
2896
  const wanted = new Set([...this.lineActions].flatMap(([name, entries]) => entries.map((entry) => `${name}\0${entry.id}`)));
2906
2897
 
2907
- for (const [key, element] of [...this.actionElements]) {
2898
+ for (const key of [...this.actionElements.keys()]) {
2908
2899
  if (!wanted.has(key)) {
2909
- element.remove();
2910
- this.actionElements.delete(key);
2900
+ this.removeActionElement(key);
2911
2901
  }
2912
2902
  }
2913
2903
 
2914
2904
  this.render();
2915
2905
  }
2916
2906
 
2907
+ /* Out of the map first, so a disposer that sets actions again finds the element gone. */
2908
+ private removeActionElement(key: string): void {
2909
+ const mounted = this.actionElements.get(key);
2910
+
2911
+ if (mounted === undefined) {
2912
+ return;
2913
+ }
2914
+
2915
+ this.actionElements.delete(key);
2916
+ mounted.element.remove();
2917
+ mounted.dispose?.();
2918
+ }
2919
+
2917
2920
  private paintLineActions(): void {
2921
+ for (const owner of this.lineActions.keys()) {
2922
+ // An owner that set its actions anew from inside a render is painted once more, with the new ones; a draw never nests.
2923
+ if (!this.paintOwnerActions(owner)) {
2924
+ this.paintOwnerActions(owner);
2925
+ }
2926
+ }
2927
+ }
2928
+
2929
+ /* False when the owner set its actions anew from inside a render, which leaves the rest of the list it was painting stale. */
2930
+ private paintOwnerActions(owner: string): boolean {
2918
2931
  const lineHeight = this.layout.metrics.lineHeight;
2919
2932
  const top = this.scrollTop;
2933
+ const entries = this.lineActions.get(owner) ?? [];
2934
+
2935
+ for (const entry of entries) {
2936
+ const key = `${owner}\0${entry.id}`;
2937
+ let element = this.actionElements.get(key)?.element;
2938
+
2939
+ if (element === undefined) {
2940
+ element = this.document.createElement('div');
2941
+ element.className = 'se-line-action';
2942
+ element.addEventListener('pointerdown', (event) => event.stopPropagation());
2943
+ element.addEventListener('mousedown', (event) => event.stopPropagation());
2944
+ this.actions.append(element);
2945
+ const mounted: { element: HTMLElement; dispose: (() => void) | void } = { element, dispose: undefined };
2946
+ this.actionElements.set(key, mounted);
2947
+ const dispose = entry.render(element);
2948
+
2949
+ // An owner that took the element away again from inside its own render gets it disposed at once.
2950
+ if (this.actionElements.get(key) !== mounted) {
2951
+ dispose?.();
2952
+
2953
+ if (this.lineActions.get(owner) !== entries) {
2954
+ return false;
2955
+ }
2920
2956
 
2921
- for (const [owner, entries] of this.lineActions) {
2922
- for (const entry of entries) {
2923
- const key = `${owner}\0${entry.id}`;
2924
- let element = this.actionElements.get(key);
2925
-
2926
- if (element === undefined) {
2927
- element = this.document.createElement('div');
2928
- element.className = 'se-line-action';
2929
- element.addEventListener('pointerdown', (event) => event.stopPropagation());
2930
- element.addEventListener('mousedown', (event) => event.stopPropagation());
2931
- this.actions.append(element);
2932
- this.actionElements.set(key, element);
2933
- entry.render(element);
2957
+ continue;
2934
2958
  }
2935
2959
 
2936
- const line = this.model.positionAt(entry.at).line;
2937
- const row = this.layout.rowForLine(line);
2938
- const place = row.kind === 'text' && row.line === line ? this.layout.caret(this.model.getLine(line).end) : null;
2939
-
2940
- if (place === null || place.y + lineHeight < top - this.viewportHeight || place.y > top + 2 * this.viewportHeight) {
2941
- element.hidden = true;
2960
+ mounted.dispose = dispose;
2942
2961
 
2943
- continue;
2962
+ if (this.lineActions.get(owner) !== entries) {
2963
+ return false;
2944
2964
  }
2965
+ }
2966
+
2967
+ const line = this.model.positionAt(entry.at).line;
2968
+ const row = this.layout.rowForLine(line);
2969
+ const place = row.kind === 'text' && row.line === line ? this.layout.caret(this.model.getLine(line).end) : null;
2970
+
2971
+ if (place === null || place.y + lineHeight < top - this.viewportHeight || place.y > top + 2 * this.viewportHeight) {
2972
+ element.hidden = true;
2945
2973
 
2946
- element.hidden = false;
2947
- element.style.left = `${Math.round(place.x) + LINE_ACTION_GAP}px`;
2948
- element.style.top = `${Math.round(place.y)}px`;
2949
- element.style.height = `${lineHeight}px`;
2974
+ continue;
2950
2975
  }
2976
+
2977
+ element.hidden = false;
2978
+ element.style.left = `${Math.round(place.x) + LINE_ACTION_GAP}px`;
2979
+ element.style.top = `${Math.round(place.y)}px`;
2980
+ element.style.height = `${lineHeight}px`;
2951
2981
  }
2982
+
2983
+ return true;
2952
2984
  }
2953
2985
 
2954
2986
  /* Bars in the gutter for runs of lines, which follow their text through edits until the host sets them again. */
@@ -3010,7 +3042,6 @@ export class EditorView {
3010
3042
  ];
3011
3043
  }
3012
3044
 
3013
- /* Code that is not in the document, drawn in the editor's own face and colors. */
3014
3045
  renderCode(container: HTMLElement, text: string, options: EditorCodeBlockOptions): void {
3015
3046
  renderCodeBlock(
3016
3047
  container,
@@ -3289,7 +3320,6 @@ export class EditorView {
3289
3320
  paintOverview(this.overview, overviewTicks(spans, this.layout.height, trackHeight));
3290
3321
  }
3291
3322
 
3292
- /* The blocks sticky scroll and the breadcrumb go by; null goes back to the editor's own reading. */
3293
3323
  setBlocks(blocks: readonly EditorBlock[] | null): void {
3294
3324
  this.outline.setProvided(blocks, this.model);
3295
3325
  this.render();
@@ -3481,7 +3511,6 @@ export class EditorView {
3481
3511
  emit(this.gutterActionListeners, line);
3482
3512
  }
3483
3513
 
3484
- /* The line a fold control in the gutter folds. */
3485
3514
  foldLineOf(target: EventTarget | null): number | null {
3486
3515
  const button = closestElement(target, '[data-fold-line]');
3487
3516
 
@@ -3523,7 +3552,11 @@ export class EditorView {
3523
3552
  this.tracked.clear();
3524
3553
  this.remoteCarets = [];
3525
3554
  this.lineActions.clear();
3526
- this.actionElements.clear();
3555
+
3556
+ for (const key of [...this.actionElements.keys()]) {
3557
+ this.removeActionElement(key);
3558
+ }
3559
+
3527
3560
  this.attribution.clear();
3528
3561
  this.highlights.clear();
3529
3562
  this.attributionListeners.clear();
package/src/zoom.ts CHANGED
@@ -2,8 +2,8 @@ import type { EditorFont } from './metrics.ts';
2
2
  import type { EditorZoom } from './types.ts';
3
3
 
4
4
  /* Nothing a person reads is smaller. */
5
- export const MIN_FONT_SIZE = 12;
6
- export const MAX_FONT_SIZE = 90;
5
+ const MIN_FONT_SIZE = 12;
6
+ const MAX_FONT_SIZE = 90;
7
7
  /* A trackpad or a pinch sends the wheel in small steps; this many pixels of them are one step of the size. */
8
8
  const PIXELS_PER_STEP = 20;
9
9