stream-monaco 0.0.3 → 0.0.4
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.
- package/dist/index.cjs +482 -153
- package/dist/index.js +482 -153
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -203,18 +203,18 @@ const monaco = _monaco;
|
|
|
203
203
|
//#endregion
|
|
204
204
|
//#region src/utils/logger.ts
|
|
205
205
|
let seq = 0;
|
|
206
|
-
const
|
|
206
|
+
const DEBUG = (() => {
|
|
207
207
|
try {
|
|
208
208
|
if (typeof window !== "undefined" && window.__STREAM_MONACO_DEBUG__ !== void 0) return Boolean(window.__STREAM_MONACO_DEBUG__);
|
|
209
209
|
try {
|
|
210
210
|
const proc = nodeProcess;
|
|
211
|
-
if (proc && proc.env && proc.env.NODE_ENV
|
|
211
|
+
if (proc && proc.env && proc.env.NODE_ENV === "production") return false;
|
|
212
212
|
} catch {}
|
|
213
213
|
} catch {}
|
|
214
|
-
return
|
|
214
|
+
return true;
|
|
215
215
|
})();
|
|
216
216
|
function log(tag, ...args) {
|
|
217
|
-
if (!
|
|
217
|
+
if (!DEBUG) return;
|
|
218
218
|
try {
|
|
219
219
|
seq += 1;
|
|
220
220
|
const id = `#${seq}`;
|
|
@@ -227,7 +227,7 @@ function log(tag, ...args) {
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
function error(tag, ...args) {
|
|
230
|
-
if (!
|
|
230
|
+
if (!DEBUG) return;
|
|
231
231
|
try {
|
|
232
232
|
console.error(`[${tag}]`, ...args);
|
|
233
233
|
} catch (err) {
|
|
@@ -354,41 +354,45 @@ function createRafScheduler(timeSource) {
|
|
|
354
354
|
//#region src/utils/scroll.ts
|
|
355
355
|
function createScrollWatcherForEditor(ed, opts) {
|
|
356
356
|
var _ed$getScrollTop, _ed$onDidScrollChange;
|
|
357
|
-
const DEBUG = (() => {
|
|
358
|
-
try {
|
|
359
|
-
if (typeof window !== "undefined" && window.__STREAM_MONACO_DEBUG__ !== void 0) return Boolean(window.__STREAM_MONACO_DEBUG__);
|
|
360
|
-
try {
|
|
361
|
-
const proc = nodeProcess;
|
|
362
|
-
if (proc && proc.env && proc.env.NODE_ENV === "production") return false;
|
|
363
|
-
} catch {}
|
|
364
|
-
} catch {}
|
|
365
|
-
return true;
|
|
366
|
-
})();
|
|
367
357
|
const initial = ((_ed$getScrollTop = ed.getScrollTop) === null || _ed$getScrollTop === void 0 ? void 0 : _ed$getScrollTop.call(ed)) ?? 0;
|
|
368
358
|
opts.setLast(initial);
|
|
369
|
-
|
|
359
|
+
log("scrollWatcher", "initial scrollTop=", initial);
|
|
370
360
|
let suppressedExternally = false;
|
|
371
361
|
const THRESHOLD_PX = 6;
|
|
362
|
+
let domNode = null;
|
|
363
|
+
let interactionListener = null;
|
|
372
364
|
const listener = (e) => {
|
|
373
365
|
var _ed$getScrollTop2;
|
|
374
366
|
if (suppressedExternally) {
|
|
375
|
-
|
|
367
|
+
log("scrollWatcher", "suppressedExternally, ignoring event");
|
|
376
368
|
return;
|
|
377
369
|
}
|
|
378
370
|
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;
|
|
379
371
|
const delta = currentTop - opts.getLast();
|
|
380
372
|
opts.setLast(currentTop);
|
|
381
373
|
if (Math.abs(delta) < THRESHOLD_PX) {
|
|
382
|
-
|
|
374
|
+
log("scrollWatcher", "small delta ignored", delta);
|
|
375
|
+
try {
|
|
376
|
+
const scrollHeight = typeof ed.getScrollHeight === "function" ? ed.getScrollHeight() : void 0;
|
|
377
|
+
const li = typeof ed.getLayoutInfo === "function" ? ed.getLayoutInfo() : void 0;
|
|
378
|
+
const viewportH = (li === null || li === void 0 ? void 0 : li.height) ?? void 0;
|
|
379
|
+
if (typeof scrollHeight === "number" && typeof viewportH === "number") {
|
|
380
|
+
const distance = scrollHeight - (currentTop + viewportH);
|
|
381
|
+
if (distance <= Math.max(THRESHOLD_PX, 0)) {
|
|
382
|
+
log("scrollWatcher", "small delta but at bottom, maybe resume", { distance });
|
|
383
|
+
opts.onMaybeResume();
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
} catch {}
|
|
383
387
|
return;
|
|
384
388
|
}
|
|
385
|
-
|
|
389
|
+
log("scrollWatcher", "delta=", delta, "currentTop=", currentTop);
|
|
386
390
|
if (delta < 0) {
|
|
387
|
-
|
|
391
|
+
log("scrollWatcher", "pause detected delta=", delta);
|
|
388
392
|
opts.onPause();
|
|
389
393
|
return;
|
|
390
394
|
}
|
|
391
|
-
|
|
395
|
+
log("scrollWatcher", "maybe resume delta=", delta);
|
|
392
396
|
opts.onMaybeResume();
|
|
393
397
|
};
|
|
394
398
|
const disp = ((_ed$onDidScrollChange = ed.onDidScrollChange) === null || _ed$onDidScrollChange === void 0 ? void 0 : _ed$onDidScrollChange.call(ed, listener)) ?? null;
|
|
@@ -398,11 +402,56 @@ function createScrollWatcherForEditor(ed, opts) {
|
|
|
398
402
|
if (disp && typeof disp.dispose === "function") disp.dispose();
|
|
399
403
|
else if (typeof disp === "function") disp();
|
|
400
404
|
} catch {}
|
|
401
|
-
|
|
405
|
+
log("scrollWatcher", "dispose");
|
|
402
406
|
},
|
|
403
407
|
setSuppressed(v) {
|
|
404
|
-
|
|
405
|
-
if (
|
|
408
|
+
const newVal = !!v;
|
|
409
|
+
if (newVal === suppressedExternally) return;
|
|
410
|
+
suppressedExternally = newVal;
|
|
411
|
+
log("scrollWatcher", "setSuppressed =>", suppressedExternally);
|
|
412
|
+
try {
|
|
413
|
+
if (!domNode && typeof ed.getDomNode === "function") domNode = ed.getDomNode();
|
|
414
|
+
if (suppressedExternally && domNode) {
|
|
415
|
+
if (!interactionListener) {
|
|
416
|
+
interactionListener = () => {
|
|
417
|
+
try {
|
|
418
|
+
var _ed$getScrollTop3;
|
|
419
|
+
log("scrollWatcher", "user interaction detected while suppressed, cancelling suppression");
|
|
420
|
+
opts.onPause();
|
|
421
|
+
suppressedExternally = false;
|
|
422
|
+
const cur = ((_ed$getScrollTop3 = ed.getScrollTop) === null || _ed$getScrollTop3 === void 0 ? void 0 : _ed$getScrollTop3.call(ed)) ?? 0;
|
|
423
|
+
opts.setLast(cur);
|
|
424
|
+
try {
|
|
425
|
+
const scrollHeight = typeof ed.getScrollHeight === "function" ? ed.getScrollHeight() : void 0;
|
|
426
|
+
const li = typeof ed.getLayoutInfo === "function" ? ed.getLayoutInfo() : void 0;
|
|
427
|
+
const viewportH = (li === null || li === void 0 ? void 0 : li.height) ?? void 0;
|
|
428
|
+
if (typeof scrollHeight === "number" && typeof viewportH === "number") {
|
|
429
|
+
const distance = scrollHeight - (cur + viewportH);
|
|
430
|
+
if (distance <= Math.max(THRESHOLD_PX, 0)) {
|
|
431
|
+
log("scrollWatcher", "interaction moved to bottom, maybe resume", { distance });
|
|
432
|
+
opts.onMaybeResume();
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
} catch {}
|
|
436
|
+
if (domNode && interactionListener) {
|
|
437
|
+
domNode.removeEventListener("wheel", interactionListener, { passive: true });
|
|
438
|
+
domNode.removeEventListener("pointerdown", interactionListener);
|
|
439
|
+
domNode.removeEventListener("touchstart", interactionListener);
|
|
440
|
+
}
|
|
441
|
+
interactionListener = null;
|
|
442
|
+
} catch {}
|
|
443
|
+
};
|
|
444
|
+
domNode.addEventListener("wheel", interactionListener, { passive: true });
|
|
445
|
+
domNode.addEventListener("pointerdown", interactionListener);
|
|
446
|
+
domNode.addEventListener("touchstart", interactionListener);
|
|
447
|
+
}
|
|
448
|
+
} else if (domNode && interactionListener) {
|
|
449
|
+
domNode.removeEventListener("wheel", interactionListener, { passive: true });
|
|
450
|
+
domNode.removeEventListener("pointerdown", interactionListener);
|
|
451
|
+
domNode.removeEventListener("touchstart", interactionListener);
|
|
452
|
+
interactionListener = null;
|
|
453
|
+
}
|
|
454
|
+
} catch {}
|
|
406
455
|
}
|
|
407
456
|
};
|
|
408
457
|
return api;
|
|
@@ -450,11 +499,14 @@ var DiffEditorManager = class {
|
|
|
450
499
|
};
|
|
451
500
|
}
|
|
452
501
|
lastRevealLineDiff = null;
|
|
502
|
+
revealTicketDiff = 0;
|
|
453
503
|
revealDebounceIdDiff = null;
|
|
454
504
|
revealDebounceMs = defaultRevealDebounceMs;
|
|
455
505
|
revealIdleTimerIdDiff = null;
|
|
456
506
|
revealStrategyOption;
|
|
457
507
|
revealBatchOnIdleMsOption;
|
|
508
|
+
scrollWatcherSuppressionMs = 500;
|
|
509
|
+
diffScrollWatcherSuppressionTimer = null;
|
|
458
510
|
appendBufferDiff = [];
|
|
459
511
|
appendBufferDiffScheduled = false;
|
|
460
512
|
rafScheduler = createRafScheduler();
|
|
@@ -484,6 +536,26 @@ var DiffEditorManager = class {
|
|
|
484
536
|
const desired = Math.max(fromLines, scrollH);
|
|
485
537
|
return Math.min(desired, this.maxHeightValue);
|
|
486
538
|
}
|
|
539
|
+
isOverflowAutoDiff() {
|
|
540
|
+
return !!this.lastContainer && this.lastContainer.style.overflow === "auto";
|
|
541
|
+
}
|
|
542
|
+
shouldPerformImmediateRevealDiff() {
|
|
543
|
+
return this.autoScrollOnUpdate && this.shouldAutoScrollDiff && this.hasVerticalScrollbarModified() && this.isOverflowAutoDiff();
|
|
544
|
+
}
|
|
545
|
+
suppressScrollWatcherDiff(ms) {
|
|
546
|
+
if (!this.diffScrollWatcher || typeof this.diffScrollWatcher.setSuppressed !== "function") return;
|
|
547
|
+
if (this.diffScrollWatcherSuppressionTimer != null) {
|
|
548
|
+
clearTimeout(this.diffScrollWatcherSuppressionTimer);
|
|
549
|
+
this.diffScrollWatcherSuppressionTimer = null;
|
|
550
|
+
}
|
|
551
|
+
this.diffScrollWatcher.setSuppressed(true);
|
|
552
|
+
this.diffScrollWatcherSuppressionTimer = setTimeout(() => {
|
|
553
|
+
try {
|
|
554
|
+
this.diffScrollWatcher.setSuppressed(false);
|
|
555
|
+
} catch {}
|
|
556
|
+
this.diffScrollWatcherSuppressionTimer = null;
|
|
557
|
+
}, ms);
|
|
558
|
+
}
|
|
487
559
|
hasVerticalScrollbarModified() {
|
|
488
560
|
if (!this.diffEditorView) return false;
|
|
489
561
|
if (this._hasScrollBar) return true;
|
|
@@ -503,21 +575,56 @@ var DiffEditorManager = class {
|
|
|
503
575
|
}
|
|
504
576
|
maybeScrollDiffToBottom(targetLine, prevLineOverride) {
|
|
505
577
|
this.rafScheduler.schedule("maybe-scroll-diff", () => {
|
|
578
|
+
log("diff", "maybeScrollDiffToBottom called", {
|
|
579
|
+
targetLine,
|
|
580
|
+
prevLineOverride,
|
|
581
|
+
diffAutoScroll: this.diffAutoScroll,
|
|
582
|
+
autoScrollOnUpdate: this.autoScrollOnUpdate,
|
|
583
|
+
shouldAutoScrollDiff: this.shouldAutoScrollDiff
|
|
584
|
+
});
|
|
506
585
|
if (!this.diffEditorView) return;
|
|
507
|
-
|
|
586
|
+
const hasV = this.hasVerticalScrollbarModified();
|
|
587
|
+
log("diff", "hasVerticalScrollbarModified ->", hasV);
|
|
588
|
+
if (!(this.diffAutoScroll && this.autoScrollOnUpdate && this.shouldAutoScrollDiff && hasV)) return;
|
|
508
589
|
const me = this.diffEditorView.getModifiedEditor();
|
|
509
590
|
const model = me.getModel();
|
|
510
591
|
const currentLine = (model === null || model === void 0 ? void 0 : model.getLineCount()) ?? 1;
|
|
511
592
|
const line = targetLine ?? currentLine;
|
|
512
593
|
const prevLine = typeof prevLineOverride === "number" ? prevLineOverride : this.lastKnownModifiedLineCount ?? -1;
|
|
594
|
+
log("diff", "scroll metrics", {
|
|
595
|
+
prevLine,
|
|
596
|
+
currentLine,
|
|
597
|
+
line,
|
|
598
|
+
lastRevealLineDiff: this.lastRevealLineDiff
|
|
599
|
+
});
|
|
513
600
|
if (prevLine !== -1 && prevLine === currentLine && line === currentLine) return;
|
|
514
601
|
if (this.lastRevealLineDiff !== null && this.lastRevealLineDiff === line) return;
|
|
515
602
|
const batchMs = this.revealBatchOnIdleMsOption ?? this.options.revealBatchOnIdleMs ?? defaultRevealBatchOnIdleMs;
|
|
603
|
+
log("diff", "reveal timing", {
|
|
604
|
+
batchMs,
|
|
605
|
+
revealDebounceMs: this.revealDebounceMs,
|
|
606
|
+
revealDebounceMsOption: this.revealDebounceMsOption
|
|
607
|
+
});
|
|
516
608
|
if (typeof batchMs === "number" && batchMs > 0) {
|
|
609
|
+
if (hasV) {
|
|
610
|
+
const ticket$1 = ++this.revealTicketDiff;
|
|
611
|
+
log("diff", "has scrollbar -> immediate ticketed reveal", {
|
|
612
|
+
ticket: ticket$1,
|
|
613
|
+
line
|
|
614
|
+
});
|
|
615
|
+
this.performRevealDiffTicketed(line, ticket$1);
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
517
618
|
if (this.revealIdleTimerIdDiff != null) clearTimeout(this.revealIdleTimerIdDiff);
|
|
619
|
+
const ticket = ++this.revealTicketDiff;
|
|
620
|
+
log("diff", "scheduling idle reveal", {
|
|
621
|
+
ticket,
|
|
622
|
+
batchMs,
|
|
623
|
+
line
|
|
624
|
+
});
|
|
518
625
|
this.revealIdleTimerIdDiff = setTimeout(() => {
|
|
519
626
|
this.revealIdleTimerIdDiff = null;
|
|
520
|
-
this.
|
|
627
|
+
this.performRevealDiffTicketed(line, ticket);
|
|
521
628
|
}, batchMs);
|
|
522
629
|
return;
|
|
523
630
|
}
|
|
@@ -528,14 +635,32 @@ var DiffEditorManager = class {
|
|
|
528
635
|
const ms = typeof this.revealDebounceMs === "number" && this.revealDebounceMs > 0 ? this.revealDebounceMs : typeof this.revealDebounceMsOption === "number" && this.revealDebounceMsOption > 0 ? this.revealDebounceMsOption : this.revealDebounceMs;
|
|
529
636
|
this.revealDebounceIdDiff = setTimeout(() => {
|
|
530
637
|
this.revealDebounceIdDiff = null;
|
|
531
|
-
this.
|
|
638
|
+
const ticket = ++this.revealTicketDiff;
|
|
639
|
+
log("diff", "debounced reveal firing", {
|
|
640
|
+
ticket,
|
|
641
|
+
line
|
|
642
|
+
});
|
|
643
|
+
this.performRevealDiffTicketed(line, ticket);
|
|
532
644
|
}, ms);
|
|
533
645
|
this.lastKnownModifiedLineCount = currentLine;
|
|
534
646
|
});
|
|
535
647
|
}
|
|
536
|
-
|
|
648
|
+
performRevealDiffTicketed(line, ticket) {
|
|
537
649
|
this.rafScheduler.schedule("revealDiff", () => {
|
|
538
650
|
var _editor;
|
|
651
|
+
if (this.diffScrollWatcher) {
|
|
652
|
+
log("diff", "performRevealDiffTicketed - suppressing watcher", {
|
|
653
|
+
ticket,
|
|
654
|
+
line,
|
|
655
|
+
ms: this.scrollWatcherSuppressionMs
|
|
656
|
+
});
|
|
657
|
+
this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs);
|
|
658
|
+
}
|
|
659
|
+
if (ticket !== this.revealTicketDiff) return;
|
|
660
|
+
log("diff", "performRevealDiffTicketed - performing reveal", {
|
|
661
|
+
ticket,
|
|
662
|
+
line
|
|
663
|
+
});
|
|
539
664
|
const strategy = this.revealStrategyOption ?? this.options.revealStrategy ?? "centerIfOutside";
|
|
540
665
|
const ScrollType = monaco_shim_exports.ScrollType || ((_editor = monaco_shim_exports.editor) === null || _editor === void 0 ? void 0 : _editor.ScrollType);
|
|
541
666
|
const smooth = ScrollType && typeof ScrollType.Smooth !== "undefined" ? ScrollType.Smooth : void 0;
|
|
@@ -553,13 +678,71 @@ var DiffEditorManager = class {
|
|
|
553
678
|
} catch {}
|
|
554
679
|
}
|
|
555
680
|
this.lastRevealLineDiff = line;
|
|
681
|
+
log("diff", "performRevealDiffTicketed - revealed", {
|
|
682
|
+
line,
|
|
683
|
+
lastRevealLineDiff: this.lastRevealLineDiff
|
|
684
|
+
});
|
|
685
|
+
try {
|
|
686
|
+
var _this$diffEditorView, _this$diffEditorView$, _this$diffEditorView$2;
|
|
687
|
+
this.shouldAutoScrollDiff = true;
|
|
688
|
+
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;
|
|
689
|
+
} catch {}
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
performImmediateRevealDiff(line, ticket) {
|
|
693
|
+
var _editor2;
|
|
694
|
+
if (!this.diffEditorView) return;
|
|
695
|
+
if (ticket !== this.revealTicketDiff) return;
|
|
696
|
+
const ScrollType = monaco_shim_exports.ScrollType || ((_editor2 = monaco_shim_exports.editor) === null || _editor2 === void 0 ? void 0 : _editor2.ScrollType);
|
|
697
|
+
const immediate = ScrollType && typeof ScrollType.Immediate !== "undefined" ? ScrollType.Immediate : void 0;
|
|
698
|
+
const me = this.diffEditorView.getModifiedEditor();
|
|
699
|
+
if (typeof immediate !== "undefined") me.revealLine(line, immediate);
|
|
700
|
+
else me.revealLine(line);
|
|
701
|
+
this.measureViewportDiff();
|
|
702
|
+
log("diff", "performImmediateRevealDiff", {
|
|
703
|
+
line,
|
|
704
|
+
ticket
|
|
705
|
+
});
|
|
706
|
+
try {
|
|
707
|
+
var _this$diffEditorView2, _this$diffEditorView3, _this$diffEditorView4;
|
|
708
|
+
this.shouldAutoScrollDiff = true;
|
|
709
|
+
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;
|
|
710
|
+
} catch {}
|
|
711
|
+
}
|
|
712
|
+
scheduleImmediateRevealAfterLayoutDiff(line) {
|
|
713
|
+
const ticket = ++this.revealTicketDiff;
|
|
714
|
+
this.rafScheduler.schedule("immediate-reveal-diff", async () => {
|
|
715
|
+
const target = this.diffEditorView && this.diffHeightManager ? Math.min(this.computedHeight(), this.maxHeightValue) : -1;
|
|
716
|
+
if (target !== -1 && this.diffHeightManager) {
|
|
717
|
+
if (this.lastContainer) this.lastContainer.style.height = `${target}px`;
|
|
718
|
+
await this.waitForHeightAppliedDiff(target);
|
|
719
|
+
}
|
|
720
|
+
this.performImmediateRevealDiff(line, ticket);
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
waitForHeightAppliedDiff(target, timeoutMs = 500) {
|
|
724
|
+
return new Promise((resolve) => {
|
|
725
|
+
const start = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
|
|
726
|
+
const check = () => {
|
|
727
|
+
const applied = this.lastContainer ? Number.parseFloat((this.lastContainer.style.height || "").replace("px", "")) || 0 : -1;
|
|
728
|
+
if (applied >= target - 1) {
|
|
729
|
+
resolve();
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
if ((typeof performance !== "undefined" && performance.now ? performance.now() : Date.now()) - start > timeoutMs) {
|
|
733
|
+
resolve();
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
requestAnimationFrame(check);
|
|
737
|
+
};
|
|
738
|
+
check();
|
|
556
739
|
});
|
|
557
740
|
}
|
|
558
741
|
async createDiffEditor(container, originalCode, modifiedCode, language, currentTheme) {
|
|
559
742
|
var _me$getScrollHeight2, _me$getOption, _oEditor$onDidContent, _mEditor$onDidContent;
|
|
560
743
|
this.cleanup();
|
|
561
744
|
this.lastContainer = container;
|
|
562
|
-
container.style.overflow = "
|
|
745
|
+
container.style.overflow = "hidden";
|
|
563
746
|
container.style.maxHeight = this.maxHeightCSS;
|
|
564
747
|
const lang = processedLanguage(language) || language;
|
|
565
748
|
this.originalModel = monaco_shim_exports.editor.createModel(originalCode, lang);
|
|
@@ -608,13 +791,23 @@ var DiffEditorManager = class {
|
|
|
608
791
|
}
|
|
609
792
|
});
|
|
610
793
|
}
|
|
611
|
-
|
|
794
|
+
log("diff", "createDiffEditor", {
|
|
795
|
+
autoScrollInitial: this.autoScrollInitial,
|
|
796
|
+
diffAutoScroll: this.diffAutoScroll
|
|
797
|
+
});
|
|
798
|
+
const MIN_VISIBLE_HEIGHT = Math.min(120, this.maxHeightValue);
|
|
799
|
+
container.style.minHeight = `${MIN_VISIBLE_HEIGHT}px`;
|
|
612
800
|
if (this.diffHeightManager) {
|
|
613
801
|
this.diffHeightManager.dispose();
|
|
614
802
|
this.diffHeightManager = null;
|
|
615
803
|
}
|
|
616
804
|
this.diffHeightManager = createHeightManager(container, () => this.computedHeight());
|
|
617
805
|
this.diffHeightManager.update();
|
|
806
|
+
const initialComputed = this.computedHeight();
|
|
807
|
+
if (initialComputed >= this.maxHeightValue - 1) {
|
|
808
|
+
container.style.height = `${this.maxHeightValue}px`;
|
|
809
|
+
container.style.overflow = "auto";
|
|
810
|
+
}
|
|
618
811
|
const me = this.diffEditorView.getModifiedEditor();
|
|
619
812
|
this.cachedScrollHeightDiff = ((_me$getScrollHeight2 = me.getScrollHeight) === null || _me$getScrollHeight2 === void 0 ? void 0 : _me$getScrollHeight2.call(me)) ?? null;
|
|
620
813
|
this.cachedLineHeightDiff = ((_me$getOption = me.getOption) === null || _me$getOption === void 0 ? void 0 : _me$getOption.call(me, monaco_shim_exports.editor.EditorOption.lineHeight)) ?? null;
|
|
@@ -624,33 +817,54 @@ var DiffEditorManager = class {
|
|
|
624
817
|
(_oEditor$onDidContent = oEditor.onDidContentSizeChange) === null || _oEditor$onDidContent === void 0 || _oEditor$onDidContent.call(oEditor, () => {
|
|
625
818
|
this._hasScrollBar = false;
|
|
626
819
|
this.rafScheduler.schedule("content-size-change-diff", () => {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
820
|
+
var _oEditor$getScrollHei, _oEditor$getOption, _this$diffHeightManag, _this$diffHeightManag2;
|
|
821
|
+
this.cachedScrollHeightDiff = ((_oEditor$getScrollHei = oEditor.getScrollHeight) === null || _oEditor$getScrollHei === void 0 ? void 0 : _oEditor$getScrollHei.call(oEditor)) ?? this.cachedScrollHeightDiff;
|
|
822
|
+
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;
|
|
823
|
+
this.cachedComputedHeightDiff = this.computedHeight();
|
|
824
|
+
if ((_this$diffHeightManag = this.diffHeightManager) === null || _this$diffHeightManag === void 0 ? void 0 : _this$diffHeightManag.isSuppressed()) return;
|
|
825
|
+
(_this$diffHeightManag2 = this.diffHeightManager) === null || _this$diffHeightManag2 === void 0 || _this$diffHeightManag2.update();
|
|
826
|
+
const computed$2 = this.computedHeight();
|
|
827
|
+
if (this.lastContainer) {
|
|
828
|
+
const prevOverflow = this.lastContainer.style.overflow;
|
|
829
|
+
const newOverflow = computed$2 >= this.maxHeightValue - 1 ? "auto" : "hidden";
|
|
830
|
+
if (prevOverflow !== newOverflow) {
|
|
831
|
+
this.lastContainer.style.overflow = newOverflow;
|
|
832
|
+
if (newOverflow === "auto" && this.shouldAutoScrollDiff) {
|
|
833
|
+
var _this$modifiedModel;
|
|
834
|
+
this.maybeScrollDiffToBottom((_this$modifiedModel = this.modifiedModel) === null || _this$modifiedModel === void 0 ? void 0 : _this$modifiedModel.getLineCount());
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
635
838
|
});
|
|
636
839
|
});
|
|
637
840
|
(_mEditor$onDidContent = mEditor.onDidContentSizeChange) === null || _mEditor$onDidContent === void 0 || _mEditor$onDidContent.call(mEditor, () => {
|
|
638
841
|
this._hasScrollBar = false;
|
|
639
842
|
this.rafScheduler.schedule("content-size-change-diff", () => {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
843
|
+
var _mEditor$getScrollHei, _mEditor$getOption, _this$diffHeightManag3, _this$diffHeightManag4;
|
|
844
|
+
this.cachedScrollHeightDiff = ((_mEditor$getScrollHei = mEditor.getScrollHeight) === null || _mEditor$getScrollHei === void 0 ? void 0 : _mEditor$getScrollHei.call(mEditor)) ?? this.cachedScrollHeightDiff;
|
|
845
|
+
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;
|
|
846
|
+
this.cachedComputedHeightDiff = this.computedHeight();
|
|
847
|
+
if ((_this$diffHeightManag3 = this.diffHeightManager) === null || _this$diffHeightManag3 === void 0 ? void 0 : _this$diffHeightManag3.isSuppressed()) return;
|
|
848
|
+
(_this$diffHeightManag4 = this.diffHeightManager) === null || _this$diffHeightManag4 === void 0 || _this$diffHeightManag4.update();
|
|
849
|
+
const computed$2 = this.computedHeight();
|
|
850
|
+
if (this.lastContainer) {
|
|
851
|
+
const prevOverflow = this.lastContainer.style.overflow;
|
|
852
|
+
const newOverflow = computed$2 >= this.maxHeightValue - 1 ? "auto" : "hidden";
|
|
853
|
+
if (prevOverflow !== newOverflow) {
|
|
854
|
+
this.lastContainer.style.overflow = newOverflow;
|
|
855
|
+
if (newOverflow === "auto" && this.shouldAutoScrollDiff) {
|
|
856
|
+
var _this$modifiedModel2;
|
|
857
|
+
this.maybeScrollDiffToBottom((_this$modifiedModel2 = this.modifiedModel) === null || _this$modifiedModel2 === void 0 ? void 0 : _this$modifiedModel2.getLineCount());
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
648
861
|
});
|
|
649
862
|
});
|
|
650
863
|
mEditor.onDidChangeModelContent(() => {
|
|
651
864
|
this.lastKnownModifiedDirty = true;
|
|
652
865
|
this.rafScheduler.schedule("sync-last-known-modified", () => this.syncLastKnownModified());
|
|
653
866
|
});
|
|
867
|
+
this.maybeScrollDiffToBottom(this.modifiedModel.getLineCount(), this.lastKnownModifiedLineCount ?? void 0);
|
|
654
868
|
return this.diffEditorView;
|
|
655
869
|
}
|
|
656
870
|
updateDiff(originalCode, modifiedCode, codeLanguage) {
|
|
@@ -710,11 +924,37 @@ var DiffEditorManager = class {
|
|
|
710
924
|
}
|
|
711
925
|
const prev = this.lastKnownModifiedCode ?? this.modifiedModel.getValue();
|
|
712
926
|
if (prev === newCode) return;
|
|
927
|
+
const prevLine = this.modifiedModel.getLineCount();
|
|
713
928
|
if (newCode.startsWith(prev) && prev.length < newCode.length) {
|
|
714
|
-
const prevLine = this.modifiedModel.getLineCount();
|
|
715
929
|
this.appendToModel(this.modifiedModel, newCode.slice(prev.length));
|
|
716
930
|
this.maybeScrollDiffToBottom(this.modifiedModel.getLineCount(), prevLine);
|
|
717
|
-
} else
|
|
931
|
+
} else {
|
|
932
|
+
this.applyMinimalEditToModel(this.modifiedModel, prev, newCode);
|
|
933
|
+
const newLine = this.modifiedModel.getLineCount();
|
|
934
|
+
if (newLine !== prevLine) {
|
|
935
|
+
const shouldImmediate = this.shouldPerformImmediateRevealDiff();
|
|
936
|
+
if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
|
|
937
|
+
const computed$2 = this.computedHeight();
|
|
938
|
+
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) {
|
|
939
|
+
this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
940
|
+
this.lastContainer.style.overflow = "auto";
|
|
941
|
+
}
|
|
942
|
+
if (shouldImmediate) this.scheduleImmediateRevealAfterLayoutDiff(newLine);
|
|
943
|
+
else this.maybeScrollDiffToBottom(newLine, prevLine);
|
|
944
|
+
if (this.autoScrollOnUpdate && this.shouldAutoScrollDiff) try {
|
|
945
|
+
var _editor3, _me2$getModel, _me2$getScrollTop;
|
|
946
|
+
const ScrollType = monaco_shim_exports.ScrollType || ((_editor3 = monaco_shim_exports.editor) === null || _editor3 === void 0 ? void 0 : _editor3.ScrollType);
|
|
947
|
+
const immediate = ScrollType && typeof ScrollType.Immediate !== "undefined" ? ScrollType.Immediate : void 0;
|
|
948
|
+
const me2 = this.diffEditorView.getModifiedEditor();
|
|
949
|
+
const targetLine = ((_me2$getModel = me2.getModel()) === null || _me2$getModel === void 0 ? void 0 : _me2$getModel.getLineCount()) ?? newLine;
|
|
950
|
+
if (typeof immediate !== "undefined") me2.revealLine(targetLine, immediate);
|
|
951
|
+
else me2.revealLine(targetLine);
|
|
952
|
+
this.lastRevealLineDiff = targetLine;
|
|
953
|
+
this.shouldAutoScrollDiff = true;
|
|
954
|
+
this.lastScrollTopDiff = ((_me2$getScrollTop = me2.getScrollTop) === null || _me2$getScrollTop === void 0 ? void 0 : _me2$getScrollTop.call(me2)) ?? this.lastScrollTopDiff;
|
|
955
|
+
} catch {}
|
|
956
|
+
}
|
|
957
|
+
}
|
|
718
958
|
this.lastKnownModifiedCode = newCode;
|
|
719
959
|
}
|
|
720
960
|
appendOriginal(appendText, codeLanguage) {
|
|
@@ -724,9 +964,7 @@ var DiffEditorManager = class {
|
|
|
724
964
|
if (lang && this.originalModel.getLanguageId() !== lang) monaco_shim_exports.editor.setModelLanguage(this.originalModel, lang);
|
|
725
965
|
}
|
|
726
966
|
this.appendToModel(this.originalModel, appendText);
|
|
727
|
-
|
|
728
|
-
this.lastKnownOriginalCode = this.originalModel.getValue();
|
|
729
|
-
} catch {}
|
|
967
|
+
this.lastKnownOriginalCode = this.originalModel.getValue();
|
|
730
968
|
}
|
|
731
969
|
appendModified(appendText, codeLanguage) {
|
|
732
970
|
if (!this.diffEditorView || !this.modifiedModel || !appendText) return;
|
|
@@ -795,6 +1033,15 @@ var DiffEditorManager = class {
|
|
|
795
1033
|
clearTimeout(this.revealDebounceIdDiff);
|
|
796
1034
|
this.revealDebounceIdDiff = null;
|
|
797
1035
|
}
|
|
1036
|
+
if (this.revealIdleTimerIdDiff != null) {
|
|
1037
|
+
clearTimeout(this.revealIdleTimerIdDiff);
|
|
1038
|
+
this.revealIdleTimerIdDiff = null;
|
|
1039
|
+
}
|
|
1040
|
+
if (this.diffScrollWatcherSuppressionTimer != null) {
|
|
1041
|
+
clearTimeout(this.diffScrollWatcherSuppressionTimer);
|
|
1042
|
+
this.diffScrollWatcherSuppressionTimer = null;
|
|
1043
|
+
}
|
|
1044
|
+
this.revealTicketDiff = 0;
|
|
798
1045
|
this.lastRevealLineDiff = null;
|
|
799
1046
|
}
|
|
800
1047
|
safeClean() {
|
|
@@ -815,6 +1062,15 @@ var DiffEditorManager = class {
|
|
|
815
1062
|
clearTimeout(this.revealDebounceIdDiff);
|
|
816
1063
|
this.revealDebounceIdDiff = null;
|
|
817
1064
|
}
|
|
1065
|
+
if (this.revealIdleTimerIdDiff != null) {
|
|
1066
|
+
clearTimeout(this.revealIdleTimerIdDiff);
|
|
1067
|
+
this.revealIdleTimerIdDiff = null;
|
|
1068
|
+
}
|
|
1069
|
+
if (this.diffScrollWatcherSuppressionTimer != null) {
|
|
1070
|
+
clearTimeout(this.diffScrollWatcherSuppressionTimer);
|
|
1071
|
+
this.diffScrollWatcherSuppressionTimer = null;
|
|
1072
|
+
}
|
|
1073
|
+
this.revealTicketDiff = 0;
|
|
818
1074
|
this.lastRevealLineDiff = null;
|
|
819
1075
|
this.rafScheduler.cancel("content-size-change-diff");
|
|
820
1076
|
this.rafScheduler.cancel("sync-last-known-modified");
|
|
@@ -828,7 +1084,7 @@ var DiffEditorManager = class {
|
|
|
828
1084
|
this.lastKnownModifiedCode = model.getValue();
|
|
829
1085
|
this.lastKnownModifiedLineCount = model.getLineCount();
|
|
830
1086
|
}
|
|
831
|
-
}
|
|
1087
|
+
} finally {
|
|
832
1088
|
this.lastKnownModifiedDirty = false;
|
|
833
1089
|
}
|
|
834
1090
|
}
|
|
@@ -872,10 +1128,20 @@ var DiffEditorManager = class {
|
|
|
872
1128
|
else this.applyMinimalEditToModel(m, prevM, modified);
|
|
873
1129
|
this.lastKnownModifiedCode = modified;
|
|
874
1130
|
const newMLineCount = m.getLineCount();
|
|
875
|
-
if (newMLineCount !== prevMLineCount)
|
|
1131
|
+
if (newMLineCount !== prevMLineCount) {
|
|
1132
|
+
const shouldImmediate = this.shouldPerformImmediateRevealDiff();
|
|
1133
|
+
if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
|
|
1134
|
+
const computed$2 = this.computedHeight();
|
|
1135
|
+
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) {
|
|
1136
|
+
this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
1137
|
+
this.lastContainer.style.overflow = "auto";
|
|
1138
|
+
}
|
|
1139
|
+
if (shouldImmediate) this.scheduleImmediateRevealAfterLayoutDiff(newMLineCount);
|
|
1140
|
+
else this.maybeScrollDiffToBottom(newMLineCount, prevMLineCount);
|
|
1141
|
+
}
|
|
876
1142
|
}
|
|
877
1143
|
}
|
|
878
|
-
flushAppendBufferDiff() {
|
|
1144
|
+
async flushAppendBufferDiff() {
|
|
879
1145
|
if (!this.diffEditorView) return;
|
|
880
1146
|
if (this.appendBufferDiff.length === 0) return;
|
|
881
1147
|
this.appendBufferDiffScheduled = false;
|
|
@@ -885,39 +1151,128 @@ var DiffEditorManager = class {
|
|
|
885
1151
|
this.appendBufferDiff.length = 0;
|
|
886
1152
|
return;
|
|
887
1153
|
}
|
|
888
|
-
|
|
1154
|
+
let parts = this.appendBufferDiff.splice(0);
|
|
1155
|
+
const prevLineInit = model.getLineCount();
|
|
1156
|
+
const totalText = parts.join("");
|
|
1157
|
+
const totalChars = totalText.length;
|
|
1158
|
+
if (parts.length === 1 && totalChars > 5e3) {
|
|
1159
|
+
const lines = totalText.split(/\r?\n/);
|
|
1160
|
+
const chunkSize = 200;
|
|
1161
|
+
const chunks = [];
|
|
1162
|
+
for (let i = 0; i < lines.length; i += chunkSize) chunks.push(`${lines.slice(i, i + chunkSize).join("\n")}\n`);
|
|
1163
|
+
if (chunks.length > 1) parts = chunks;
|
|
1164
|
+
}
|
|
1165
|
+
const applyChunked = parts.length > 1 && (totalChars > 2e3 || model.getLineCount && model.getLineCount() + 0 - prevLineInit > 50);
|
|
1166
|
+
log("diff", "flushAppendBufferDiff start", {
|
|
1167
|
+
partsCount: parts.length,
|
|
1168
|
+
totalChars,
|
|
1169
|
+
applyChunked
|
|
1170
|
+
});
|
|
1171
|
+
let prevLine = prevLineInit;
|
|
1172
|
+
const watcherApi = this.diffScrollWatcher;
|
|
1173
|
+
let suppressedByFlush = false;
|
|
1174
|
+
if (watcherApi && typeof watcherApi.setSuppressed === "function") try {
|
|
1175
|
+
if (this.diffScrollWatcherSuppressionTimer != null) {
|
|
1176
|
+
clearTimeout(this.diffScrollWatcherSuppressionTimer);
|
|
1177
|
+
this.diffScrollWatcherSuppressionTimer = null;
|
|
1178
|
+
}
|
|
1179
|
+
watcherApi.setSuppressed(true);
|
|
1180
|
+
suppressedByFlush = true;
|
|
1181
|
+
} catch {}
|
|
1182
|
+
if (applyChunked) {
|
|
1183
|
+
log("diff", "flushAppendBufferDiff applying chunked", { partsLen: parts.length });
|
|
1184
|
+
let idx = 0;
|
|
1185
|
+
for (const part of parts) {
|
|
1186
|
+
if (!part) continue;
|
|
1187
|
+
idx += 1;
|
|
1188
|
+
log("diff", "flushAppendBufferDiff chunk", {
|
|
1189
|
+
idx,
|
|
1190
|
+
partLen: part.length,
|
|
1191
|
+
prevLine
|
|
1192
|
+
});
|
|
1193
|
+
const lastColumn$1 = model.getLineMaxColumn(prevLine);
|
|
1194
|
+
const range$1 = new monaco_shim_exports.Range(prevLine, lastColumn$1, prevLine, lastColumn$1);
|
|
1195
|
+
model.applyEdits([{
|
|
1196
|
+
range: range$1,
|
|
1197
|
+
text: part,
|
|
1198
|
+
forceMoveMarkers: true
|
|
1199
|
+
}]);
|
|
1200
|
+
this.lastKnownModifiedCode = model.getValue();
|
|
1201
|
+
const newLine$1 = model.getLineCount();
|
|
1202
|
+
this.lastKnownModifiedLineCount = newLine$1;
|
|
1203
|
+
await new Promise((resolve) => typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame(resolve) : setTimeout(resolve, 0));
|
|
1204
|
+
const shouldImmediate$1 = this.shouldPerformImmediateRevealDiff();
|
|
1205
|
+
log("diff", "flushAppendBufferDiff chunk metrics", {
|
|
1206
|
+
idx,
|
|
1207
|
+
newLine: newLine$1,
|
|
1208
|
+
prevLine,
|
|
1209
|
+
shouldImmediate: shouldImmediate$1
|
|
1210
|
+
});
|
|
1211
|
+
if (shouldImmediate$1) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
|
|
1212
|
+
const computed$3 = this.computedHeight();
|
|
1213
|
+
if (computed$3 >= this.maxHeightValue - 1 && this.lastContainer) {
|
|
1214
|
+
this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
1215
|
+
this.lastContainer.style.overflow = "auto";
|
|
1216
|
+
}
|
|
1217
|
+
if (shouldImmediate$1) this.scheduleImmediateRevealAfterLayoutDiff(newLine$1);
|
|
1218
|
+
else this.maybeScrollDiffToBottom(newLine$1, prevLine);
|
|
1219
|
+
prevLine = newLine$1;
|
|
1220
|
+
log("diff", "flushAppendBufferDiff chunk applied", {
|
|
1221
|
+
idx,
|
|
1222
|
+
newLine: newLine$1
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
if (suppressedByFlush) watcherApi.setSuppressed(false);
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
const text = totalText;
|
|
889
1229
|
this.appendBufferDiff.length = 0;
|
|
1230
|
+
prevLine = model.getLineCount();
|
|
1231
|
+
const lastColumn = model.getLineMaxColumn(prevLine);
|
|
1232
|
+
const range = new monaco_shim_exports.Range(prevLine, lastColumn, prevLine, lastColumn);
|
|
1233
|
+
model.applyEdits([{
|
|
1234
|
+
range,
|
|
1235
|
+
text,
|
|
1236
|
+
forceMoveMarkers: true
|
|
1237
|
+
}]);
|
|
1238
|
+
this.lastKnownModifiedCode = model.getValue();
|
|
1239
|
+
const newLine = model.getLineCount();
|
|
1240
|
+
this.lastKnownModifiedLineCount = newLine;
|
|
1241
|
+
const shouldImmediate = this.shouldPerformImmediateRevealDiff();
|
|
1242
|
+
if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
|
|
1243
|
+
const computed$2 = this.computedHeight();
|
|
1244
|
+
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
1245
|
+
if (shouldImmediate) this.scheduleImmediateRevealAfterLayoutDiff(newLine);
|
|
1246
|
+
else this.maybeScrollDiffToBottom(newLine, prevLine);
|
|
1247
|
+
if (this.autoScrollOnUpdate && this.shouldAutoScrollDiff) try {
|
|
1248
|
+
var _editor4, _me2$getModel2, _me2$getScrollTop2;
|
|
1249
|
+
const ScrollType = monaco_shim_exports.ScrollType || ((_editor4 = monaco_shim_exports.editor) === null || _editor4 === void 0 ? void 0 : _editor4.ScrollType);
|
|
1250
|
+
const immediate = ScrollType && typeof ScrollType.Immediate !== "undefined" ? ScrollType.Immediate : void 0;
|
|
1251
|
+
const me2 = this.diffEditorView.getModifiedEditor();
|
|
1252
|
+
const targetLine = ((_me2$getModel2 = me2.getModel()) === null || _me2$getModel2 === void 0 ? void 0 : _me2$getModel2.getLineCount()) ?? newLine;
|
|
1253
|
+
if (typeof immediate !== "undefined") me2.revealLine(targetLine, immediate);
|
|
1254
|
+
else me2.revealLine(targetLine);
|
|
1255
|
+
this.lastRevealLineDiff = targetLine;
|
|
1256
|
+
this.shouldAutoScrollDiff = true;
|
|
1257
|
+
this.lastScrollTopDiff = ((_me2$getScrollTop2 = me2.getScrollTop) === null || _me2$getScrollTop2 === void 0 ? void 0 : _me2$getScrollTop2.call(me2)) ?? this.lastScrollTopDiff;
|
|
1258
|
+
} catch {}
|
|
1259
|
+
if (suppressedByFlush) watcherApi.setSuppressed(false);
|
|
890
1260
|
try {
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
model.applyEdits([{
|
|
895
|
-
range,
|
|
896
|
-
text,
|
|
897
|
-
forceMoveMarkers: true
|
|
898
|
-
}]);
|
|
899
|
-
try {
|
|
900
|
-
this.lastKnownModifiedCode = model.getValue();
|
|
901
|
-
} catch {}
|
|
902
|
-
const newLine = model.getLineCount();
|
|
903
|
-
this.maybeScrollDiffToBottom(newLine, prevLine);
|
|
904
|
-
this.lastKnownModifiedLineCount = newLine;
|
|
1261
|
+
var _this$diffEditorView5, _this$diffEditorView6, _this$diffEditorView7;
|
|
1262
|
+
this.shouldAutoScrollDiff = true;
|
|
1263
|
+
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;
|
|
905
1264
|
} catch {}
|
|
906
1265
|
}
|
|
907
1266
|
applyMinimalEditToModel(model, prev, next) {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
} catch {}
|
|
918
|
-
return;
|
|
919
|
-
}
|
|
920
|
-
} catch {}
|
|
1267
|
+
const maxChars = minimalEditMaxChars;
|
|
1268
|
+
const ratio = minimalEditMaxChangeRatio;
|
|
1269
|
+
const maxLen = Math.max(prev.length, next.length);
|
|
1270
|
+
const changeRatio = maxLen > 0 ? Math.abs(next.length - prev.length) / maxLen : 0;
|
|
1271
|
+
if (prev.length + next.length > maxChars || changeRatio > ratio) {
|
|
1272
|
+
model.setValue(next);
|
|
1273
|
+
if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
921
1276
|
const res = computeMinimalEdit(prev, next);
|
|
922
1277
|
if (!res) return;
|
|
923
1278
|
const { start, endPrevIncl, replaceText } = res;
|
|
@@ -929,9 +1284,7 @@ var DiffEditorManager = class {
|
|
|
929
1284
|
text: replaceText,
|
|
930
1285
|
forceMoveMarkers: true
|
|
931
1286
|
}]);
|
|
932
|
-
|
|
933
|
-
if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
|
|
934
|
-
} catch {}
|
|
1287
|
+
if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
|
|
935
1288
|
}
|
|
936
1289
|
appendToModel(model, appendText) {
|
|
937
1290
|
if (!appendText) return;
|
|
@@ -943,9 +1296,7 @@ var DiffEditorManager = class {
|
|
|
943
1296
|
text: appendText,
|
|
944
1297
|
forceMoveMarkers: true
|
|
945
1298
|
}]);
|
|
946
|
-
|
|
947
|
-
if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
|
|
948
|
-
} catch {}
|
|
1299
|
+
if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
|
|
949
1300
|
}
|
|
950
1301
|
};
|
|
951
1302
|
|
|
@@ -1044,14 +1395,12 @@ var EditorManager = class {
|
|
|
1044
1395
|
const lineCount = this.cachedLineCount ?? ((_editorView$getModel = editorView.getModel()) === null || _editorView$getModel === void 0 ? void 0 : _editorView$getModel.getLineCount()) ?? 1;
|
|
1045
1396
|
const lineHeight = editorView.getOption(monaco_shim_exports.editor.EditorOption.lineHeight);
|
|
1046
1397
|
const height = Math.min(lineCount * lineHeight + padding, this.maxHeightValue);
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
});
|
|
1054
|
-
} catch {}
|
|
1398
|
+
log("EditorManager.computedHeight", {
|
|
1399
|
+
lineCount,
|
|
1400
|
+
lineHeight,
|
|
1401
|
+
computed: height,
|
|
1402
|
+
maxHeightValue: this.maxHeightValue
|
|
1403
|
+
});
|
|
1055
1404
|
return height;
|
|
1056
1405
|
}
|
|
1057
1406
|
maybeScrollToBottom(targetLine) {
|
|
@@ -1102,7 +1451,6 @@ var EditorManager = class {
|
|
|
1102
1451
|
return;
|
|
1103
1452
|
}
|
|
1104
1453
|
this.dlog("performReveal executing, ticket=", ticket, "line=", line);
|
|
1105
|
-
this.lastPerformedRevealTicket = ticket;
|
|
1106
1454
|
const strategy = this.revealStrategyOption ?? this.options.revealStrategy ?? "centerIfOutside";
|
|
1107
1455
|
this.dlog("performReveal strategy=", strategy);
|
|
1108
1456
|
const ScrollType = monaco_shim_exports.ScrollType || ((_editor = monaco_shim_exports.editor) === null || _editor === void 0 ? void 0 : _editor.ScrollType);
|
|
@@ -1130,7 +1478,6 @@ var EditorManager = class {
|
|
|
1130
1478
|
this.dlog("performImmediateReveal skipped, stale ticket", ticket, "current", this.revealTicket);
|
|
1131
1479
|
return;
|
|
1132
1480
|
}
|
|
1133
|
-
this.lastPerformedRevealTicket = ticket;
|
|
1134
1481
|
const ScrollType = monaco_shim_exports.ScrollType || ((_editor2 = monaco_shim_exports.editor) === null || _editor2 === void 0 ? void 0 : _editor2.ScrollType);
|
|
1135
1482
|
const immediate = ScrollType && typeof ScrollType.Immediate !== "undefined" ? ScrollType.Immediate : void 0;
|
|
1136
1483
|
if (typeof immediate !== "undefined") this.editorView.revealLine(line, immediate);
|
|
@@ -1280,35 +1627,28 @@ var EditorManager = class {
|
|
|
1280
1627
|
}
|
|
1281
1628
|
syncLastKnownCode() {
|
|
1282
1629
|
if (!this.editorView || !this.lastKnownCodeDirty) return;
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
this.cachedLineCount = model.getLineCount() ?? this.cachedLineCount;
|
|
1288
|
-
}
|
|
1289
|
-
} catch {} finally {
|
|
1290
|
-
this.lastKnownCodeDirty = false;
|
|
1630
|
+
const model = this.editorView.getModel();
|
|
1631
|
+
if (model) {
|
|
1632
|
+
this.lastKnownCode = model.getValue();
|
|
1633
|
+
this.cachedLineCount = model.getLineCount() ?? this.cachedLineCount;
|
|
1291
1634
|
}
|
|
1635
|
+
this.lastKnownCodeDirty = false;
|
|
1292
1636
|
}
|
|
1293
1637
|
suppressScrollWatcher(ms) {
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1638
|
+
if (!this.scrollWatcher || typeof this.scrollWatcher.setSuppressed !== "function") return;
|
|
1639
|
+
this.dlog("suppressScrollWatcher", ms);
|
|
1640
|
+
if (this.scrollWatcherSuppressionTimer != null) {
|
|
1641
|
+
clearTimeout(this.scrollWatcherSuppressionTimer);
|
|
1642
|
+
this.scrollWatcherSuppressionTimer = null;
|
|
1643
|
+
}
|
|
1644
|
+
this.scrollWatcher.setSuppressed(true);
|
|
1645
|
+
this.scrollWatcherSuppressionTimer = setTimeout(() => {
|
|
1646
|
+
if (this.scrollWatcher && typeof this.scrollWatcher.setSuppressed === "function") {
|
|
1647
|
+
this.scrollWatcher.setSuppressed(false);
|
|
1648
|
+
this.dlog("suppressScrollWatcher cleared");
|
|
1300
1649
|
}
|
|
1301
|
-
this.
|
|
1302
|
-
|
|
1303
|
-
try {
|
|
1304
|
-
if (this.scrollWatcher && typeof this.scrollWatcher.setSuppressed === "function") {
|
|
1305
|
-
this.scrollWatcher.setSuppressed(false);
|
|
1306
|
-
this.dlog("suppressScrollWatcher cleared");
|
|
1307
|
-
}
|
|
1308
|
-
} catch {}
|
|
1309
|
-
this.scrollWatcherSuppressionTimer = null;
|
|
1310
|
-
}, ms);
|
|
1311
|
-
} catch {}
|
|
1650
|
+
this.scrollWatcherSuppressionTimer = null;
|
|
1651
|
+
}, ms);
|
|
1312
1652
|
}
|
|
1313
1653
|
scheduleImmediateRevealAfterLayout(line) {
|
|
1314
1654
|
const ticket = ++this.revealTicket;
|
|
@@ -1374,14 +1714,9 @@ var EditorManager = class {
|
|
|
1374
1714
|
if (newLineCount$1 !== prevLineCount$1) {
|
|
1375
1715
|
const shouldImmediate = this.shouldPerformImmediateReveal();
|
|
1376
1716
|
if (shouldImmediate) this.suppressScrollWatcher(this.scrollWatcherSuppressionMs);
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
} catch {}
|
|
1381
|
-
if (shouldImmediate) try {
|
|
1382
|
-
this.forceReveal(newLineCount$1);
|
|
1383
|
-
} catch {}
|
|
1384
|
-
else this.maybeScrollToBottom(newLineCount$1);
|
|
1717
|
+
const computed$2 = this.computedHeight(this.editorView);
|
|
1718
|
+
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
1719
|
+
this.forceReveal(newLineCount$1);
|
|
1385
1720
|
}
|
|
1386
1721
|
return;
|
|
1387
1722
|
}
|
|
@@ -1423,21 +1758,19 @@ var EditorManager = class {
|
|
|
1423
1758
|
if (!this.editorView) return;
|
|
1424
1759
|
const model = this.editorView.getModel();
|
|
1425
1760
|
if (!model) return;
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
}
|
|
1440
|
-
} catch {}
|
|
1761
|
+
const maxChars = minimalEditMaxChars;
|
|
1762
|
+
const ratio = minimalEditMaxChangeRatio;
|
|
1763
|
+
const maxLen = Math.max(prev.length, next.length);
|
|
1764
|
+
const changeRatio = maxLen > 0 ? Math.abs(next.length - prev.length) / maxLen : 0;
|
|
1765
|
+
if (prev.length + next.length > maxChars || changeRatio > ratio) {
|
|
1766
|
+
const prevLineCount = model.getLineCount();
|
|
1767
|
+
model.setValue(next);
|
|
1768
|
+
this.lastKnownCode = next;
|
|
1769
|
+
const newLineCount = model.getLineCount();
|
|
1770
|
+
this.cachedLineCount = newLineCount;
|
|
1771
|
+
if (newLineCount !== prevLineCount) this.maybeScrollToBottom(newLineCount);
|
|
1772
|
+
return;
|
|
1773
|
+
}
|
|
1441
1774
|
const res = computeMinimalEdit(prev, next);
|
|
1442
1775
|
if (!res) return;
|
|
1443
1776
|
const { start, endPrevIncl, replaceText } = res;
|
|
@@ -1483,10 +1816,8 @@ var EditorManager = class {
|
|
|
1483
1816
|
this.cachedLineCount = newLineCount;
|
|
1484
1817
|
const shouldImmediate = this.shouldPerformImmediateReveal();
|
|
1485
1818
|
if (shouldImmediate) this.suppressScrollWatcher(this.scrollWatcherSuppressionMs);
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
1489
|
-
} catch {}
|
|
1819
|
+
const computed$2 = this.computedHeight(this.editorView);
|
|
1820
|
+
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
1490
1821
|
if (shouldImmediate) try {
|
|
1491
1822
|
this.forceReveal(newLineCount);
|
|
1492
1823
|
} catch {}
|
|
@@ -2060,9 +2391,7 @@ function useMonaco(monacoOptions = {}) {
|
|
|
2060
2391
|
flush: "post",
|
|
2061
2392
|
immediate: true
|
|
2062
2393
|
});
|
|
2063
|
-
|
|
2064
|
-
if (editorView) lastKnownCode = editorView.getValue();
|
|
2065
|
-
} catch {}
|
|
2394
|
+
if (editorView) lastKnownCode = editorView.getValue();
|
|
2066
2395
|
return editorView;
|
|
2067
2396
|
}
|
|
2068
2397
|
function computedHeight(editorView$1) {
|