@bastani/atomic-tui 0.9.90-alpha.1 → 0.10.0-alpha.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 (50) hide show
  1. package/dist/builtin-command-names.d.ts +1 -1
  2. package/dist/builtin-command-names.d.ts.map +1 -1
  3. package/dist/builtin-command-names.js +0 -2
  4. package/dist/builtin-command-names.js.map +1 -1
  5. package/dist/clickable-hints.d.ts.map +1 -1
  6. package/dist/clickable-hints.js +75 -19
  7. package/dist/clickable-hints.js.map +1 -1
  8. package/dist/components/editor.d.ts +39 -0
  9. package/dist/components/editor.d.ts.map +1 -1
  10. package/dist/components/editor.js +110 -0
  11. package/dist/components/editor.js.map +1 -1
  12. package/dist/components/scroll-view.d.ts +17 -0
  13. package/dist/components/scroll-view.d.ts.map +1 -1
  14. package/dist/components/scroll-view.js +40 -0
  15. package/dist/components/scroll-view.js.map +1 -1
  16. package/dist/components/windowed-container.d.ts +87 -0
  17. package/dist/components/windowed-container.d.ts.map +1 -1
  18. package/dist/components/windowed-container.js +212 -3
  19. package/dist/components/windowed-container.js.map +1 -1
  20. package/dist/editor-component.d.ts +9 -0
  21. package/dist/editor-component.d.ts.map +1 -1
  22. package/dist/editor-component.js.map +1 -1
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +1 -1
  26. package/dist/index.js.map +1 -1
  27. package/dist/kill-ring.d.ts +2 -0
  28. package/dist/kill-ring.d.ts.map +1 -1
  29. package/dist/kill-ring.js +6 -0
  30. package/dist/kill-ring.js.map +1 -1
  31. package/dist/layout.d.ts.map +1 -1
  32. package/dist/layout.js +6 -1
  33. package/dist/layout.js.map +1 -1
  34. package/dist/tui-alt-screen.d.ts +45 -1
  35. package/dist/tui-alt-screen.d.ts.map +1 -1
  36. package/dist/tui-alt-screen.js +550 -48
  37. package/dist/tui-alt-screen.js.map +1 -1
  38. package/dist/tui-main-screen.d.ts +27 -1
  39. package/dist/tui-main-screen.d.ts.map +1 -1
  40. package/dist/tui-main-screen.js +216 -15
  41. package/dist/tui-main-screen.js.map +1 -1
  42. package/dist/tui.d.ts +56 -4
  43. package/dist/tui.d.ts.map +1 -1
  44. package/dist/tui.js +58 -7
  45. package/dist/tui.js.map +1 -1
  46. package/dist/undo-stack.d.ts +2 -0
  47. package/dist/undo-stack.d.ts.map +1 -1
  48. package/dist/undo-stack.js +6 -0
  49. package/dist/undo-stack.js.map +1 -1
  50. package/package.json +1 -1
@@ -2,7 +2,7 @@ import { AltScreenSearchComponent, AltScreenSearchIndex, getAltScreenSearchMatch
2
2
  import { hintActionAt, readHintSpans } from "./clickable-hints.js";
3
3
  import { AltScreenFlashContainer } from "./components/alt-screen-flash.js";
4
4
  import { ScrollView } from "./components/scroll-view.js";
5
- import { WindowedContainer } from "./components/windowed-container.js";
5
+ import { WindowedContainer, } from "./components/windowed-container.js";
6
6
  import { getKeybindings } from "./keybindings.js";
7
7
  import { isKeyRelease } from "./keys.js";
8
8
  import { getLayoutBoxesAt, getScrollbarGeometry, getScrollContentRows, getScrollViewBox, getScrollViewsAt, renderLayoutFrame, } from "./layout.js";
@@ -49,6 +49,74 @@ const COPY_ERROR_FLASH_DURATION_MS = 5000;
49
49
  // https://github.com/gnachman/iTerm2/blob/7f4ff739721f95d0b93003d8701c4523a7edf261/sources/Settings/iTermPreferences.m#L743
50
50
  const TERMINAL_WORD_SELECTION_JOINERS = new Set(["/", "-", "+", "\\", "~", "_", "."]);
51
51
  const wordSegmenter = getWordSegmenter();
52
+ /** Document order of two saved rows; a leaf without a row stands for its first row. */
53
+ function compareArchivedRows(a, b) {
54
+ return a.seq - b.seq || a.block - b.block || a.part - b.part || (a.line ?? 0) - (b.line ?? 0);
55
+ }
56
+ function archivedRowKey(p) {
57
+ return `${p.seq}:${p.block}:${p.part}:${p.line}`;
58
+ }
59
+ /** Printable ASCII styled only by SGR codes: every cell is one character, so a slice needs no grapheme walk. */
60
+ const PLAIN_STYLED_ROW = /^(?:\x1b\[[0-9;:]*m|[\x20-\x7e])*$/;
61
+ const SGR_CODES = /\x1b\[[0-9;:]*m/g;
62
+ const ONE_BYTE_TEXT = /^[\x00-\xff]*$/;
63
+ /** The plain text of cells `start` to `end` of a row: what slicing it by column and stripping its codes gives. */
64
+ function selectedCells(line, start, end) {
65
+ if (end <= start)
66
+ return "";
67
+ return PLAIN_STYLED_ROW.test(line)
68
+ ? line.replace(SGR_CODES, "").slice(start, end)
69
+ : stripTerminalSequences(sliceByColumn(line, start, end - start, true));
70
+ }
71
+ /** Whether a live row lies above (-1) or below (1) a saved run, or 0 when neither edge places it. */
72
+ function savedRunSide(edges, row) {
73
+ const below = edges.below?.();
74
+ if (below !== undefined && row >= below)
75
+ return 1;
76
+ const above = edges.above?.();
77
+ return above !== undefined && row <= above ? -1 : 0;
78
+ }
79
+ /** Sorted, disjoint inclusive ranges without one entry. */
80
+ function withoutEntry(ranges, seq) {
81
+ const kept = [];
82
+ for (const [a, b] of ranges) {
83
+ if (a < seq)
84
+ kept.push([a, Math.min(b, seq - 1)]);
85
+ if (b > seq)
86
+ kept.push([Math.max(a, seq + 1), b]);
87
+ }
88
+ return kept;
89
+ }
90
+ /** Add an inclusive range to sorted, disjoint ranges. */
91
+ function addRange(ranges, from, to) {
92
+ const merged = [];
93
+ let next = [from, to];
94
+ for (const range of [...ranges].sort((x, y) => x[0] - y[0])) {
95
+ if (range[1] + 1 < next[0] || next[1] + 1 < range[0])
96
+ merged.push([range[0], range[1]]);
97
+ else
98
+ next = [Math.min(next[0], range[0]), Math.max(next[1], range[1])];
99
+ }
100
+ merged.push(next);
101
+ return merged.sort((x, y) => x[0] - y[0]);
102
+ }
103
+ /** The parts of `from` through `to` that no range covers. */
104
+ function missingRanges(from, to, covered) {
105
+ const missing = [];
106
+ let next = from;
107
+ for (const [a, b] of covered) {
108
+ if (b < next)
109
+ continue;
110
+ if (a > to)
111
+ break;
112
+ if (a > next)
113
+ missing.push([next, Math.min(a - 1, to)]);
114
+ next = Math.max(next, b + 1);
115
+ }
116
+ if (next <= to)
117
+ missing.push([next, to]);
118
+ return missing;
119
+ }
52
120
  /** Whether the same components are drawn at the pointer in the same places: the frame's geometry there. */
53
121
  function samePointerGeometry(a, b) {
54
122
  return (a !== undefined &&
@@ -127,6 +195,14 @@ export class TuiAltScreen extends TuiBase {
127
195
  uploadedKittyImages = new Map();
128
196
  selectionAnchor;
129
197
  selectionFocus;
198
+ archiveSelection = new Map();
199
+ selectedFragments = new Map();
200
+ /** A saved run found between the two live endpoints of the selection. */
201
+ selectionRun;
202
+ /** Sequence ranges of saved entries whose selected rows were all captured while mounted. */
203
+ savedCoverage = [];
204
+ /** The saved range the coverage was captured for. */
205
+ savedCoverageBounds;
130
206
  selectionGranularity = "character";
131
207
  selectionInitialRange;
132
208
  lastClick;
@@ -166,6 +242,7 @@ export class TuiAltScreen extends TuiBase {
166
242
  searchNavigationButtonStyle;
167
243
  scrollToEndIndicator;
168
244
  scrollPinnedPrompt;
245
+ parkedPrompt;
169
246
  openUrl;
170
247
  onRightClickPaste;
171
248
  copyOnSelect;
@@ -214,14 +291,11 @@ export class TuiAltScreen extends TuiBase {
214
291
  }
215
292
  /** Whether the fullscreen viewport has a non-empty active text selection. */
216
293
  hasActiveSelection() {
217
- return this.getActiveSelectionText() !== undefined;
294
+ return this.getSelectionBounds() !== undefined;
218
295
  }
219
296
  /** Copy the active fullscreen text selection, if any, using the configured selection clipboard path. */
220
297
  async copyActiveSelectionToClipboard() {
221
- const text = this.getActiveSelectionText();
222
- if (!text)
223
- return false;
224
- return this.copyTextToClipboard(text);
298
+ return this.copyActiveSelection();
225
299
  }
226
300
  /** Drop the text selection and multi-click history, e.g. before the host replaces the transcript. */
227
301
  resetTextSelection() {
@@ -267,6 +341,7 @@ export class TuiAltScreen extends TuiBase {
267
341
  this.invalidate();
268
342
  }
269
343
  this.lastDocument = [];
344
+ this.clearSelectionFragments();
270
345
  this.selectionAnchor = undefined;
271
346
  this.selectionFocus = undefined;
272
347
  this.selectionGranularity = "character";
@@ -292,6 +367,7 @@ export class TuiAltScreen extends TuiBase {
292
367
  this.terminal.write(`${ENTER_ALT_SCREEN}${DISABLE_AUTOWRAP}${this.mouseEnabled ? mouseSequence : ""}\x1b[2J\x1b[H\x1b[?25l`);
293
368
  }
294
369
  beforeTerminalStop(_options) {
370
+ this.clearSelectionFragments();
295
371
  this.closeSearch();
296
372
  this.dropWaitingSingleClicks();
297
373
  this.stopSelectionAutoScroll();
@@ -663,7 +739,8 @@ export class TuiAltScreen extends TuiBase {
663
739
  this.mousePressFrame = undefined;
664
740
  this.mousePressMoved = false;
665
741
  }
666
- handleViewportInput(data) {
742
+ /** Handle a viewport report, optionally replayed from before a dialog answered raw input. */
743
+ handleViewportInput(data, receivedAt) {
667
744
  if (data === FOCUS_OUT) {
668
745
  this.dropWaitingSingleClicks();
669
746
  const hadActiveSelection = this.selectionPressActive;
@@ -680,6 +757,7 @@ export class TuiAltScreen extends TuiBase {
680
757
  this.selectionDragged = false;
681
758
  this.clearComponentMouseGesture();
682
759
  if (hadActiveSelection) {
760
+ this.clearSelectionFragments();
683
761
  this.selectionAnchor = undefined;
684
762
  this.selectionFocus = undefined;
685
763
  this.selectionGranularity = "character";
@@ -711,7 +789,7 @@ export class TuiAltScreen extends TuiBase {
711
789
  }
712
790
  const mouseEvent = this.parseSgrMouseEvent(data);
713
791
  if (mouseEvent) {
714
- this.handleMouseEvent(mouseEvent);
792
+ this.handleMouseEvent(mouseEvent, receivedAt);
715
793
  return { consume: true };
716
794
  }
717
795
  if (this.isMouseSequence(data))
@@ -889,7 +967,10 @@ export class TuiAltScreen extends TuiBase {
889
967
  if (clickTime() - press.timestamp <= MULTI_CLICK_INTERVAL_MS)
890
968
  break;
891
969
  this.waitingSingleClicks.delete(press);
892
- result.whenSingleClick?.();
970
+ if (press.overlayPress?.revoked)
971
+ result.onSingleClickCancel?.();
972
+ else
973
+ result.whenSingleClick?.();
893
974
  this.requestRender();
894
975
  }
895
976
  }
@@ -915,7 +996,15 @@ export class TuiAltScreen extends TuiBase {
915
996
  for (const start of this.waitingSingleClicks.keys())
916
997
  this.cancelWaitingSingleClicks(start);
917
998
  }
999
+ clearSelectionFragments() {
1000
+ this.selectedFragments.clear();
1001
+ this.archiveSelection.clear();
1002
+ this.selectionRun = undefined;
1003
+ this.savedCoverage = [];
1004
+ this.savedCoverageBounds = undefined;
1005
+ }
918
1006
  clearTextSelection() {
1007
+ this.clearSelectionFragments();
919
1008
  this.stopSelectionAutoScroll();
920
1009
  this.selectionPressActive = false;
921
1010
  this.selectionAnchor = undefined;
@@ -926,7 +1015,7 @@ export class TuiAltScreen extends TuiBase {
926
1015
  this.pressedHint = undefined;
927
1016
  this.selectionDragged = false;
928
1017
  }
929
- handleMouseEvent(raw) {
1018
+ handleMouseEvent(raw, receivedAt) {
930
1019
  const isMotion = (raw.button & 32) !== 0;
931
1020
  const type = raw.release
932
1021
  ? "release"
@@ -956,6 +1045,7 @@ export class TuiAltScreen extends TuiBase {
956
1045
  // same target still drawn where it was pressed, not another that took its place.
957
1046
  const click = this.lastClick;
958
1047
  if (click &&
1048
+ !click.overlayPress?.revoked &&
959
1049
  !this.mousePressMoved &&
960
1050
  this.mousePressPoint?.x === raw.x &&
961
1051
  this.mousePressPoint.y === raw.y &&
@@ -986,7 +1076,8 @@ export class TuiAltScreen extends TuiBase {
986
1076
  this.handleSelectionMouseEvent(raw, timestamp, previous);
987
1077
  return;
988
1078
  }
989
- const overlay = this.dispatchMouseToOverlay(event);
1079
+ const pressAt = type === "press" && event.button === "left" ? (receivedAt ?? this.overlayVisibilityVersion) : undefined;
1080
+ const overlay = this.dispatchMouseToOverlay(event, pressAt);
990
1081
  if (!overlay.hit) {
991
1082
  if (this.handleScrollToEndIndicatorMouseEvent(raw))
992
1083
  return;
@@ -1016,6 +1107,7 @@ export class TuiAltScreen extends TuiBase {
1016
1107
  wordEnd: raw.x,
1017
1108
  drawn: this.mousePressFrame.drawn,
1018
1109
  component: result.target.component,
1110
+ ...(overlay.press && { overlayPress: overlay.press }),
1019
1111
  });
1020
1112
  this.mousePressMoved = false;
1021
1113
  }
@@ -1025,7 +1117,7 @@ export class TuiAltScreen extends TuiBase {
1025
1117
  }
1026
1118
  if (this.handleRightClickPaste(raw))
1027
1119
  return;
1028
- this.handleSelectionMouseEvent(raw, timestamp, previous);
1120
+ this.handleSelectionMouseEvent(raw, timestamp, previous, overlay.press);
1029
1121
  }
1030
1122
  parseWheelEvent(data) {
1031
1123
  const sgr = /^\x1b\[<(\d+);(\d+);(\d+)[Mm]$/.exec(data);
@@ -1164,6 +1256,7 @@ export class TuiAltScreen extends TuiBase {
1164
1256
  const target = this.getScrollbarTargetAt(event.x, event.y);
1165
1257
  if (!target)
1166
1258
  return false;
1259
+ this.clearSelectionFragments();
1167
1260
  this.stopSelectionAutoScroll();
1168
1261
  this.selectionPressActive = false;
1169
1262
  this.selectionAnchor = undefined;
@@ -1199,9 +1292,26 @@ export class TuiAltScreen extends TuiBase {
1199
1292
  if (visibleBottom < visibleTop)
1200
1293
  return undefined;
1201
1294
  const pointerRow = Math.max(visibleTop, Math.min(visibleBottom, y));
1202
- const maxContentRow = Math.max(0, (getScrollContentRows(box)?.length ?? 1) - 1);
1295
+ const lines = getScrollContentRows(box);
1296
+ const maxContentRow = Math.max(0, (lines?.length ?? 1) - 1);
1297
+ const row = Math.max(0, Math.min(maxContentRow, scrollView.scrollTop + pointerRow - box.rect.y));
1298
+ const archive = scrollView.hasHistoryNavigation ? lines?.historyRow?.(row) : undefined;
1299
+ const anchor = scrollView.hasHistoryNavigation && !archive ? lines?.historyAnchor?.() : undefined;
1300
+ const side = anchor ? savedRunSide(anchor.edges, row) : 0;
1203
1301
  return {
1204
- row: Math.max(0, Math.min(maxContentRow, scrollView.scrollTop + pointerRow - box.rect.y)),
1302
+ row,
1303
+ ...(scrollView.hasHistoryNavigation ? { trackRow: lines?.trackRow?.(row), archive } : {}),
1304
+ ...(archive ? { edges: lines?.historyEdges?.(row) } : {}),
1305
+ ...(anchor && side
1306
+ ? {
1307
+ edges: anchor.edges,
1308
+ saved: {
1309
+ source: anchor.source,
1310
+ below: side > 0,
1311
+ ...(side < 0 && anchor.first ? { first: anchor.first } : {}),
1312
+ },
1313
+ }
1314
+ : {}),
1205
1315
  col: Math.max(0, Math.min(box.rect.width - 1, x - box.rect.x)),
1206
1316
  scrollView,
1207
1317
  };
@@ -1259,6 +1369,10 @@ export class TuiAltScreen extends TuiBase {
1259
1369
  };
1260
1370
  }
1261
1371
  updateSelectionFocus(point) {
1372
+ this.setSelectionFocus(point);
1373
+ this.captureVolatileSelection();
1374
+ }
1375
+ setSelectionFocus(point) {
1262
1376
  if (this.selectionGranularity === "character" || !this.selectionInitialRange) {
1263
1377
  this.selectionFocus = point;
1264
1378
  return;
@@ -1267,8 +1381,7 @@ export class TuiAltScreen extends TuiBase {
1267
1381
  if (!range)
1268
1382
  return;
1269
1383
  const initial = this.selectionInitialRange;
1270
- const targetBeforeInitial = range.start.row < initial.start.row ||
1271
- (range.start.row === initial.start.row && range.start.col < initial.start.col);
1384
+ const targetBeforeInitial = this.compareSelectionPoints(range.start, initial.start) < 0;
1272
1385
  if (targetBeforeInitial) {
1273
1386
  this.selectionAnchor = initial.end;
1274
1387
  this.selectionFocus = range.start;
@@ -1370,7 +1483,7 @@ export class TuiAltScreen extends TuiBase {
1370
1483
  this.selectionAutoScrollDirection = 0;
1371
1484
  this.selectionDragPointer = undefined;
1372
1485
  }
1373
- handleSelectionMouseEvent(event, timestamp, previous) {
1486
+ handleSelectionMouseEvent(event, timestamp, previous, overlayPress) {
1374
1487
  const button = event.button & 3;
1375
1488
  if (button !== 0 && !(event.release && button === 3))
1376
1489
  return;
@@ -1435,7 +1548,11 @@ export class TuiAltScreen extends TuiBase {
1435
1548
  this.requestRender();
1436
1549
  return;
1437
1550
  }
1438
- if (click && isClick && unchanged && !releaseFrame.decorated) {
1551
+ // For a repeat click in text selection only the handler knows whether it consumes the selected word or
1552
+ // line. Preserve that decision rather than guessing whether to write the clipboard.
1553
+ if (click?.count === 1 && click.overlayPress?.revoked)
1554
+ this.lastClick = undefined;
1555
+ else if (click && isClick && unchanged && !releaseFrame.decorated) {
1439
1556
  const clickEvent = this.createMouseEvent("click", event.button, event.x, event.y, {
1440
1557
  clickCount: click.count,
1441
1558
  });
@@ -1470,6 +1587,7 @@ export class TuiAltScreen extends TuiBase {
1470
1587
  return;
1471
1588
  }
1472
1589
  this.stopSelectionAutoScroll();
1590
+ this.clearSelectionFragments();
1473
1591
  this.selectionPressActive = true;
1474
1592
  const scrollView = !this.hasOverlay() && this.currentLayout
1475
1593
  ? getScrollViewsAt(this.currentLayout, event.x, event.y)[0]
@@ -1487,12 +1605,14 @@ export class TuiAltScreen extends TuiBase {
1487
1605
  wordStart: (word?.start.col ?? anchor.col) + offset,
1488
1606
  wordEnd: (word?.end.col ?? anchor.col) + offset,
1489
1607
  drawn: pressFrame.drawn,
1608
+ ...(overlayPress && { overlayPress }),
1490
1609
  });
1491
1610
  const range = clickCount === 2 ? word : clickCount === 3 ? this.getLineSelection(anchor) : undefined;
1492
1611
  this.selectionGranularity = range ? (clickCount === 2 ? "word" : "line") : "character";
1493
1612
  this.selectionInitialRange = range;
1494
1613
  this.selectionAnchor = range?.start ?? anchor;
1495
1614
  this.selectionFocus = range?.end ?? anchor;
1615
+ this.captureVolatileSelection();
1496
1616
  this.selectionDragged = false;
1497
1617
  this.pressFrame = pressFrame;
1498
1618
  this.pressedUrl = range
@@ -1515,16 +1635,35 @@ export class TuiAltScreen extends TuiBase {
1515
1635
  return undefined;
1516
1636
  if (this.selectionAnchor.scrollView !== this.selectionFocus.scrollView)
1517
1637
  return undefined;
1518
- const anchorBeforeFocus = this.selectionAnchor.row < this.selectionFocus.row ||
1519
- (this.selectionAnchor.row === this.selectionFocus.row && this.selectionAnchor.col < this.selectionFocus.col);
1520
- if (this.selectionAnchor.row === this.selectionFocus.row &&
1521
- this.selectionAnchor.col === this.selectionFocus.col) {
1638
+ this.selectionAnchor.row = this.selectionAnchor.trackRow?.() ?? this.selectionAnchor.row;
1639
+ this.selectionFocus.row = this.selectionFocus.trackRow?.() ?? this.selectionFocus.row;
1640
+ const order = this.compareSelectionPoints(this.selectionAnchor, this.selectionFocus);
1641
+ if (order === 0)
1522
1642
  return undefined;
1523
- }
1524
- return anchorBeforeFocus
1643
+ return order < 0
1525
1644
  ? { start: this.selectionAnchor, end: this.selectionFocus }
1526
1645
  : { start: this.selectionFocus, end: this.selectionAnchor };
1527
1646
  }
1647
+ /** Document order of two points. A saved row keeps its place against a live row after its page is released. */
1648
+ compareSelectionPoints(p, q) {
1649
+ const a = p.archive, b = q.archive;
1650
+ const pRow = p.trackRow?.() ?? p.row, qRow = q.trackRow?.() ?? q.row;
1651
+ let order = pRow - qRow;
1652
+ if (a && b && a.source === b.source)
1653
+ order = compareArchivedRows(a, b);
1654
+ else if (a || b) {
1655
+ const saved = (a ? q : p).saved;
1656
+ const edges = (a ? p : q).edges;
1657
+ const side = saved && saved.source === (a ?? b)?.source
1658
+ ? saved.below
1659
+ ? 1
1660
+ : -1
1661
+ : edges && savedRunSide(edges, a ? qRow : pRow);
1662
+ if (side)
1663
+ order = a ? -side : side;
1664
+ }
1665
+ return order || p.col - q.col;
1666
+ }
1528
1667
  getSelectionColumns(line, row, selection, minColumn = 0, maxColumn = visibleWidth(line)) {
1529
1668
  const lineWidth = visibleWidth(line);
1530
1669
  let start = Math.max(0, minColumn);
@@ -1539,34 +1678,345 @@ export class TuiAltScreen extends TuiBase {
1539
1678
  }
1540
1679
  return { start: Math.max(minColumn, start), end: Math.min(maxColumn, end) };
1541
1680
  }
1681
+ captureVolatileSelection() {
1682
+ const selection = this.getSelectionBounds();
1683
+ if (!selection) {
1684
+ this.clearSelectionFragments();
1685
+ return;
1686
+ }
1687
+ const span = this.savedSpanOf(selection);
1688
+ for (const [key, fragment] of this.archiveSelection)
1689
+ if (!span || !this.savedSelects(fragment.position, span))
1690
+ this.archiveSelection.delete(key);
1691
+ // When an end of the selection moves outward, the entry it was on holds rows that were never captured.
1692
+ const old = this.savedCoverageBounds;
1693
+ let coverage = span && span.source === old?.source ? this.savedCoverage : [];
1694
+ if (span && old && coverage.length) {
1695
+ if (old.from && (!span.from || compareArchivedRows(span.from, old.from) < 0))
1696
+ coverage = withoutEntry(coverage, old.from.seq);
1697
+ if (old.to && (!span.to || compareArchivedRows(span.to, old.to) > 0))
1698
+ coverage = withoutEntry(coverage, old.to.seq);
1699
+ }
1700
+ this.savedCoverage = coverage;
1701
+ this.savedCoverageBounds = span && { source: span.source, from: span.from, to: span.to };
1702
+ for (const [key, fragment] of this.selectedFragments) {
1703
+ const base = fragment.part === "anchor"
1704
+ ? this.selectionAnchor?.row
1705
+ : fragment.part === "below"
1706
+ ? span?.edges?.below?.()
1707
+ : span?.edges?.above?.();
1708
+ if (base === undefined || !this.holdsLiveRow(base + fragment.offset, selection, span))
1709
+ this.selectedFragments.delete(key);
1710
+ }
1711
+ this.capturePaintedFragments(selection, this.currentLayout, true);
1712
+ }
1713
+ /** The saved rows a selection holds, as a range of saved positions, and the live rows around them. */
1714
+ savedSpanOf(selection) {
1715
+ const { start, end } = selection;
1716
+ const a = start.archive, b = end.archive;
1717
+ if (a && b)
1718
+ return a.source === b.source
1719
+ ? { source: a.source, edges: start.edges ?? end.edges, from: a, to: b, liveAbove: false, liveBelow: false }
1720
+ : undefined;
1721
+ if (a)
1722
+ return { source: a.source, edges: start.edges, from: a, liveAbove: false, liveBelow: true };
1723
+ if (b) {
1724
+ // A live start above saved rows holds them from the first one that was mounted below it when it was placed.
1725
+ const from = start.saved?.source === b.source ? start.saved.first : undefined;
1726
+ if (start.saved?.source === b.source && !from)
1727
+ return undefined;
1728
+ return {
1729
+ source: b.source,
1730
+ edges: end.edges,
1731
+ ...(from ? { from } : {}),
1732
+ to: b,
1733
+ liveAbove: true,
1734
+ liveBelow: false,
1735
+ };
1736
+ }
1737
+ const above = start.saved, below = end.saved;
1738
+ if (above && below && above.source === below.source && !above.below && below.below) {
1739
+ return above.first
1740
+ ? { source: above.source, edges: end.edges, from: above.first, liveAbove: true, liveBelow: true }
1741
+ : { source: above.source, edges: end.edges, liveAbove: true, liveBelow: true, empty: true };
1742
+ }
1743
+ const run = this.selectionRun;
1744
+ const top = run?.above?.(), bottom = run?.below?.();
1745
+ return run && top !== undefined && bottom !== undefined && start.row <= top && bottom <= end.row
1746
+ ? { source: run.source, edges: run, liveAbove: true, liveBelow: true }
1747
+ : undefined;
1748
+ }
1749
+ savedSelects(position, span) {
1750
+ return (!span.empty &&
1751
+ position.source === span.source &&
1752
+ (!span.from || compareArchivedRows(position, span.from) >= 0) &&
1753
+ (!span.to || compareArchivedRows(position, span.to) <= 0));
1754
+ }
1755
+ /** Whether the selection holds a live row: one before the saved rows it spans, or after them. */
1756
+ holdsLiveRow(row, selection, span) {
1757
+ const { start, end } = selection;
1758
+ if (!span)
1759
+ return row >= start.row && row <= end.row;
1760
+ if (span.liveAbove && row >= start.row && row <= (span.edges?.above?.() ?? -1))
1761
+ return true;
1762
+ return span.liveBelow && row >= (span.edges?.below?.() ?? Number.POSITIVE_INFINITY) && row <= end.row;
1763
+ }
1764
+ /** The columns of the live endpoints only; an archived endpoint's row number may be out of date. */
1765
+ liveColumnsSelection(selection) {
1766
+ const { start, end } = selection;
1767
+ return {
1768
+ start: start.archive ? { ...start, row: -1 } : start,
1769
+ end: end.archive ? { ...end, row: -1 } : end,
1770
+ };
1771
+ }
1772
+ liveFragmentKey(row, span) {
1773
+ const below = span?.edges?.below?.();
1774
+ if (below !== undefined && row >= below)
1775
+ return { part: "below", offset: row - below };
1776
+ const above = span?.edges?.above?.();
1777
+ if (above !== undefined && row <= above)
1778
+ return { part: "above", offset: row - above };
1779
+ return { part: "anchor", offset: row - (this.selectionAnchor?.row ?? 0) };
1780
+ }
1781
+ capturePaintedFragments(selection, layout, full = false) {
1782
+ const view = selection.start.scrollView;
1783
+ if (!layout || !view)
1784
+ return;
1785
+ const rows = getScrollContentRows(getScrollViewBox(layout, view));
1786
+ if (!rows?.visitVolatileRows)
1787
+ return;
1788
+ const { start, end } = selection;
1789
+ const live = !start.archive && !end.archive;
1790
+ let span = this.savedSpanOf(selection);
1791
+ const top = view.scrollTop, bottom = top + view.viewportHeight - 1;
1792
+ let looked = false;
1793
+ const visit = (row, line, renderer, position) => {
1794
+ if (position && !span && !looked && live && row >= start.row && row <= end.row) {
1795
+ looked = true;
1796
+ this.selectionRun = rows.historyEdges?.(row);
1797
+ span = this.savedSpanOf(selection);
1798
+ }
1799
+ if (position && position.source === span?.source) {
1800
+ if (this.savedSelects(position, span))
1801
+ this.captureSavedRow(position, line, selection);
1802
+ return;
1803
+ }
1804
+ if (row >= top && row <= bottom && this.holdsLiveRow(row, selection, span))
1805
+ this.captureLiveRow(row, line, renderer, selection, span);
1806
+ };
1807
+ rows.visitVolatileRows(top, bottom, visit);
1808
+ if (!full)
1809
+ return;
1810
+ // A selection can span more than one screen, and a jump can release a page before it is painted again. Seal
1811
+ // the selected cells of every mounted saved row as the user selects, drawing those the background sweep has
1812
+ // not reached; plain repaint and merely asking whether a selection exists do not perform this work. Never
1813
+ // request an unmounted archive page here.
1814
+ if (!span && live && view.hasHistoryNavigation && !this.selectionPressActive)
1815
+ rows.visitVolatileRows(start.row, end.row, visit);
1816
+ const inside = span && !span.empty ? this.rowInsideRun(span, selection) : undefined;
1817
+ if (span && inside !== undefined && rows.visitHistoryRun) {
1818
+ const saved = span;
1819
+ let first = Number.POSITIVE_INFINITY, last = Number.NEGATIVE_INFINITY;
1820
+ const provisional = new Set();
1821
+ rows.visitHistoryRun(inside, saved.from, saved.to, (line, position) => {
1822
+ if (position.source !== saved.source || !this.savedSelects(position, saved))
1823
+ return;
1824
+ this.captureSavedRow(position, line, selection);
1825
+ first = Math.min(first, position.seq);
1826
+ last = Math.max(last, position.seq);
1827
+ if (position.provisional)
1828
+ provisional.add(position.seq);
1829
+ });
1830
+ // Every mounted saved leaf of these entries is now captured, but for provisional ones: a copy draws only the
1831
+ // rest again.
1832
+ if (first <= last && this.savedCoverageBounds?.source === saved.source) {
1833
+ let coverage = addRange(this.savedCoverage, first, last);
1834
+ for (const seq of provisional)
1835
+ coverage = withoutEntry(coverage, seq);
1836
+ this.savedCoverage = coverage;
1837
+ }
1838
+ }
1839
+ else if (start.archive && end.archive && start.archive.source === end.archive.source)
1840
+ rows.visitVolatileRows(start.trackRow?.() ?? top, end.trackRow?.() ?? bottom, visit);
1841
+ }
1842
+ /** A row of the mounted part of a saved run, if any of it is mounted. */
1843
+ rowInsideRun(span, selection) {
1844
+ for (const point of [selection.start, selection.end]) {
1845
+ const row = point.archive?.source === span.source ? point.trackRow?.() : undefined;
1846
+ if (row !== undefined)
1847
+ return row;
1848
+ }
1849
+ if (!span.edges)
1850
+ return undefined;
1851
+ if (!span.edges.above)
1852
+ return 0;
1853
+ const above = span.edges.above();
1854
+ return above === undefined ? undefined : above + 1;
1855
+ }
1856
+ /** The selected text of a saved row, with the columns of an archived endpoint on its own row. */
1857
+ savedRowText(position, line, selection, old) {
1858
+ const a = selection.start.archive, b = selection.end.archive;
1859
+ const first = a?.source === position.source && !compareArchivedRows(position, a), last = b?.source === position.source && !compareArchivedRows(position, b);
1860
+ const { start, end } = this.getSelectionColumns(line, 0, {
1861
+ start: { ...selection.start, row: first ? 0 : -1 },
1862
+ end: { ...selection.end, row: last ? 0 : 1 },
1863
+ });
1864
+ const slice = (s, p, n) => selectedCells(s, p, p + n);
1865
+ const before = old ? Math.max(start, old.start) : end, after = old ? Math.min(end, old.end) : start;
1866
+ const text = old && after > before
1867
+ ? slice(line, start, before - start) +
1868
+ slice(old.text, before - old.start, after - before) +
1869
+ slice(line, after, end - after)
1870
+ : slice(line, start, end - start);
1871
+ return { start, end, text, whole: !first && !last };
1872
+ }
1873
+ captureSavedRow(position, line, selection) {
1874
+ // What a provisional row shows depends on the pages mounted now; a copy draws its entry instead.
1875
+ if (position.provisional)
1876
+ return;
1877
+ const a = selection.start.archive, b = selection.end.archive;
1878
+ const key = archivedRowKey(position), old = this.archiveSelection.get(key);
1879
+ // A row between the endpoints is selected whole; once captured, it stays as it was selected.
1880
+ const edge = (a?.source === position.source && !compareArchivedRows(position, a)) ||
1881
+ (b?.source === position.source && !compareArchivedRows(position, b));
1882
+ if (old?.whole && !edge)
1883
+ return;
1884
+ const next = this.savedRowText(position, line, selection, old);
1885
+ if (old && old.start === next.start && old.end === next.end)
1886
+ return;
1887
+ // Detach narrow selections from potentially large source strings, preserving UTF-16 code units, and keep
1888
+ // one-byte text one byte per character.
1889
+ const encoding = ONE_BYTE_TEXT.test(next.text) ? "latin1" : "utf16le";
1890
+ this.archiveSelection.set(key, {
1891
+ position,
1892
+ ...next,
1893
+ text: Buffer.from(next.text, encoding).toString(encoding),
1894
+ });
1895
+ }
1896
+ captureLiveRow(row, line, renderer, selection, span) {
1897
+ const { start, end } = this.getSelectionColumns(line, row, this.liveColumnsSelection(selection));
1898
+ const position = this.liveFragmentKey(row, span);
1899
+ const key = `${position.part}:${position.offset}`;
1900
+ const previous = this.selectedFragments.get(key);
1901
+ // The same live component can publish new text. A recreated historical component, however, cannot
1902
+ // reproduce its predecessor's private state: preserve the overlap that was already selected.
1903
+ const replay = previous && previous.renderer !== renderer ? previous : undefined;
1904
+ if (replay && replay.start === start && replay.end === end)
1905
+ return;
1906
+ const slice = selectedCells;
1907
+ let text;
1908
+ if (!replay || start >= replay.end || end <= replay.start)
1909
+ text = slice(line, start, end);
1910
+ else {
1911
+ const from = Math.max(start, replay.start), to = Math.min(end, replay.end);
1912
+ text =
1913
+ slice(line, start, from) +
1914
+ slice(replay.text, from - replay.start, to - replay.start) +
1915
+ slice(line, to, end);
1916
+ }
1917
+ this.selectedFragments.set(key, { ...position, renderer: replay?.renderer ?? renderer, start, end, text });
1918
+ }
1919
+ /** The selected text of the saved rows, in document order: what was captured as the user selected it, and what
1920
+ * a copy draws on request for the selected entries that were released before they were ever captured. */
1921
+ savedSelectionText(span, selection, anchor) {
1922
+ const rows = [];
1923
+ for (const fragment of this.archiveSelection.values())
1924
+ if (this.savedSelects(fragment.position, span))
1925
+ rows.push(fragment);
1926
+ const ordered = () => rows.sort((x, y) => compareArchivedRows(x.position, y.position)).map((row) => row.text.trimEnd());
1927
+ const missing = span.from && anchor?.source === span.source
1928
+ ? missingRanges(span.from.seq, Math.min(span.to?.seq ?? anchor.last, anchor.last), this.savedCoverage)
1929
+ : [];
1930
+ if (!anchor || missing.length === 0)
1931
+ return ordered();
1932
+ const captured = new Set(this.archiveSelection.keys());
1933
+ return (async () => {
1934
+ for (const [from, to] of missing) {
1935
+ for (const block of await anchor.read(from, to)) {
1936
+ for (let line = 0; line < block.lines.length; line++) {
1937
+ const position = { ...block.position, line };
1938
+ if (!this.savedSelects(position, span) || captured.has(archivedRowKey(position)))
1939
+ continue;
1940
+ rows.push({ position, text: this.savedRowText(position, block.lines[line], selection).text });
1941
+ }
1942
+ }
1943
+ }
1944
+ return ordered();
1945
+ })();
1946
+ }
1947
+ /** The selected text, at once unless saved entries the selection holds must be drawn first. */
1542
1948
  getActiveSelectionText() {
1949
+ // Fill in what the selection holds that is still mounted, as the user asks for it.
1950
+ this.captureVolatileSelection();
1543
1951
  const selection = this.getSelectionBounds();
1544
1952
  if (!selection)
1545
1953
  return undefined;
1954
+ const { start, end } = selection;
1546
1955
  let sourceLines = this.previousScreen;
1547
- if (selection.start.scrollView) {
1956
+ if (start.scrollView) {
1548
1957
  if (!this.currentLayout)
1549
1958
  return undefined;
1550
- const rows = getScrollContentRows(getScrollViewBox(this.currentLayout, selection.start.scrollView));
1959
+ const rows = getScrollContentRows(getScrollViewBox(this.currentLayout, start.scrollView));
1551
1960
  if (!rows)
1552
1961
  return undefined;
1553
1962
  sourceLines = rows;
1554
1963
  }
1555
- const lines = [];
1556
- for (let row = selection.start.row; row <= selection.end.row; row++) {
1557
- const line = sourceLines.at(row) ?? "";
1558
- const columns = this.getSelectionColumns(line, row, selection);
1559
- lines.push(stripTerminalSequences(sliceByColumn(line, columns.start, Math.max(0, columns.end - columns.start), true)).trimEnd());
1560
- }
1561
- const text = lines.join("\n");
1562
- return text.length === 0 ? undefined : text;
1964
+ const span = this.savedSpanOf(selection);
1965
+ const columns = this.liveColumnsSelection(selection);
1966
+ const live = (from, to) => {
1967
+ const lines = [];
1968
+ for (let row = from; row <= to; row++) {
1969
+ const { part, offset } = this.liveFragmentKey(row, span);
1970
+ const pinned = this.selectedFragments.get(`${part}:${offset}`);
1971
+ if (pinned) {
1972
+ lines.push(pinned.text.trimEnd());
1973
+ continue;
1974
+ }
1975
+ const line = sourceLines.at(row) ?? "";
1976
+ const { start, end } = this.getSelectionColumns(line, row, columns);
1977
+ lines.push(stripTerminalSequences(sliceByColumn(line, start, Math.max(0, end - start), true)).trimEnd());
1978
+ }
1979
+ return lines;
1980
+ };
1981
+ // Rows of a saved run come from the selected text kept or drawn for them; the live rows around it are read in
1982
+ // place, before anything is awaited.
1983
+ const above = span?.liveAbove ? span.edges?.above?.() : undefined, below = span?.liveBelow ? span.edges?.below?.() : undefined;
1984
+ const anchor = span && !span.empty ? sourceLines.historyAnchor?.() : undefined;
1985
+ const composed = span &&
1986
+ (span.liveAbove ? above !== undefined : true) &&
1987
+ (span.liveBelow ? below !== undefined : true) &&
1988
+ (span.liveAbove || span.liveBelow || this.archiveSelection.size > 0 || anchor?.source === span.source);
1989
+ if (!composed) {
1990
+ const text = live(start.row, end.row).join("\n");
1991
+ return text.length === 0 ? undefined : text;
1992
+ }
1993
+ const head = above !== undefined ? live(start.row, above) : [];
1994
+ const tail = below !== undefined ? live(below, end.row) : [];
1995
+ const join = (saved) => {
1996
+ const text = [...head, ...saved, ...tail].join("\n");
1997
+ return text.length === 0 ? undefined : text;
1998
+ };
1999
+ const saved = span.empty ? [] : this.savedSelectionText(span, selection, anchor);
2000
+ return Array.isArray(saved) ? join(saved) : saved.then(join);
1563
2001
  }
1564
- async copySelectionToClipboard() {
1565
- const text = this.getActiveSelectionText();
2002
+ async copyActiveSelection() {
2003
+ let text;
2004
+ try {
2005
+ // Copy in the same turn when nothing has to be drawn.
2006
+ const selected = this.getActiveSelectionText();
2007
+ text = typeof selected === "object" ? await selected : selected;
2008
+ }
2009
+ catch (error) {
2010
+ this.flash(`Copy failed: ${error instanceof Error ? error.message : String(error)}`, COPY_ERROR_FLASH_DURATION_MS);
2011
+ return false;
2012
+ }
1566
2013
  if (!text)
1567
2014
  return false;
1568
2015
  return this.copyTextToClipboard(text);
1569
2016
  }
2017
+ copySelectionToClipboard() {
2018
+ return this.copyActiveSelection();
2019
+ }
1570
2020
  async copyTextToClipboard(text) {
1571
2021
  // Prefer an injected clipboard implementation (native clipboard + platform tools with a
1572
2022
  // verified success path) when the host app provides one. A bare OSC 52 write can show
@@ -1684,16 +2134,31 @@ export class TuiAltScreen extends TuiBase {
1684
2134
  }
1685
2135
  return `${result}\x1b[27m`;
1686
2136
  }
2137
+ /** Where the painted selection starts and ends. A saved endpoint whose page was released is painted from the
2138
+ * edge of what remains of its run, so the rows it still selects stay highlighted. */
2139
+ paintedSelectionEnds(selection, box) {
2140
+ let { start, end } = selection;
2141
+ if (start.archive && start.trackRow?.() === undefined && start.edges)
2142
+ start = { ...start, row: (start.edges.above?.() ?? -1) + 1, col: 0, boundary: false };
2143
+ if (end.archive && end.trackRow?.() === undefined && end.edges) {
2144
+ const rows = getScrollContentRows(box)?.length ?? 0;
2145
+ end = { ...end, row: (end.edges.below?.() ?? rows) - 1, col: Number.MAX_SAFE_INTEGER, boundary: true };
2146
+ }
2147
+ return { start, end };
2148
+ }
1687
2149
  applySelection(screen, layout = this.currentLayout) {
1688
2150
  this.highlightedRows.clear();
1689
2151
  const selection = this.getSelectionBounds();
1690
2152
  if (!selection)
1691
2153
  return screen;
2154
+ this.capturePaintedFragments(selection, layout);
1692
2155
  let screenSelection = selection;
1693
2156
  let minRow = 0;
1694
2157
  let maxRow = screen.length - 1;
1695
2158
  let minColumn = 0;
1696
2159
  let maxColumn = this.terminal.columns;
2160
+ /** Whether a screen row shows a saved row outside the selected ones. */
2161
+ let unselectedSaved = (_row) => false;
1697
2162
  if (selection.start.scrollView) {
1698
2163
  if (!layout)
1699
2164
  return screen;
@@ -1704,25 +2169,27 @@ export class TuiAltScreen extends TuiBase {
1704
2169
  maxRow = Math.min(screen.length - 1, box.rect.y + box.rect.height - 1, box.clip.y + box.clip.height - 1);
1705
2170
  minColumn = Math.max(0, box.rect.x, box.clip.x);
1706
2171
  maxColumn = Math.min(this.terminal.columns, box.rect.x + box.rect.width, box.clip.x + box.clip.width);
2172
+ const top = box.rect.y - selection.start.scrollView.scrollTop;
2173
+ const { start, end } = this.paintedSelectionEnds(selection, box);
1707
2174
  screenSelection = {
1708
- start: {
1709
- ...selection.start,
1710
- row: box.rect.y + selection.start.row - selection.start.scrollView.scrollTop,
1711
- col: box.rect.x + selection.start.col,
1712
- },
1713
- end: {
1714
- ...selection.end,
1715
- row: box.rect.y + selection.end.row - selection.start.scrollView.scrollTop,
1716
- col: box.rect.x + selection.end.col,
1717
- },
2175
+ start: { ...start, row: top + start.row, col: box.rect.x + start.col },
2176
+ end: { ...end, row: top + end.row, col: box.rect.x + end.col },
1718
2177
  };
2178
+ const rows = getScrollContentRows(box);
2179
+ const span = this.savedSpanOf(selection);
2180
+ if (span && rows?.historyRow)
2181
+ unselectedSaved = (row) => {
2182
+ const position = rows.historyRow?.(row - top);
2183
+ return position?.source === span.source && !this.savedSelects(position, span);
2184
+ };
1719
2185
  }
1720
2186
  return screen.map((line, row) => {
1721
2187
  if (row < minRow ||
1722
2188
  row > maxRow ||
1723
2189
  row < screenSelection.start.row ||
1724
2190
  row > screenSelection.end.row ||
1725
- isImageLine(line)) {
2191
+ isImageLine(line) ||
2192
+ unselectedSaved(row)) {
1726
2193
  return line;
1727
2194
  }
1728
2195
  const lineWidth = visibleWidth(line);
@@ -1824,6 +2291,41 @@ export class TuiAltScreen extends TuiBase {
1824
2291
  screen = this.compositeScrollToEndIndicator(screen, layout, width);
1825
2292
  return this.compositeScrollPinnedPrompt(screen, layout, width);
1826
2293
  }
2294
+ /** Keep a turn's pinned prompt while the rows [first, end) stay mounted but their preceding prompt leaves the
2295
+ * transcript. The painted line and two weak row positions do not retain the prompt component or its page. */
2296
+ keepScrollPinnedPrompt(first, end) {
2297
+ const pin = this.scrollPinnedPrompt;
2298
+ const view = this.getPrimaryScrollView();
2299
+ const lines = this.currentLayout && getScrollContentRows(getScrollViewBox(this.currentLayout, view));
2300
+ if (!pin || !lines?.trackRow || view.isFollowingEnd || first >= end)
2301
+ return;
2302
+ const row = this.pinnedPromptAt(lines, first, pin.isPrompt);
2303
+ this.parkedPrompt = undefined;
2304
+ if (!row)
2305
+ return;
2306
+ // A later turn in the same kept page has its own prompt; never show this one over it.
2307
+ let next = first;
2308
+ while (next < end && !pin.isPrompt(lines.at(next) ?? ""))
2309
+ next++;
2310
+ const start = lines.trackRow(first);
2311
+ const last = next > first && lines.trackRow(next - 1);
2312
+ if (start && last)
2313
+ this.parkedPrompt = { view: new WeakRef(view), row, first: start, last };
2314
+ }
2315
+ pinnedPromptAt(lines, top, isPrompt) {
2316
+ const prompt = turnPromptAbove(lines, top, isPrompt);
2317
+ if (prompt !== undefined || isPrompt(lines.at(top) ?? ""))
2318
+ return prompt;
2319
+ const parked = this.parkedPrompt;
2320
+ if (!parked || parked.view.deref() !== this.getPrimaryScrollView())
2321
+ return undefined;
2322
+ const first = parked.first(), last = parked.last();
2323
+ if (first === undefined || last === undefined) {
2324
+ this.parkedPrompt = undefined;
2325
+ return undefined;
2326
+ }
2327
+ return top >= first && top <= last ? parked.row : undefined;
2328
+ }
1827
2329
  compositeScrollPinnedPrompt(screen, layout, width) {
1828
2330
  if (!this.scrollPinnedPrompt)
1829
2331
  return screen;
@@ -1838,7 +2340,7 @@ export class TuiAltScreen extends TuiBase {
1838
2340
  if (!clip || !lines || clip.width <= 0 || clip.height < 2)
1839
2341
  return screen;
1840
2342
  const pin = this.scrollPinnedPrompt;
1841
- const promptRow = turnPromptAbove(lines, scrollView.scrollTop, pin.isPrompt);
2343
+ const promptRow = this.pinnedPromptAt(lines, scrollView.scrollTop, pin.isPrompt);
1842
2344
  if (promptRow === undefined)
1843
2345
  return screen;
1844
2346
  const row = clip.y;