stream-monaco 0.0.3 → 0.0.5

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 (3) hide show
  1. package/dist/index.cjs +488 -175
  2. package/dist/index.js +488 -175
  3. package/package.json +5 -5
package/dist/index.cjs CHANGED
@@ -231,38 +231,22 @@ const monaco = monaco_editor;
231
231
  //#endregion
232
232
  //#region src/utils/logger.ts
233
233
  let seq = 0;
234
- const ENABLED = (() => {
235
- try {
236
- if (typeof window !== "undefined" && window.__STREAM_MONACO_DEBUG__ !== void 0) return Boolean(window.__STREAM_MONACO_DEBUG__);
237
- try {
238
- const proc = node_process.default;
239
- if (proc && proc.env && proc.env.NODE_ENV !== "production") return true;
240
- } catch {}
241
- } catch {}
234
+ const DEBUG = (() => {
235
+ if (typeof window !== "undefined" && window.__STREAM_MONACO_DEBUG__ !== void 0) return Boolean(window.__STREAM_MONACO_DEBUG__);
236
+ const proc = node_process.default;
237
+ if (proc && proc.env && proc.env.NODE_ENV === "production") return false;
242
238
  return false;
243
239
  })();
244
240
  function log(tag, ...args) {
245
- if (!ENABLED) return;
246
- try {
247
- seq += 1;
248
- const id = `#${seq}`;
249
- const ts = typeof performance !== "undefined" && performance.now ? performance.now().toFixed(1) : Date.now();
250
- console.warn(`${id} [${tag}] @${ts}ms`, ...args);
251
- } catch (err) {
252
- try {
253
- console.warn("[logger] fallback", tag, ...args, err);
254
- } catch {}
255
- }
241
+ if (!DEBUG) return;
242
+ seq += 1;
243
+ const id = `#${seq}`;
244
+ const ts = typeof performance !== "undefined" && performance.now ? performance.now().toFixed(1) : Date.now();
245
+ console.warn(`${id} [${tag}] @${ts}ms`, ...args);
256
246
  }
257
247
  function error(tag, ...args) {
258
- if (!ENABLED) return;
259
- try {
260
- console.error(`[${tag}]`, ...args);
261
- } catch (err) {
262
- try {
263
- console.error("[logger] fallback error", tag, ...args, err);
264
- } catch {}
265
- }
248
+ if (!DEBUG) return;
249
+ console.error(`[${tag}]`, ...args);
266
250
  }
267
251
 
268
252
  //#endregion
@@ -382,41 +366,45 @@ function createRafScheduler(timeSource) {
382
366
  //#region src/utils/scroll.ts
383
367
  function createScrollWatcherForEditor(ed, opts) {
384
368
  var _ed$getScrollTop, _ed$onDidScrollChange;
385
- const DEBUG = (() => {
386
- try {
387
- if (typeof window !== "undefined" && window.__STREAM_MONACO_DEBUG__ !== void 0) return Boolean(window.__STREAM_MONACO_DEBUG__);
388
- try {
389
- const proc = node_process.default;
390
- if (proc && proc.env && proc.env.NODE_ENV === "production") return false;
391
- } catch {}
392
- } catch {}
393
- return true;
394
- })();
395
369
  const initial = ((_ed$getScrollTop = ed.getScrollTop) === null || _ed$getScrollTop === void 0 ? void 0 : _ed$getScrollTop.call(ed)) ?? 0;
396
370
  opts.setLast(initial);
397
- if (DEBUG) log("scrollWatcher", "initial scrollTop=", initial);
371
+ log("scrollWatcher", "initial scrollTop=", initial);
398
372
  let suppressedExternally = false;
399
373
  const THRESHOLD_PX = 6;
374
+ let domNode = null;
375
+ let interactionListener = null;
400
376
  const listener = (e) => {
401
377
  var _ed$getScrollTop2;
402
378
  if (suppressedExternally) {
403
- if (DEBUG) log("scrollWatcher", "suppressedExternally, ignoring event");
379
+ log("scrollWatcher", "suppressedExternally, ignoring event");
404
380
  return;
405
381
  }
406
382
  const currentTop = e && typeof e.scrollTop === "number" ? e.scrollTop : ((_ed$getScrollTop2 = ed.getScrollTop) === null || _ed$getScrollTop2 === void 0 ? void 0 : _ed$getScrollTop2.call(ed)) ?? 0;
407
383
  const delta = currentTop - opts.getLast();
408
384
  opts.setLast(currentTop);
409
385
  if (Math.abs(delta) < THRESHOLD_PX) {
410
- if (DEBUG) log("scrollWatcher", "small delta ignored", delta);
386
+ log("scrollWatcher", "small delta ignored", delta);
387
+ try {
388
+ const scrollHeight = typeof ed.getScrollHeight === "function" ? ed.getScrollHeight() : void 0;
389
+ const li = typeof ed.getLayoutInfo === "function" ? ed.getLayoutInfo() : void 0;
390
+ const viewportH = (li === null || li === void 0 ? void 0 : li.height) ?? void 0;
391
+ if (typeof scrollHeight === "number" && typeof viewportH === "number") {
392
+ const distance = scrollHeight - (currentTop + viewportH);
393
+ if (distance <= Math.max(THRESHOLD_PX, 0)) {
394
+ log("scrollWatcher", "small delta but at bottom, maybe resume", { distance });
395
+ opts.onMaybeResume();
396
+ }
397
+ }
398
+ } catch {}
411
399
  return;
412
400
  }
413
- if (DEBUG) log("scrollWatcher", "delta=", delta, "currentTop=", currentTop);
401
+ log("scrollWatcher", "delta=", delta, "currentTop=", currentTop);
414
402
  if (delta < 0) {
415
- if (DEBUG) log("scrollWatcher", "pause detected delta=", delta);
403
+ log("scrollWatcher", "pause detected delta=", delta);
416
404
  opts.onPause();
417
405
  return;
418
406
  }
419
- if (DEBUG) log("scrollWatcher", "maybe resume delta=", delta);
407
+ log("scrollWatcher", "maybe resume delta=", delta);
420
408
  opts.onMaybeResume();
421
409
  };
422
410
  const disp = ((_ed$onDidScrollChange = ed.onDidScrollChange) === null || _ed$onDidScrollChange === void 0 ? void 0 : _ed$onDidScrollChange.call(ed, listener)) ?? null;
@@ -426,11 +414,56 @@ function createScrollWatcherForEditor(ed, opts) {
426
414
  if (disp && typeof disp.dispose === "function") disp.dispose();
427
415
  else if (typeof disp === "function") disp();
428
416
  } catch {}
429
- if (DEBUG) log("scrollWatcher", "dispose");
417
+ log("scrollWatcher", "dispose");
430
418
  },
431
419
  setSuppressed(v) {
432
- suppressedExternally = !!v;
433
- if (DEBUG) log("scrollWatcher", "setSuppressed =>", suppressedExternally);
420
+ const newVal = !!v;
421
+ if (newVal === suppressedExternally) return;
422
+ suppressedExternally = newVal;
423
+ log("scrollWatcher", "setSuppressed =>", suppressedExternally);
424
+ try {
425
+ if (!domNode && typeof ed.getDomNode === "function") domNode = ed.getDomNode();
426
+ if (suppressedExternally && domNode) {
427
+ if (!interactionListener) {
428
+ interactionListener = () => {
429
+ try {
430
+ var _ed$getScrollTop3;
431
+ log("scrollWatcher", "user interaction detected while suppressed, cancelling suppression");
432
+ opts.onPause();
433
+ suppressedExternally = false;
434
+ const cur = ((_ed$getScrollTop3 = ed.getScrollTop) === null || _ed$getScrollTop3 === void 0 ? void 0 : _ed$getScrollTop3.call(ed)) ?? 0;
435
+ opts.setLast(cur);
436
+ try {
437
+ const scrollHeight = typeof ed.getScrollHeight === "function" ? ed.getScrollHeight() : void 0;
438
+ const li = typeof ed.getLayoutInfo === "function" ? ed.getLayoutInfo() : void 0;
439
+ const viewportH = (li === null || li === void 0 ? void 0 : li.height) ?? void 0;
440
+ if (typeof scrollHeight === "number" && typeof viewportH === "number") {
441
+ const distance = scrollHeight - (cur + viewportH);
442
+ if (distance <= Math.max(THRESHOLD_PX, 0)) {
443
+ log("scrollWatcher", "interaction moved to bottom, maybe resume", { distance });
444
+ opts.onMaybeResume();
445
+ }
446
+ }
447
+ } catch {}
448
+ if (domNode && interactionListener) {
449
+ domNode.removeEventListener("wheel", interactionListener, { passive: true });
450
+ domNode.removeEventListener("pointerdown", interactionListener);
451
+ domNode.removeEventListener("touchstart", interactionListener);
452
+ }
453
+ interactionListener = null;
454
+ } catch {}
455
+ };
456
+ domNode.addEventListener("wheel", interactionListener, { passive: true });
457
+ domNode.addEventListener("pointerdown", interactionListener);
458
+ domNode.addEventListener("touchstart", interactionListener);
459
+ }
460
+ } else if (domNode && interactionListener) {
461
+ domNode.removeEventListener("wheel", interactionListener, { passive: true });
462
+ domNode.removeEventListener("pointerdown", interactionListener);
463
+ domNode.removeEventListener("touchstart", interactionListener);
464
+ interactionListener = null;
465
+ }
466
+ } catch {}
434
467
  }
435
468
  };
436
469
  return api;
@@ -478,11 +511,14 @@ var DiffEditorManager = class {
478
511
  };
479
512
  }
480
513
  lastRevealLineDiff = null;
514
+ revealTicketDiff = 0;
481
515
  revealDebounceIdDiff = null;
482
516
  revealDebounceMs = defaultRevealDebounceMs;
483
517
  revealIdleTimerIdDiff = null;
484
518
  revealStrategyOption;
485
519
  revealBatchOnIdleMsOption;
520
+ scrollWatcherSuppressionMs = 500;
521
+ diffScrollWatcherSuppressionTimer = null;
486
522
  appendBufferDiff = [];
487
523
  appendBufferDiffScheduled = false;
488
524
  rafScheduler = createRafScheduler();
@@ -512,6 +548,26 @@ var DiffEditorManager = class {
512
548
  const desired = Math.max(fromLines, scrollH);
513
549
  return Math.min(desired, this.maxHeightValue);
514
550
  }
551
+ isOverflowAutoDiff() {
552
+ return !!this.lastContainer && this.lastContainer.style.overflow === "auto";
553
+ }
554
+ shouldPerformImmediateRevealDiff() {
555
+ return this.autoScrollOnUpdate && this.shouldAutoScrollDiff && this.hasVerticalScrollbarModified() && this.isOverflowAutoDiff();
556
+ }
557
+ suppressScrollWatcherDiff(ms) {
558
+ if (!this.diffScrollWatcher || typeof this.diffScrollWatcher.setSuppressed !== "function") return;
559
+ if (this.diffScrollWatcherSuppressionTimer != null) {
560
+ clearTimeout(this.diffScrollWatcherSuppressionTimer);
561
+ this.diffScrollWatcherSuppressionTimer = null;
562
+ }
563
+ this.diffScrollWatcher.setSuppressed(true);
564
+ this.diffScrollWatcherSuppressionTimer = setTimeout(() => {
565
+ try {
566
+ this.diffScrollWatcher.setSuppressed(false);
567
+ } catch {}
568
+ this.diffScrollWatcherSuppressionTimer = null;
569
+ }, ms);
570
+ }
515
571
  hasVerticalScrollbarModified() {
516
572
  if (!this.diffEditorView) return false;
517
573
  if (this._hasScrollBar) return true;
@@ -531,21 +587,56 @@ var DiffEditorManager = class {
531
587
  }
532
588
  maybeScrollDiffToBottom(targetLine, prevLineOverride) {
533
589
  this.rafScheduler.schedule("maybe-scroll-diff", () => {
590
+ log("diff", "maybeScrollDiffToBottom called", {
591
+ targetLine,
592
+ prevLineOverride,
593
+ diffAutoScroll: this.diffAutoScroll,
594
+ autoScrollOnUpdate: this.autoScrollOnUpdate,
595
+ shouldAutoScrollDiff: this.shouldAutoScrollDiff
596
+ });
534
597
  if (!this.diffEditorView) return;
535
- if (!(this.diffAutoScroll && this.autoScrollOnUpdate && this.shouldAutoScrollDiff && this.hasVerticalScrollbarModified())) return;
598
+ const hasV = this.hasVerticalScrollbarModified();
599
+ log("diff", "hasVerticalScrollbarModified ->", hasV);
600
+ if (!(this.diffAutoScroll && this.autoScrollOnUpdate && this.shouldAutoScrollDiff && hasV)) return;
536
601
  const me = this.diffEditorView.getModifiedEditor();
537
602
  const model = me.getModel();
538
603
  const currentLine = (model === null || model === void 0 ? void 0 : model.getLineCount()) ?? 1;
539
604
  const line = targetLine ?? currentLine;
540
605
  const prevLine = typeof prevLineOverride === "number" ? prevLineOverride : this.lastKnownModifiedLineCount ?? -1;
606
+ log("diff", "scroll metrics", {
607
+ prevLine,
608
+ currentLine,
609
+ line,
610
+ lastRevealLineDiff: this.lastRevealLineDiff
611
+ });
541
612
  if (prevLine !== -1 && prevLine === currentLine && line === currentLine) return;
542
613
  if (this.lastRevealLineDiff !== null && this.lastRevealLineDiff === line) return;
543
614
  const batchMs = this.revealBatchOnIdleMsOption ?? this.options.revealBatchOnIdleMs ?? defaultRevealBatchOnIdleMs;
615
+ log("diff", "reveal timing", {
616
+ batchMs,
617
+ revealDebounceMs: this.revealDebounceMs,
618
+ revealDebounceMsOption: this.revealDebounceMsOption
619
+ });
544
620
  if (typeof batchMs === "number" && batchMs > 0) {
621
+ if (hasV) {
622
+ const ticket$1 = ++this.revealTicketDiff;
623
+ log("diff", "has scrollbar -> immediate ticketed reveal", {
624
+ ticket: ticket$1,
625
+ line
626
+ });
627
+ this.performRevealDiffTicketed(line, ticket$1);
628
+ return;
629
+ }
545
630
  if (this.revealIdleTimerIdDiff != null) clearTimeout(this.revealIdleTimerIdDiff);
631
+ const ticket = ++this.revealTicketDiff;
632
+ log("diff", "scheduling idle reveal", {
633
+ ticket,
634
+ batchMs,
635
+ line
636
+ });
546
637
  this.revealIdleTimerIdDiff = setTimeout(() => {
547
638
  this.revealIdleTimerIdDiff = null;
548
- this.performRevealDiff(line);
639
+ this.performRevealDiffTicketed(line, ticket);
549
640
  }, batchMs);
550
641
  return;
551
642
  }
@@ -556,14 +647,32 @@ var DiffEditorManager = class {
556
647
  const ms = typeof this.revealDebounceMs === "number" && this.revealDebounceMs > 0 ? this.revealDebounceMs : typeof this.revealDebounceMsOption === "number" && this.revealDebounceMsOption > 0 ? this.revealDebounceMsOption : this.revealDebounceMs;
557
648
  this.revealDebounceIdDiff = setTimeout(() => {
558
649
  this.revealDebounceIdDiff = null;
559
- this.performRevealDiff(line);
650
+ const ticket = ++this.revealTicketDiff;
651
+ log("diff", "debounced reveal firing", {
652
+ ticket,
653
+ line
654
+ });
655
+ this.performRevealDiffTicketed(line, ticket);
560
656
  }, ms);
561
657
  this.lastKnownModifiedLineCount = currentLine;
562
658
  });
563
659
  }
564
- performRevealDiff(line) {
660
+ performRevealDiffTicketed(line, ticket) {
565
661
  this.rafScheduler.schedule("revealDiff", () => {
566
662
  var _editor;
663
+ if (this.diffScrollWatcher) {
664
+ log("diff", "performRevealDiffTicketed - suppressing watcher", {
665
+ ticket,
666
+ line,
667
+ ms: this.scrollWatcherSuppressionMs
668
+ });
669
+ this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs);
670
+ }
671
+ if (ticket !== this.revealTicketDiff) return;
672
+ log("diff", "performRevealDiffTicketed - performing reveal", {
673
+ ticket,
674
+ line
675
+ });
567
676
  const strategy = this.revealStrategyOption ?? this.options.revealStrategy ?? "centerIfOutside";
568
677
  const ScrollType = monaco_shim_exports.ScrollType || ((_editor = monaco_shim_exports.editor) === null || _editor === void 0 ? void 0 : _editor.ScrollType);
569
678
  const smooth = ScrollType && typeof ScrollType.Smooth !== "undefined" ? ScrollType.Smooth : void 0;
@@ -581,13 +690,71 @@ var DiffEditorManager = class {
581
690
  } catch {}
582
691
  }
583
692
  this.lastRevealLineDiff = line;
693
+ log("diff", "performRevealDiffTicketed - revealed", {
694
+ line,
695
+ lastRevealLineDiff: this.lastRevealLineDiff
696
+ });
697
+ try {
698
+ var _this$diffEditorView, _this$diffEditorView$, _this$diffEditorView$2;
699
+ this.shouldAutoScrollDiff = true;
700
+ this.lastScrollTopDiff = ((_this$diffEditorView = this.diffEditorView) === null || _this$diffEditorView === void 0 || (_this$diffEditorView$2 = (_this$diffEditorView$ = _this$diffEditorView.getModifiedEditor()).getScrollTop) === null || _this$diffEditorView$2 === void 0 ? void 0 : _this$diffEditorView$2.call(_this$diffEditorView$)) ?? this.lastScrollTopDiff;
701
+ } catch {}
702
+ });
703
+ }
704
+ performImmediateRevealDiff(line, ticket) {
705
+ var _editor2;
706
+ if (!this.diffEditorView) return;
707
+ if (ticket !== this.revealTicketDiff) return;
708
+ const ScrollType = monaco_shim_exports.ScrollType || ((_editor2 = monaco_shim_exports.editor) === null || _editor2 === void 0 ? void 0 : _editor2.ScrollType);
709
+ const immediate = ScrollType && typeof ScrollType.Immediate !== "undefined" ? ScrollType.Immediate : void 0;
710
+ const me = this.diffEditorView.getModifiedEditor();
711
+ if (typeof immediate !== "undefined") me.revealLine(line, immediate);
712
+ else me.revealLine(line);
713
+ this.measureViewportDiff();
714
+ log("diff", "performImmediateRevealDiff", {
715
+ line,
716
+ ticket
717
+ });
718
+ try {
719
+ var _this$diffEditorView2, _this$diffEditorView3, _this$diffEditorView4;
720
+ this.shouldAutoScrollDiff = true;
721
+ this.lastScrollTopDiff = ((_this$diffEditorView2 = this.diffEditorView) === null || _this$diffEditorView2 === void 0 || (_this$diffEditorView4 = (_this$diffEditorView3 = _this$diffEditorView2.getModifiedEditor()).getScrollTop) === null || _this$diffEditorView4 === void 0 ? void 0 : _this$diffEditorView4.call(_this$diffEditorView3)) ?? this.lastScrollTopDiff;
722
+ } catch {}
723
+ }
724
+ scheduleImmediateRevealAfterLayoutDiff(line) {
725
+ const ticket = ++this.revealTicketDiff;
726
+ this.rafScheduler.schedule("immediate-reveal-diff", async () => {
727
+ const target = this.diffEditorView && this.diffHeightManager ? Math.min(this.computedHeight(), this.maxHeightValue) : -1;
728
+ if (target !== -1 && this.diffHeightManager) {
729
+ if (this.lastContainer) this.lastContainer.style.height = `${target}px`;
730
+ await this.waitForHeightAppliedDiff(target);
731
+ }
732
+ this.performImmediateRevealDiff(line, ticket);
733
+ });
734
+ }
735
+ waitForHeightAppliedDiff(target, timeoutMs = 500) {
736
+ return new Promise((resolve) => {
737
+ const start = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
738
+ const check = () => {
739
+ const applied = this.lastContainer ? Number.parseFloat((this.lastContainer.style.height || "").replace("px", "")) || 0 : -1;
740
+ if (applied >= target - 1) {
741
+ resolve();
742
+ return;
743
+ }
744
+ if ((typeof performance !== "undefined" && performance.now ? performance.now() : Date.now()) - start > timeoutMs) {
745
+ resolve();
746
+ return;
747
+ }
748
+ requestAnimationFrame(check);
749
+ };
750
+ check();
584
751
  });
585
752
  }
586
753
  async createDiffEditor(container, originalCode, modifiedCode, language, currentTheme) {
587
754
  var _me$getScrollHeight2, _me$getOption, _oEditor$onDidContent, _mEditor$onDidContent;
588
755
  this.cleanup();
589
756
  this.lastContainer = container;
590
- container.style.overflow = "auto";
757
+ container.style.overflow = "hidden";
591
758
  container.style.maxHeight = this.maxHeightCSS;
592
759
  const lang = processedLanguage(language) || language;
593
760
  this.originalModel = monaco_shim_exports.editor.createModel(originalCode, lang);
@@ -636,13 +803,23 @@ var DiffEditorManager = class {
636
803
  }
637
804
  });
638
805
  }
639
- this.maybeScrollDiffToBottom(this.modifiedModel.getLineCount(), this.lastKnownModifiedLineCount ?? void 0);
806
+ log("diff", "createDiffEditor", {
807
+ autoScrollInitial: this.autoScrollInitial,
808
+ diffAutoScroll: this.diffAutoScroll
809
+ });
810
+ const MIN_VISIBLE_HEIGHT = Math.min(120, this.maxHeightValue);
811
+ container.style.minHeight = `${MIN_VISIBLE_HEIGHT}px`;
640
812
  if (this.diffHeightManager) {
641
813
  this.diffHeightManager.dispose();
642
814
  this.diffHeightManager = null;
643
815
  }
644
816
  this.diffHeightManager = createHeightManager(container, () => this.computedHeight());
645
817
  this.diffHeightManager.update();
818
+ const initialComputed = this.computedHeight();
819
+ if (initialComputed >= this.maxHeightValue - 1) {
820
+ container.style.height = `${this.maxHeightValue}px`;
821
+ container.style.overflow = "auto";
822
+ }
646
823
  const me = this.diffEditorView.getModifiedEditor();
647
824
  this.cachedScrollHeightDiff = ((_me$getScrollHeight2 = me.getScrollHeight) === null || _me$getScrollHeight2 === void 0 ? void 0 : _me$getScrollHeight2.call(me)) ?? null;
648
825
  this.cachedLineHeightDiff = ((_me$getOption = me.getOption) === null || _me$getOption === void 0 ? void 0 : _me$getOption.call(me, monaco_shim_exports.editor.EditorOption.lineHeight)) ?? null;
@@ -652,33 +829,54 @@ var DiffEditorManager = class {
652
829
  (_oEditor$onDidContent = oEditor.onDidContentSizeChange) === null || _oEditor$onDidContent === void 0 || _oEditor$onDidContent.call(oEditor, () => {
653
830
  this._hasScrollBar = false;
654
831
  this.rafScheduler.schedule("content-size-change-diff", () => {
655
- try {
656
- var _oEditor$getScrollHei, _oEditor$getOption, _this$diffHeightManag, _this$diffHeightManag2;
657
- this.cachedScrollHeightDiff = ((_oEditor$getScrollHei = oEditor.getScrollHeight) === null || _oEditor$getScrollHei === void 0 ? void 0 : _oEditor$getScrollHei.call(oEditor)) ?? this.cachedScrollHeightDiff;
658
- this.cachedLineHeightDiff = ((_oEditor$getOption = oEditor.getOption) === null || _oEditor$getOption === void 0 ? void 0 : _oEditor$getOption.call(oEditor, monaco_shim_exports.editor.EditorOption.lineHeight)) ?? this.cachedLineHeightDiff;
659
- this.cachedComputedHeightDiff = this.computedHeight();
660
- if ((_this$diffHeightManag = this.diffHeightManager) === null || _this$diffHeightManag === void 0 ? void 0 : _this$diffHeightManag.isSuppressed()) return;
661
- (_this$diffHeightManag2 = this.diffHeightManager) === null || _this$diffHeightManag2 === void 0 || _this$diffHeightManag2.update();
662
- } catch {}
832
+ var _oEditor$getScrollHei, _oEditor$getOption, _this$diffHeightManag, _this$diffHeightManag2;
833
+ this.cachedScrollHeightDiff = ((_oEditor$getScrollHei = oEditor.getScrollHeight) === null || _oEditor$getScrollHei === void 0 ? void 0 : _oEditor$getScrollHei.call(oEditor)) ?? this.cachedScrollHeightDiff;
834
+ this.cachedLineHeightDiff = ((_oEditor$getOption = oEditor.getOption) === null || _oEditor$getOption === void 0 ? void 0 : _oEditor$getOption.call(oEditor, monaco_shim_exports.editor.EditorOption.lineHeight)) ?? this.cachedLineHeightDiff;
835
+ this.cachedComputedHeightDiff = this.computedHeight();
836
+ if ((_this$diffHeightManag = this.diffHeightManager) === null || _this$diffHeightManag === void 0 ? void 0 : _this$diffHeightManag.isSuppressed()) return;
837
+ (_this$diffHeightManag2 = this.diffHeightManager) === null || _this$diffHeightManag2 === void 0 || _this$diffHeightManag2.update();
838
+ const computed$1 = this.computedHeight();
839
+ if (this.lastContainer) {
840
+ const prevOverflow = this.lastContainer.style.overflow;
841
+ const newOverflow = computed$1 >= this.maxHeightValue - 1 ? "auto" : "hidden";
842
+ if (prevOverflow !== newOverflow) {
843
+ this.lastContainer.style.overflow = newOverflow;
844
+ if (newOverflow === "auto" && this.shouldAutoScrollDiff) {
845
+ var _this$modifiedModel;
846
+ this.maybeScrollDiffToBottom((_this$modifiedModel = this.modifiedModel) === null || _this$modifiedModel === void 0 ? void 0 : _this$modifiedModel.getLineCount());
847
+ }
848
+ }
849
+ }
663
850
  });
664
851
  });
665
852
  (_mEditor$onDidContent = mEditor.onDidContentSizeChange) === null || _mEditor$onDidContent === void 0 || _mEditor$onDidContent.call(mEditor, () => {
666
853
  this._hasScrollBar = false;
667
854
  this.rafScheduler.schedule("content-size-change-diff", () => {
668
- try {
669
- var _mEditor$getScrollHei, _mEditor$getOption, _this$diffHeightManag3, _this$diffHeightManag4;
670
- this.cachedScrollHeightDiff = ((_mEditor$getScrollHei = mEditor.getScrollHeight) === null || _mEditor$getScrollHei === void 0 ? void 0 : _mEditor$getScrollHei.call(mEditor)) ?? this.cachedScrollHeightDiff;
671
- this.cachedLineHeightDiff = ((_mEditor$getOption = mEditor.getOption) === null || _mEditor$getOption === void 0 ? void 0 : _mEditor$getOption.call(mEditor, monaco_shim_exports.editor.EditorOption.lineHeight)) ?? this.cachedLineHeightDiff;
672
- this.cachedComputedHeightDiff = this.computedHeight();
673
- if ((_this$diffHeightManag3 = this.diffHeightManager) === null || _this$diffHeightManag3 === void 0 ? void 0 : _this$diffHeightManag3.isSuppressed()) return;
674
- (_this$diffHeightManag4 = this.diffHeightManager) === null || _this$diffHeightManag4 === void 0 || _this$diffHeightManag4.update();
675
- } catch {}
855
+ var _mEditor$getScrollHei, _mEditor$getOption, _this$diffHeightManag3, _this$diffHeightManag4;
856
+ this.cachedScrollHeightDiff = ((_mEditor$getScrollHei = mEditor.getScrollHeight) === null || _mEditor$getScrollHei === void 0 ? void 0 : _mEditor$getScrollHei.call(mEditor)) ?? this.cachedScrollHeightDiff;
857
+ this.cachedLineHeightDiff = ((_mEditor$getOption = mEditor.getOption) === null || _mEditor$getOption === void 0 ? void 0 : _mEditor$getOption.call(mEditor, monaco_shim_exports.editor.EditorOption.lineHeight)) ?? this.cachedLineHeightDiff;
858
+ this.cachedComputedHeightDiff = this.computedHeight();
859
+ if ((_this$diffHeightManag3 = this.diffHeightManager) === null || _this$diffHeightManag3 === void 0 ? void 0 : _this$diffHeightManag3.isSuppressed()) return;
860
+ (_this$diffHeightManag4 = this.diffHeightManager) === null || _this$diffHeightManag4 === void 0 || _this$diffHeightManag4.update();
861
+ const computed$1 = this.computedHeight();
862
+ if (this.lastContainer) {
863
+ const prevOverflow = this.lastContainer.style.overflow;
864
+ const newOverflow = computed$1 >= this.maxHeightValue - 1 ? "auto" : "hidden";
865
+ if (prevOverflow !== newOverflow) {
866
+ this.lastContainer.style.overflow = newOverflow;
867
+ if (newOverflow === "auto" && this.shouldAutoScrollDiff) {
868
+ var _this$modifiedModel2;
869
+ this.maybeScrollDiffToBottom((_this$modifiedModel2 = this.modifiedModel) === null || _this$modifiedModel2 === void 0 ? void 0 : _this$modifiedModel2.getLineCount());
870
+ }
871
+ }
872
+ }
676
873
  });
677
874
  });
678
875
  mEditor.onDidChangeModelContent(() => {
679
876
  this.lastKnownModifiedDirty = true;
680
877
  this.rafScheduler.schedule("sync-last-known-modified", () => this.syncLastKnownModified());
681
878
  });
879
+ this.maybeScrollDiffToBottom(this.modifiedModel.getLineCount(), this.lastKnownModifiedLineCount ?? void 0);
682
880
  return this.diffEditorView;
683
881
  }
684
882
  updateDiff(originalCode, modifiedCode, codeLanguage) {
@@ -738,11 +936,37 @@ var DiffEditorManager = class {
738
936
  }
739
937
  const prev = this.lastKnownModifiedCode ?? this.modifiedModel.getValue();
740
938
  if (prev === newCode) return;
939
+ const prevLine = this.modifiedModel.getLineCount();
741
940
  if (newCode.startsWith(prev) && prev.length < newCode.length) {
742
- const prevLine = this.modifiedModel.getLineCount();
743
941
  this.appendToModel(this.modifiedModel, newCode.slice(prev.length));
744
942
  this.maybeScrollDiffToBottom(this.modifiedModel.getLineCount(), prevLine);
745
- } else this.applyMinimalEditToModel(this.modifiedModel, prev, newCode);
943
+ } else {
944
+ this.applyMinimalEditToModel(this.modifiedModel, prev, newCode);
945
+ const newLine = this.modifiedModel.getLineCount();
946
+ if (newLine !== prevLine) {
947
+ const shouldImmediate = this.shouldPerformImmediateRevealDiff();
948
+ if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
949
+ const computed$1 = this.computedHeight();
950
+ if (computed$1 >= this.maxHeightValue - 1 && this.lastContainer) {
951
+ this.lastContainer.style.height = `${this.maxHeightValue}px`;
952
+ this.lastContainer.style.overflow = "auto";
953
+ }
954
+ if (shouldImmediate) this.scheduleImmediateRevealAfterLayoutDiff(newLine);
955
+ else this.maybeScrollDiffToBottom(newLine, prevLine);
956
+ if (this.autoScrollOnUpdate && this.shouldAutoScrollDiff) try {
957
+ var _editor3, _me2$getModel, _me2$getScrollTop;
958
+ const ScrollType = monaco_shim_exports.ScrollType || ((_editor3 = monaco_shim_exports.editor) === null || _editor3 === void 0 ? void 0 : _editor3.ScrollType);
959
+ const immediate = ScrollType && typeof ScrollType.Immediate !== "undefined" ? ScrollType.Immediate : void 0;
960
+ const me2 = this.diffEditorView.getModifiedEditor();
961
+ const targetLine = ((_me2$getModel = me2.getModel()) === null || _me2$getModel === void 0 ? void 0 : _me2$getModel.getLineCount()) ?? newLine;
962
+ if (typeof immediate !== "undefined") me2.revealLine(targetLine, immediate);
963
+ else me2.revealLine(targetLine);
964
+ this.lastRevealLineDiff = targetLine;
965
+ this.shouldAutoScrollDiff = true;
966
+ this.lastScrollTopDiff = ((_me2$getScrollTop = me2.getScrollTop) === null || _me2$getScrollTop === void 0 ? void 0 : _me2$getScrollTop.call(me2)) ?? this.lastScrollTopDiff;
967
+ } catch {}
968
+ }
969
+ }
746
970
  this.lastKnownModifiedCode = newCode;
747
971
  }
748
972
  appendOriginal(appendText, codeLanguage) {
@@ -752,9 +976,7 @@ var DiffEditorManager = class {
752
976
  if (lang && this.originalModel.getLanguageId() !== lang) monaco_shim_exports.editor.setModelLanguage(this.originalModel, lang);
753
977
  }
754
978
  this.appendToModel(this.originalModel, appendText);
755
- try {
756
- this.lastKnownOriginalCode = this.originalModel.getValue();
757
- } catch {}
979
+ this.lastKnownOriginalCode = this.originalModel.getValue();
758
980
  }
759
981
  appendModified(appendText, codeLanguage) {
760
982
  if (!this.diffEditorView || !this.modifiedModel || !appendText) return;
@@ -823,6 +1045,15 @@ var DiffEditorManager = class {
823
1045
  clearTimeout(this.revealDebounceIdDiff);
824
1046
  this.revealDebounceIdDiff = null;
825
1047
  }
1048
+ if (this.revealIdleTimerIdDiff != null) {
1049
+ clearTimeout(this.revealIdleTimerIdDiff);
1050
+ this.revealIdleTimerIdDiff = null;
1051
+ }
1052
+ if (this.diffScrollWatcherSuppressionTimer != null) {
1053
+ clearTimeout(this.diffScrollWatcherSuppressionTimer);
1054
+ this.diffScrollWatcherSuppressionTimer = null;
1055
+ }
1056
+ this.revealTicketDiff = 0;
826
1057
  this.lastRevealLineDiff = null;
827
1058
  }
828
1059
  safeClean() {
@@ -843,6 +1074,15 @@ var DiffEditorManager = class {
843
1074
  clearTimeout(this.revealDebounceIdDiff);
844
1075
  this.revealDebounceIdDiff = null;
845
1076
  }
1077
+ if (this.revealIdleTimerIdDiff != null) {
1078
+ clearTimeout(this.revealIdleTimerIdDiff);
1079
+ this.revealIdleTimerIdDiff = null;
1080
+ }
1081
+ if (this.diffScrollWatcherSuppressionTimer != null) {
1082
+ clearTimeout(this.diffScrollWatcherSuppressionTimer);
1083
+ this.diffScrollWatcherSuppressionTimer = null;
1084
+ }
1085
+ this.revealTicketDiff = 0;
846
1086
  this.lastRevealLineDiff = null;
847
1087
  this.rafScheduler.cancel("content-size-change-diff");
848
1088
  this.rafScheduler.cancel("sync-last-known-modified");
@@ -856,7 +1096,7 @@ var DiffEditorManager = class {
856
1096
  this.lastKnownModifiedCode = model.getValue();
857
1097
  this.lastKnownModifiedLineCount = model.getLineCount();
858
1098
  }
859
- } catch {} finally {
1099
+ } finally {
860
1100
  this.lastKnownModifiedDirty = false;
861
1101
  }
862
1102
  }
@@ -900,10 +1140,20 @@ var DiffEditorManager = class {
900
1140
  else this.applyMinimalEditToModel(m, prevM, modified);
901
1141
  this.lastKnownModifiedCode = modified;
902
1142
  const newMLineCount = m.getLineCount();
903
- if (newMLineCount !== prevMLineCount) this.maybeScrollDiffToBottom(newMLineCount, prevMLineCount);
1143
+ if (newMLineCount !== prevMLineCount) {
1144
+ const shouldImmediate = this.shouldPerformImmediateRevealDiff();
1145
+ if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
1146
+ const computed$1 = this.computedHeight();
1147
+ if (computed$1 >= this.maxHeightValue - 1 && this.lastContainer) {
1148
+ this.lastContainer.style.height = `${this.maxHeightValue}px`;
1149
+ this.lastContainer.style.overflow = "auto";
1150
+ }
1151
+ if (shouldImmediate) this.scheduleImmediateRevealAfterLayoutDiff(newMLineCount);
1152
+ else this.maybeScrollDiffToBottom(newMLineCount, prevMLineCount);
1153
+ }
904
1154
  }
905
1155
  }
906
- flushAppendBufferDiff() {
1156
+ async flushAppendBufferDiff() {
907
1157
  if (!this.diffEditorView) return;
908
1158
  if (this.appendBufferDiff.length === 0) return;
909
1159
  this.appendBufferDiffScheduled = false;
@@ -913,39 +1163,128 @@ var DiffEditorManager = class {
913
1163
  this.appendBufferDiff.length = 0;
914
1164
  return;
915
1165
  }
916
- const text = this.appendBufferDiff.join("");
1166
+ let parts = this.appendBufferDiff.splice(0);
1167
+ const prevLineInit = model.getLineCount();
1168
+ const totalText = parts.join("");
1169
+ const totalChars = totalText.length;
1170
+ if (parts.length === 1 && totalChars > 5e3) {
1171
+ const lines = totalText.split(/\r?\n/);
1172
+ const chunkSize = 200;
1173
+ const chunks = [];
1174
+ for (let i = 0; i < lines.length; i += chunkSize) chunks.push(`${lines.slice(i, i + chunkSize).join("\n")}\n`);
1175
+ if (chunks.length > 1) parts = chunks;
1176
+ }
1177
+ const applyChunked = parts.length > 1 && (totalChars > 2e3 || model.getLineCount && model.getLineCount() + 0 - prevLineInit > 50);
1178
+ log("diff", "flushAppendBufferDiff start", {
1179
+ partsCount: parts.length,
1180
+ totalChars,
1181
+ applyChunked
1182
+ });
1183
+ let prevLine = prevLineInit;
1184
+ const watcherApi = this.diffScrollWatcher;
1185
+ let suppressedByFlush = false;
1186
+ if (watcherApi && typeof watcherApi.setSuppressed === "function") try {
1187
+ if (this.diffScrollWatcherSuppressionTimer != null) {
1188
+ clearTimeout(this.diffScrollWatcherSuppressionTimer);
1189
+ this.diffScrollWatcherSuppressionTimer = null;
1190
+ }
1191
+ watcherApi.setSuppressed(true);
1192
+ suppressedByFlush = true;
1193
+ } catch {}
1194
+ if (applyChunked) {
1195
+ log("diff", "flushAppendBufferDiff applying chunked", { partsLen: parts.length });
1196
+ let idx = 0;
1197
+ for (const part of parts) {
1198
+ if (!part) continue;
1199
+ idx += 1;
1200
+ log("diff", "flushAppendBufferDiff chunk", {
1201
+ idx,
1202
+ partLen: part.length,
1203
+ prevLine
1204
+ });
1205
+ const lastColumn$1 = model.getLineMaxColumn(prevLine);
1206
+ const range$1 = new monaco_shim_exports.Range(prevLine, lastColumn$1, prevLine, lastColumn$1);
1207
+ model.applyEdits([{
1208
+ range: range$1,
1209
+ text: part,
1210
+ forceMoveMarkers: true
1211
+ }]);
1212
+ this.lastKnownModifiedCode = model.getValue();
1213
+ const newLine$1 = model.getLineCount();
1214
+ this.lastKnownModifiedLineCount = newLine$1;
1215
+ await new Promise((resolve) => typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame(resolve) : setTimeout(resolve, 0));
1216
+ const shouldImmediate$1 = this.shouldPerformImmediateRevealDiff();
1217
+ log("diff", "flushAppendBufferDiff chunk metrics", {
1218
+ idx,
1219
+ newLine: newLine$1,
1220
+ prevLine,
1221
+ shouldImmediate: shouldImmediate$1
1222
+ });
1223
+ if (shouldImmediate$1) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
1224
+ const computed$2 = this.computedHeight();
1225
+ if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) {
1226
+ this.lastContainer.style.height = `${this.maxHeightValue}px`;
1227
+ this.lastContainer.style.overflow = "auto";
1228
+ }
1229
+ if (shouldImmediate$1) this.scheduleImmediateRevealAfterLayoutDiff(newLine$1);
1230
+ else this.maybeScrollDiffToBottom(newLine$1, prevLine);
1231
+ prevLine = newLine$1;
1232
+ log("diff", "flushAppendBufferDiff chunk applied", {
1233
+ idx,
1234
+ newLine: newLine$1
1235
+ });
1236
+ }
1237
+ if (suppressedByFlush) watcherApi.setSuppressed(false);
1238
+ return;
1239
+ }
1240
+ const text = totalText;
917
1241
  this.appendBufferDiff.length = 0;
1242
+ prevLine = model.getLineCount();
1243
+ const lastColumn = model.getLineMaxColumn(prevLine);
1244
+ const range = new monaco_shim_exports.Range(prevLine, lastColumn, prevLine, lastColumn);
1245
+ model.applyEdits([{
1246
+ range,
1247
+ text,
1248
+ forceMoveMarkers: true
1249
+ }]);
1250
+ this.lastKnownModifiedCode = model.getValue();
1251
+ const newLine = model.getLineCount();
1252
+ this.lastKnownModifiedLineCount = newLine;
1253
+ const shouldImmediate = this.shouldPerformImmediateRevealDiff();
1254
+ if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
1255
+ const computed$1 = this.computedHeight();
1256
+ if (computed$1 >= this.maxHeightValue - 1 && this.lastContainer) this.lastContainer.style.height = `${this.maxHeightValue}px`;
1257
+ if (shouldImmediate) this.scheduleImmediateRevealAfterLayoutDiff(newLine);
1258
+ else this.maybeScrollDiffToBottom(newLine, prevLine);
1259
+ if (this.autoScrollOnUpdate && this.shouldAutoScrollDiff) try {
1260
+ var _editor4, _me2$getModel2, _me2$getScrollTop2;
1261
+ const ScrollType = monaco_shim_exports.ScrollType || ((_editor4 = monaco_shim_exports.editor) === null || _editor4 === void 0 ? void 0 : _editor4.ScrollType);
1262
+ const immediate = ScrollType && typeof ScrollType.Immediate !== "undefined" ? ScrollType.Immediate : void 0;
1263
+ const me2 = this.diffEditorView.getModifiedEditor();
1264
+ const targetLine = ((_me2$getModel2 = me2.getModel()) === null || _me2$getModel2 === void 0 ? void 0 : _me2$getModel2.getLineCount()) ?? newLine;
1265
+ if (typeof immediate !== "undefined") me2.revealLine(targetLine, immediate);
1266
+ else me2.revealLine(targetLine);
1267
+ this.lastRevealLineDiff = targetLine;
1268
+ this.shouldAutoScrollDiff = true;
1269
+ this.lastScrollTopDiff = ((_me2$getScrollTop2 = me2.getScrollTop) === null || _me2$getScrollTop2 === void 0 ? void 0 : _me2$getScrollTop2.call(me2)) ?? this.lastScrollTopDiff;
1270
+ } catch {}
1271
+ if (suppressedByFlush) watcherApi.setSuppressed(false);
918
1272
  try {
919
- const prevLine = model.getLineCount();
920
- const lastColumn = model.getLineMaxColumn(prevLine);
921
- const range = new monaco_shim_exports.Range(prevLine, lastColumn, prevLine, lastColumn);
922
- model.applyEdits([{
923
- range,
924
- text,
925
- forceMoveMarkers: true
926
- }]);
927
- try {
928
- this.lastKnownModifiedCode = model.getValue();
929
- } catch {}
930
- const newLine = model.getLineCount();
931
- this.maybeScrollDiffToBottom(newLine, prevLine);
932
- this.lastKnownModifiedLineCount = newLine;
1273
+ var _this$diffEditorView5, _this$diffEditorView6, _this$diffEditorView7;
1274
+ this.shouldAutoScrollDiff = true;
1275
+ this.lastScrollTopDiff = ((_this$diffEditorView5 = this.diffEditorView) === null || _this$diffEditorView5 === void 0 || (_this$diffEditorView7 = (_this$diffEditorView6 = _this$diffEditorView5.getModifiedEditor()).getScrollTop) === null || _this$diffEditorView7 === void 0 ? void 0 : _this$diffEditorView7.call(_this$diffEditorView6)) ?? this.lastScrollTopDiff;
933
1276
  } catch {}
934
1277
  }
935
1278
  applyMinimalEditToModel(model, prev, next) {
936
- try {
937
- const maxChars = minimalEditMaxChars;
938
- const ratio = minimalEditMaxChangeRatio;
939
- const maxLen = Math.max(prev.length, next.length);
940
- const changeRatio = maxLen > 0 ? Math.abs(next.length - prev.length) / maxLen : 0;
941
- if (prev.length + next.length > maxChars || changeRatio > ratio) {
942
- model.setValue(next);
943
- try {
944
- if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
945
- } catch {}
946
- return;
947
- }
948
- } catch {}
1279
+ const maxChars = minimalEditMaxChars;
1280
+ const ratio = minimalEditMaxChangeRatio;
1281
+ const maxLen = Math.max(prev.length, next.length);
1282
+ const changeRatio = maxLen > 0 ? Math.abs(next.length - prev.length) / maxLen : 0;
1283
+ if (prev.length + next.length > maxChars || changeRatio > ratio) {
1284
+ model.setValue(next);
1285
+ if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
1286
+ return;
1287
+ }
949
1288
  const res = computeMinimalEdit(prev, next);
950
1289
  if (!res) return;
951
1290
  const { start, endPrevIncl, replaceText } = res;
@@ -957,9 +1296,7 @@ var DiffEditorManager = class {
957
1296
  text: replaceText,
958
1297
  forceMoveMarkers: true
959
1298
  }]);
960
- try {
961
- if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
962
- } catch {}
1299
+ if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
963
1300
  }
964
1301
  appendToModel(model, appendText) {
965
1302
  if (!appendText) return;
@@ -971,9 +1308,7 @@ var DiffEditorManager = class {
971
1308
  text: appendText,
972
1309
  forceMoveMarkers: true
973
1310
  }]);
974
- try {
975
- if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
976
- } catch {}
1311
+ if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
977
1312
  }
978
1313
  };
979
1314
 
@@ -1072,14 +1407,12 @@ var EditorManager = class {
1072
1407
  const lineCount = this.cachedLineCount ?? ((_editorView$getModel = editorView.getModel()) === null || _editorView$getModel === void 0 ? void 0 : _editorView$getModel.getLineCount()) ?? 1;
1073
1408
  const lineHeight = editorView.getOption(monaco_shim_exports.editor.EditorOption.lineHeight);
1074
1409
  const height = Math.min(lineCount * lineHeight + padding, this.maxHeightValue);
1075
- try {
1076
- log("EditorManager.computedHeight", {
1077
- lineCount,
1078
- lineHeight,
1079
- computed: height,
1080
- maxHeightValue: this.maxHeightValue
1081
- });
1082
- } catch {}
1410
+ log("EditorManager.computedHeight", {
1411
+ lineCount,
1412
+ lineHeight,
1413
+ computed: height,
1414
+ maxHeightValue: this.maxHeightValue
1415
+ });
1083
1416
  return height;
1084
1417
  }
1085
1418
  maybeScrollToBottom(targetLine) {
@@ -1130,7 +1463,6 @@ var EditorManager = class {
1130
1463
  return;
1131
1464
  }
1132
1465
  this.dlog("performReveal executing, ticket=", ticket, "line=", line);
1133
- this.lastPerformedRevealTicket = ticket;
1134
1466
  const strategy = this.revealStrategyOption ?? this.options.revealStrategy ?? "centerIfOutside";
1135
1467
  this.dlog("performReveal strategy=", strategy);
1136
1468
  const ScrollType = monaco_shim_exports.ScrollType || ((_editor = monaco_shim_exports.editor) === null || _editor === void 0 ? void 0 : _editor.ScrollType);
@@ -1158,7 +1490,6 @@ var EditorManager = class {
1158
1490
  this.dlog("performImmediateReveal skipped, stale ticket", ticket, "current", this.revealTicket);
1159
1491
  return;
1160
1492
  }
1161
- this.lastPerformedRevealTicket = ticket;
1162
1493
  const ScrollType = monaco_shim_exports.ScrollType || ((_editor2 = monaco_shim_exports.editor) === null || _editor2 === void 0 ? void 0 : _editor2.ScrollType);
1163
1494
  const immediate = ScrollType && typeof ScrollType.Immediate !== "undefined" ? ScrollType.Immediate : void 0;
1164
1495
  if (typeof immediate !== "undefined") this.editorView.revealLine(line, immediate);
@@ -1308,35 +1639,28 @@ var EditorManager = class {
1308
1639
  }
1309
1640
  syncLastKnownCode() {
1310
1641
  if (!this.editorView || !this.lastKnownCodeDirty) return;
1311
- try {
1312
- const model = this.editorView.getModel();
1313
- if (model) {
1314
- this.lastKnownCode = model.getValue();
1315
- this.cachedLineCount = model.getLineCount() ?? this.cachedLineCount;
1316
- }
1317
- } catch {} finally {
1318
- this.lastKnownCodeDirty = false;
1642
+ const model = this.editorView.getModel();
1643
+ if (model) {
1644
+ this.lastKnownCode = model.getValue();
1645
+ this.cachedLineCount = model.getLineCount() ?? this.cachedLineCount;
1319
1646
  }
1647
+ this.lastKnownCodeDirty = false;
1320
1648
  }
1321
1649
  suppressScrollWatcher(ms) {
1322
- try {
1323
- if (!this.scrollWatcher || typeof this.scrollWatcher.setSuppressed !== "function") return;
1324
- this.dlog("suppressScrollWatcher", ms);
1325
- if (this.scrollWatcherSuppressionTimer != null) {
1326
- clearTimeout(this.scrollWatcherSuppressionTimer);
1327
- this.scrollWatcherSuppressionTimer = null;
1650
+ if (!this.scrollWatcher || typeof this.scrollWatcher.setSuppressed !== "function") return;
1651
+ this.dlog("suppressScrollWatcher", ms);
1652
+ if (this.scrollWatcherSuppressionTimer != null) {
1653
+ clearTimeout(this.scrollWatcherSuppressionTimer);
1654
+ this.scrollWatcherSuppressionTimer = null;
1655
+ }
1656
+ this.scrollWatcher.setSuppressed(true);
1657
+ this.scrollWatcherSuppressionTimer = setTimeout(() => {
1658
+ if (this.scrollWatcher && typeof this.scrollWatcher.setSuppressed === "function") {
1659
+ this.scrollWatcher.setSuppressed(false);
1660
+ this.dlog("suppressScrollWatcher cleared");
1328
1661
  }
1329
- this.scrollWatcher.setSuppressed(true);
1330
- this.scrollWatcherSuppressionTimer = setTimeout(() => {
1331
- try {
1332
- if (this.scrollWatcher && typeof this.scrollWatcher.setSuppressed === "function") {
1333
- this.scrollWatcher.setSuppressed(false);
1334
- this.dlog("suppressScrollWatcher cleared");
1335
- }
1336
- } catch {}
1337
- this.scrollWatcherSuppressionTimer = null;
1338
- }, ms);
1339
- } catch {}
1662
+ this.scrollWatcherSuppressionTimer = null;
1663
+ }, ms);
1340
1664
  }
1341
1665
  scheduleImmediateRevealAfterLayout(line) {
1342
1666
  const ticket = ++this.revealTicket;
@@ -1402,14 +1726,9 @@ var EditorManager = class {
1402
1726
  if (newLineCount$1 !== prevLineCount$1) {
1403
1727
  const shouldImmediate = this.shouldPerformImmediateReveal();
1404
1728
  if (shouldImmediate) this.suppressScrollWatcher(this.scrollWatcherSuppressionMs);
1405
- try {
1406
- const computed$1 = this.computedHeight(this.editorView);
1407
- if (computed$1 >= this.maxHeightValue - 1 && this.lastContainer) this.lastContainer.style.height = `${this.maxHeightValue}px`;
1408
- } catch {}
1409
- if (shouldImmediate) try {
1410
- this.forceReveal(newLineCount$1);
1411
- } catch {}
1412
- else this.maybeScrollToBottom(newLineCount$1);
1729
+ const computed$1 = this.computedHeight(this.editorView);
1730
+ if (computed$1 >= this.maxHeightValue - 1 && this.lastContainer) this.lastContainer.style.height = `${this.maxHeightValue}px`;
1731
+ this.forceReveal(newLineCount$1);
1413
1732
  }
1414
1733
  return;
1415
1734
  }
@@ -1451,21 +1770,19 @@ var EditorManager = class {
1451
1770
  if (!this.editorView) return;
1452
1771
  const model = this.editorView.getModel();
1453
1772
  if (!model) return;
1454
- try {
1455
- const maxChars = minimalEditMaxChars;
1456
- const ratio = minimalEditMaxChangeRatio;
1457
- const maxLen = Math.max(prev.length, next.length);
1458
- const changeRatio = maxLen > 0 ? Math.abs(next.length - prev.length) / maxLen : 0;
1459
- if (prev.length + next.length > maxChars || changeRatio > ratio) {
1460
- const prevLineCount = model.getLineCount();
1461
- model.setValue(next);
1462
- this.lastKnownCode = next;
1463
- const newLineCount = model.getLineCount();
1464
- this.cachedLineCount = newLineCount;
1465
- if (newLineCount !== prevLineCount) this.maybeScrollToBottom(newLineCount);
1466
- return;
1467
- }
1468
- } catch {}
1773
+ const maxChars = minimalEditMaxChars;
1774
+ const ratio = minimalEditMaxChangeRatio;
1775
+ const maxLen = Math.max(prev.length, next.length);
1776
+ const changeRatio = maxLen > 0 ? Math.abs(next.length - prev.length) / maxLen : 0;
1777
+ if (prev.length + next.length > maxChars || changeRatio > ratio) {
1778
+ const prevLineCount = model.getLineCount();
1779
+ model.setValue(next);
1780
+ this.lastKnownCode = next;
1781
+ const newLineCount = model.getLineCount();
1782
+ this.cachedLineCount = newLineCount;
1783
+ if (newLineCount !== prevLineCount) this.maybeScrollToBottom(newLineCount);
1784
+ return;
1785
+ }
1469
1786
  const res = computeMinimalEdit(prev, next);
1470
1787
  if (!res) return;
1471
1788
  const { start, endPrevIncl, replaceText } = res;
@@ -1511,10 +1828,8 @@ var EditorManager = class {
1511
1828
  this.cachedLineCount = newLineCount;
1512
1829
  const shouldImmediate = this.shouldPerformImmediateReveal();
1513
1830
  if (shouldImmediate) this.suppressScrollWatcher(this.scrollWatcherSuppressionMs);
1514
- try {
1515
- const computed$1 = this.computedHeight(this.editorView);
1516
- if (computed$1 >= this.maxHeightValue - 1 && this.lastContainer) this.lastContainer.style.height = `${this.maxHeightValue}px`;
1517
- } catch {}
1831
+ const computed$1 = this.computedHeight(this.editorView);
1832
+ if (computed$1 >= this.maxHeightValue - 1 && this.lastContainer) this.lastContainer.style.height = `${this.maxHeightValue}px`;
1518
1833
  if (shouldImmediate) try {
1519
1834
  this.forceReveal(newLineCount);
1520
1835
  } catch {}
@@ -2088,9 +2403,7 @@ function useMonaco(monacoOptions = {}) {
2088
2403
  flush: "post",
2089
2404
  immediate: true
2090
2405
  });
2091
- try {
2092
- if (editorView) lastKnownCode = editorView.getValue();
2093
- } catch {}
2406
+ if (editorView) lastKnownCode = editorView.getValue();
2094
2407
  return editorView;
2095
2408
  }
2096
2409
  function computedHeight(editorView$1) {