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.
- package/dist/index.cjs +488 -175
- package/dist/index.js +488 -175
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -203,38 +203,22 @@ const monaco = _monaco;
|
|
|
203
203
|
//#endregion
|
|
204
204
|
//#region src/utils/logger.ts
|
|
205
205
|
let seq = 0;
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const proc = nodeProcess;
|
|
211
|
-
if (proc && proc.env && proc.env.NODE_ENV !== "production") return true;
|
|
212
|
-
} catch {}
|
|
213
|
-
} catch {}
|
|
206
|
+
const DEBUG = (() => {
|
|
207
|
+
if (typeof window !== "undefined" && window.__STREAM_MONACO_DEBUG__ !== void 0) return Boolean(window.__STREAM_MONACO_DEBUG__);
|
|
208
|
+
const proc = nodeProcess;
|
|
209
|
+
if (proc && proc.env && proc.env.NODE_ENV === "production") return false;
|
|
214
210
|
return false;
|
|
215
211
|
})();
|
|
216
212
|
function log(tag, ...args) {
|
|
217
|
-
if (!
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
console.warn(`${id} [${tag}] @${ts}ms`, ...args);
|
|
223
|
-
} catch (err) {
|
|
224
|
-
try {
|
|
225
|
-
console.warn("[logger] fallback", tag, ...args, err);
|
|
226
|
-
} catch {}
|
|
227
|
-
}
|
|
213
|
+
if (!DEBUG) return;
|
|
214
|
+
seq += 1;
|
|
215
|
+
const id = `#${seq}`;
|
|
216
|
+
const ts = typeof performance !== "undefined" && performance.now ? performance.now().toFixed(1) : Date.now();
|
|
217
|
+
console.warn(`${id} [${tag}] @${ts}ms`, ...args);
|
|
228
218
|
}
|
|
229
219
|
function error(tag, ...args) {
|
|
230
|
-
if (!
|
|
231
|
-
|
|
232
|
-
console.error(`[${tag}]`, ...args);
|
|
233
|
-
} catch (err) {
|
|
234
|
-
try {
|
|
235
|
-
console.error("[logger] fallback error", tag, ...args, err);
|
|
236
|
-
} catch {}
|
|
237
|
-
}
|
|
220
|
+
if (!DEBUG) return;
|
|
221
|
+
console.error(`[${tag}]`, ...args);
|
|
238
222
|
}
|
|
239
223
|
|
|
240
224
|
//#endregion
|
|
@@ -354,41 +338,45 @@ function createRafScheduler(timeSource) {
|
|
|
354
338
|
//#region src/utils/scroll.ts
|
|
355
339
|
function createScrollWatcherForEditor(ed, opts) {
|
|
356
340
|
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
341
|
const initial = ((_ed$getScrollTop = ed.getScrollTop) === null || _ed$getScrollTop === void 0 ? void 0 : _ed$getScrollTop.call(ed)) ?? 0;
|
|
368
342
|
opts.setLast(initial);
|
|
369
|
-
|
|
343
|
+
log("scrollWatcher", "initial scrollTop=", initial);
|
|
370
344
|
let suppressedExternally = false;
|
|
371
345
|
const THRESHOLD_PX = 6;
|
|
346
|
+
let domNode = null;
|
|
347
|
+
let interactionListener = null;
|
|
372
348
|
const listener = (e) => {
|
|
373
349
|
var _ed$getScrollTop2;
|
|
374
350
|
if (suppressedExternally) {
|
|
375
|
-
|
|
351
|
+
log("scrollWatcher", "suppressedExternally, ignoring event");
|
|
376
352
|
return;
|
|
377
353
|
}
|
|
378
354
|
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
355
|
const delta = currentTop - opts.getLast();
|
|
380
356
|
opts.setLast(currentTop);
|
|
381
357
|
if (Math.abs(delta) < THRESHOLD_PX) {
|
|
382
|
-
|
|
358
|
+
log("scrollWatcher", "small delta ignored", delta);
|
|
359
|
+
try {
|
|
360
|
+
const scrollHeight = typeof ed.getScrollHeight === "function" ? ed.getScrollHeight() : void 0;
|
|
361
|
+
const li = typeof ed.getLayoutInfo === "function" ? ed.getLayoutInfo() : void 0;
|
|
362
|
+
const viewportH = (li === null || li === void 0 ? void 0 : li.height) ?? void 0;
|
|
363
|
+
if (typeof scrollHeight === "number" && typeof viewportH === "number") {
|
|
364
|
+
const distance = scrollHeight - (currentTop + viewportH);
|
|
365
|
+
if (distance <= Math.max(THRESHOLD_PX, 0)) {
|
|
366
|
+
log("scrollWatcher", "small delta but at bottom, maybe resume", { distance });
|
|
367
|
+
opts.onMaybeResume();
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
} catch {}
|
|
383
371
|
return;
|
|
384
372
|
}
|
|
385
|
-
|
|
373
|
+
log("scrollWatcher", "delta=", delta, "currentTop=", currentTop);
|
|
386
374
|
if (delta < 0) {
|
|
387
|
-
|
|
375
|
+
log("scrollWatcher", "pause detected delta=", delta);
|
|
388
376
|
opts.onPause();
|
|
389
377
|
return;
|
|
390
378
|
}
|
|
391
|
-
|
|
379
|
+
log("scrollWatcher", "maybe resume delta=", delta);
|
|
392
380
|
opts.onMaybeResume();
|
|
393
381
|
};
|
|
394
382
|
const disp = ((_ed$onDidScrollChange = ed.onDidScrollChange) === null || _ed$onDidScrollChange === void 0 ? void 0 : _ed$onDidScrollChange.call(ed, listener)) ?? null;
|
|
@@ -398,11 +386,56 @@ function createScrollWatcherForEditor(ed, opts) {
|
|
|
398
386
|
if (disp && typeof disp.dispose === "function") disp.dispose();
|
|
399
387
|
else if (typeof disp === "function") disp();
|
|
400
388
|
} catch {}
|
|
401
|
-
|
|
389
|
+
log("scrollWatcher", "dispose");
|
|
402
390
|
},
|
|
403
391
|
setSuppressed(v) {
|
|
404
|
-
|
|
405
|
-
if (
|
|
392
|
+
const newVal = !!v;
|
|
393
|
+
if (newVal === suppressedExternally) return;
|
|
394
|
+
suppressedExternally = newVal;
|
|
395
|
+
log("scrollWatcher", "setSuppressed =>", suppressedExternally);
|
|
396
|
+
try {
|
|
397
|
+
if (!domNode && typeof ed.getDomNode === "function") domNode = ed.getDomNode();
|
|
398
|
+
if (suppressedExternally && domNode) {
|
|
399
|
+
if (!interactionListener) {
|
|
400
|
+
interactionListener = () => {
|
|
401
|
+
try {
|
|
402
|
+
var _ed$getScrollTop3;
|
|
403
|
+
log("scrollWatcher", "user interaction detected while suppressed, cancelling suppression");
|
|
404
|
+
opts.onPause();
|
|
405
|
+
suppressedExternally = false;
|
|
406
|
+
const cur = ((_ed$getScrollTop3 = ed.getScrollTop) === null || _ed$getScrollTop3 === void 0 ? void 0 : _ed$getScrollTop3.call(ed)) ?? 0;
|
|
407
|
+
opts.setLast(cur);
|
|
408
|
+
try {
|
|
409
|
+
const scrollHeight = typeof ed.getScrollHeight === "function" ? ed.getScrollHeight() : void 0;
|
|
410
|
+
const li = typeof ed.getLayoutInfo === "function" ? ed.getLayoutInfo() : void 0;
|
|
411
|
+
const viewportH = (li === null || li === void 0 ? void 0 : li.height) ?? void 0;
|
|
412
|
+
if (typeof scrollHeight === "number" && typeof viewportH === "number") {
|
|
413
|
+
const distance = scrollHeight - (cur + viewportH);
|
|
414
|
+
if (distance <= Math.max(THRESHOLD_PX, 0)) {
|
|
415
|
+
log("scrollWatcher", "interaction moved to bottom, maybe resume", { distance });
|
|
416
|
+
opts.onMaybeResume();
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
} catch {}
|
|
420
|
+
if (domNode && interactionListener) {
|
|
421
|
+
domNode.removeEventListener("wheel", interactionListener, { passive: true });
|
|
422
|
+
domNode.removeEventListener("pointerdown", interactionListener);
|
|
423
|
+
domNode.removeEventListener("touchstart", interactionListener);
|
|
424
|
+
}
|
|
425
|
+
interactionListener = null;
|
|
426
|
+
} catch {}
|
|
427
|
+
};
|
|
428
|
+
domNode.addEventListener("wheel", interactionListener, { passive: true });
|
|
429
|
+
domNode.addEventListener("pointerdown", interactionListener);
|
|
430
|
+
domNode.addEventListener("touchstart", interactionListener);
|
|
431
|
+
}
|
|
432
|
+
} else if (domNode && interactionListener) {
|
|
433
|
+
domNode.removeEventListener("wheel", interactionListener, { passive: true });
|
|
434
|
+
domNode.removeEventListener("pointerdown", interactionListener);
|
|
435
|
+
domNode.removeEventListener("touchstart", interactionListener);
|
|
436
|
+
interactionListener = null;
|
|
437
|
+
}
|
|
438
|
+
} catch {}
|
|
406
439
|
}
|
|
407
440
|
};
|
|
408
441
|
return api;
|
|
@@ -450,11 +483,14 @@ var DiffEditorManager = class {
|
|
|
450
483
|
};
|
|
451
484
|
}
|
|
452
485
|
lastRevealLineDiff = null;
|
|
486
|
+
revealTicketDiff = 0;
|
|
453
487
|
revealDebounceIdDiff = null;
|
|
454
488
|
revealDebounceMs = defaultRevealDebounceMs;
|
|
455
489
|
revealIdleTimerIdDiff = null;
|
|
456
490
|
revealStrategyOption;
|
|
457
491
|
revealBatchOnIdleMsOption;
|
|
492
|
+
scrollWatcherSuppressionMs = 500;
|
|
493
|
+
diffScrollWatcherSuppressionTimer = null;
|
|
458
494
|
appendBufferDiff = [];
|
|
459
495
|
appendBufferDiffScheduled = false;
|
|
460
496
|
rafScheduler = createRafScheduler();
|
|
@@ -484,6 +520,26 @@ var DiffEditorManager = class {
|
|
|
484
520
|
const desired = Math.max(fromLines, scrollH);
|
|
485
521
|
return Math.min(desired, this.maxHeightValue);
|
|
486
522
|
}
|
|
523
|
+
isOverflowAutoDiff() {
|
|
524
|
+
return !!this.lastContainer && this.lastContainer.style.overflow === "auto";
|
|
525
|
+
}
|
|
526
|
+
shouldPerformImmediateRevealDiff() {
|
|
527
|
+
return this.autoScrollOnUpdate && this.shouldAutoScrollDiff && this.hasVerticalScrollbarModified() && this.isOverflowAutoDiff();
|
|
528
|
+
}
|
|
529
|
+
suppressScrollWatcherDiff(ms) {
|
|
530
|
+
if (!this.diffScrollWatcher || typeof this.diffScrollWatcher.setSuppressed !== "function") return;
|
|
531
|
+
if (this.diffScrollWatcherSuppressionTimer != null) {
|
|
532
|
+
clearTimeout(this.diffScrollWatcherSuppressionTimer);
|
|
533
|
+
this.diffScrollWatcherSuppressionTimer = null;
|
|
534
|
+
}
|
|
535
|
+
this.diffScrollWatcher.setSuppressed(true);
|
|
536
|
+
this.diffScrollWatcherSuppressionTimer = setTimeout(() => {
|
|
537
|
+
try {
|
|
538
|
+
this.diffScrollWatcher.setSuppressed(false);
|
|
539
|
+
} catch {}
|
|
540
|
+
this.diffScrollWatcherSuppressionTimer = null;
|
|
541
|
+
}, ms);
|
|
542
|
+
}
|
|
487
543
|
hasVerticalScrollbarModified() {
|
|
488
544
|
if (!this.diffEditorView) return false;
|
|
489
545
|
if (this._hasScrollBar) return true;
|
|
@@ -503,21 +559,56 @@ var DiffEditorManager = class {
|
|
|
503
559
|
}
|
|
504
560
|
maybeScrollDiffToBottom(targetLine, prevLineOverride) {
|
|
505
561
|
this.rafScheduler.schedule("maybe-scroll-diff", () => {
|
|
562
|
+
log("diff", "maybeScrollDiffToBottom called", {
|
|
563
|
+
targetLine,
|
|
564
|
+
prevLineOverride,
|
|
565
|
+
diffAutoScroll: this.diffAutoScroll,
|
|
566
|
+
autoScrollOnUpdate: this.autoScrollOnUpdate,
|
|
567
|
+
shouldAutoScrollDiff: this.shouldAutoScrollDiff
|
|
568
|
+
});
|
|
506
569
|
if (!this.diffEditorView) return;
|
|
507
|
-
|
|
570
|
+
const hasV = this.hasVerticalScrollbarModified();
|
|
571
|
+
log("diff", "hasVerticalScrollbarModified ->", hasV);
|
|
572
|
+
if (!(this.diffAutoScroll && this.autoScrollOnUpdate && this.shouldAutoScrollDiff && hasV)) return;
|
|
508
573
|
const me = this.diffEditorView.getModifiedEditor();
|
|
509
574
|
const model = me.getModel();
|
|
510
575
|
const currentLine = (model === null || model === void 0 ? void 0 : model.getLineCount()) ?? 1;
|
|
511
576
|
const line = targetLine ?? currentLine;
|
|
512
577
|
const prevLine = typeof prevLineOverride === "number" ? prevLineOverride : this.lastKnownModifiedLineCount ?? -1;
|
|
578
|
+
log("diff", "scroll metrics", {
|
|
579
|
+
prevLine,
|
|
580
|
+
currentLine,
|
|
581
|
+
line,
|
|
582
|
+
lastRevealLineDiff: this.lastRevealLineDiff
|
|
583
|
+
});
|
|
513
584
|
if (prevLine !== -1 && prevLine === currentLine && line === currentLine) return;
|
|
514
585
|
if (this.lastRevealLineDiff !== null && this.lastRevealLineDiff === line) return;
|
|
515
586
|
const batchMs = this.revealBatchOnIdleMsOption ?? this.options.revealBatchOnIdleMs ?? defaultRevealBatchOnIdleMs;
|
|
587
|
+
log("diff", "reveal timing", {
|
|
588
|
+
batchMs,
|
|
589
|
+
revealDebounceMs: this.revealDebounceMs,
|
|
590
|
+
revealDebounceMsOption: this.revealDebounceMsOption
|
|
591
|
+
});
|
|
516
592
|
if (typeof batchMs === "number" && batchMs > 0) {
|
|
593
|
+
if (hasV) {
|
|
594
|
+
const ticket$1 = ++this.revealTicketDiff;
|
|
595
|
+
log("diff", "has scrollbar -> immediate ticketed reveal", {
|
|
596
|
+
ticket: ticket$1,
|
|
597
|
+
line
|
|
598
|
+
});
|
|
599
|
+
this.performRevealDiffTicketed(line, ticket$1);
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
517
602
|
if (this.revealIdleTimerIdDiff != null) clearTimeout(this.revealIdleTimerIdDiff);
|
|
603
|
+
const ticket = ++this.revealTicketDiff;
|
|
604
|
+
log("diff", "scheduling idle reveal", {
|
|
605
|
+
ticket,
|
|
606
|
+
batchMs,
|
|
607
|
+
line
|
|
608
|
+
});
|
|
518
609
|
this.revealIdleTimerIdDiff = setTimeout(() => {
|
|
519
610
|
this.revealIdleTimerIdDiff = null;
|
|
520
|
-
this.
|
|
611
|
+
this.performRevealDiffTicketed(line, ticket);
|
|
521
612
|
}, batchMs);
|
|
522
613
|
return;
|
|
523
614
|
}
|
|
@@ -528,14 +619,32 @@ var DiffEditorManager = class {
|
|
|
528
619
|
const ms = typeof this.revealDebounceMs === "number" && this.revealDebounceMs > 0 ? this.revealDebounceMs : typeof this.revealDebounceMsOption === "number" && this.revealDebounceMsOption > 0 ? this.revealDebounceMsOption : this.revealDebounceMs;
|
|
529
620
|
this.revealDebounceIdDiff = setTimeout(() => {
|
|
530
621
|
this.revealDebounceIdDiff = null;
|
|
531
|
-
this.
|
|
622
|
+
const ticket = ++this.revealTicketDiff;
|
|
623
|
+
log("diff", "debounced reveal firing", {
|
|
624
|
+
ticket,
|
|
625
|
+
line
|
|
626
|
+
});
|
|
627
|
+
this.performRevealDiffTicketed(line, ticket);
|
|
532
628
|
}, ms);
|
|
533
629
|
this.lastKnownModifiedLineCount = currentLine;
|
|
534
630
|
});
|
|
535
631
|
}
|
|
536
|
-
|
|
632
|
+
performRevealDiffTicketed(line, ticket) {
|
|
537
633
|
this.rafScheduler.schedule("revealDiff", () => {
|
|
538
634
|
var _editor;
|
|
635
|
+
if (this.diffScrollWatcher) {
|
|
636
|
+
log("diff", "performRevealDiffTicketed - suppressing watcher", {
|
|
637
|
+
ticket,
|
|
638
|
+
line,
|
|
639
|
+
ms: this.scrollWatcherSuppressionMs
|
|
640
|
+
});
|
|
641
|
+
this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs);
|
|
642
|
+
}
|
|
643
|
+
if (ticket !== this.revealTicketDiff) return;
|
|
644
|
+
log("diff", "performRevealDiffTicketed - performing reveal", {
|
|
645
|
+
ticket,
|
|
646
|
+
line
|
|
647
|
+
});
|
|
539
648
|
const strategy = this.revealStrategyOption ?? this.options.revealStrategy ?? "centerIfOutside";
|
|
540
649
|
const ScrollType = monaco_shim_exports.ScrollType || ((_editor = monaco_shim_exports.editor) === null || _editor === void 0 ? void 0 : _editor.ScrollType);
|
|
541
650
|
const smooth = ScrollType && typeof ScrollType.Smooth !== "undefined" ? ScrollType.Smooth : void 0;
|
|
@@ -553,13 +662,71 @@ var DiffEditorManager = class {
|
|
|
553
662
|
} catch {}
|
|
554
663
|
}
|
|
555
664
|
this.lastRevealLineDiff = line;
|
|
665
|
+
log("diff", "performRevealDiffTicketed - revealed", {
|
|
666
|
+
line,
|
|
667
|
+
lastRevealLineDiff: this.lastRevealLineDiff
|
|
668
|
+
});
|
|
669
|
+
try {
|
|
670
|
+
var _this$diffEditorView, _this$diffEditorView$, _this$diffEditorView$2;
|
|
671
|
+
this.shouldAutoScrollDiff = true;
|
|
672
|
+
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;
|
|
673
|
+
} catch {}
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
performImmediateRevealDiff(line, ticket) {
|
|
677
|
+
var _editor2;
|
|
678
|
+
if (!this.diffEditorView) return;
|
|
679
|
+
if (ticket !== this.revealTicketDiff) return;
|
|
680
|
+
const ScrollType = monaco_shim_exports.ScrollType || ((_editor2 = monaco_shim_exports.editor) === null || _editor2 === void 0 ? void 0 : _editor2.ScrollType);
|
|
681
|
+
const immediate = ScrollType && typeof ScrollType.Immediate !== "undefined" ? ScrollType.Immediate : void 0;
|
|
682
|
+
const me = this.diffEditorView.getModifiedEditor();
|
|
683
|
+
if (typeof immediate !== "undefined") me.revealLine(line, immediate);
|
|
684
|
+
else me.revealLine(line);
|
|
685
|
+
this.measureViewportDiff();
|
|
686
|
+
log("diff", "performImmediateRevealDiff", {
|
|
687
|
+
line,
|
|
688
|
+
ticket
|
|
689
|
+
});
|
|
690
|
+
try {
|
|
691
|
+
var _this$diffEditorView2, _this$diffEditorView3, _this$diffEditorView4;
|
|
692
|
+
this.shouldAutoScrollDiff = true;
|
|
693
|
+
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;
|
|
694
|
+
} catch {}
|
|
695
|
+
}
|
|
696
|
+
scheduleImmediateRevealAfterLayoutDiff(line) {
|
|
697
|
+
const ticket = ++this.revealTicketDiff;
|
|
698
|
+
this.rafScheduler.schedule("immediate-reveal-diff", async () => {
|
|
699
|
+
const target = this.diffEditorView && this.diffHeightManager ? Math.min(this.computedHeight(), this.maxHeightValue) : -1;
|
|
700
|
+
if (target !== -1 && this.diffHeightManager) {
|
|
701
|
+
if (this.lastContainer) this.lastContainer.style.height = `${target}px`;
|
|
702
|
+
await this.waitForHeightAppliedDiff(target);
|
|
703
|
+
}
|
|
704
|
+
this.performImmediateRevealDiff(line, ticket);
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
waitForHeightAppliedDiff(target, timeoutMs = 500) {
|
|
708
|
+
return new Promise((resolve) => {
|
|
709
|
+
const start = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
|
|
710
|
+
const check = () => {
|
|
711
|
+
const applied = this.lastContainer ? Number.parseFloat((this.lastContainer.style.height || "").replace("px", "")) || 0 : -1;
|
|
712
|
+
if (applied >= target - 1) {
|
|
713
|
+
resolve();
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
if ((typeof performance !== "undefined" && performance.now ? performance.now() : Date.now()) - start > timeoutMs) {
|
|
717
|
+
resolve();
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
requestAnimationFrame(check);
|
|
721
|
+
};
|
|
722
|
+
check();
|
|
556
723
|
});
|
|
557
724
|
}
|
|
558
725
|
async createDiffEditor(container, originalCode, modifiedCode, language, currentTheme) {
|
|
559
726
|
var _me$getScrollHeight2, _me$getOption, _oEditor$onDidContent, _mEditor$onDidContent;
|
|
560
727
|
this.cleanup();
|
|
561
728
|
this.lastContainer = container;
|
|
562
|
-
container.style.overflow = "
|
|
729
|
+
container.style.overflow = "hidden";
|
|
563
730
|
container.style.maxHeight = this.maxHeightCSS;
|
|
564
731
|
const lang = processedLanguage(language) || language;
|
|
565
732
|
this.originalModel = monaco_shim_exports.editor.createModel(originalCode, lang);
|
|
@@ -608,13 +775,23 @@ var DiffEditorManager = class {
|
|
|
608
775
|
}
|
|
609
776
|
});
|
|
610
777
|
}
|
|
611
|
-
|
|
778
|
+
log("diff", "createDiffEditor", {
|
|
779
|
+
autoScrollInitial: this.autoScrollInitial,
|
|
780
|
+
diffAutoScroll: this.diffAutoScroll
|
|
781
|
+
});
|
|
782
|
+
const MIN_VISIBLE_HEIGHT = Math.min(120, this.maxHeightValue);
|
|
783
|
+
container.style.minHeight = `${MIN_VISIBLE_HEIGHT}px`;
|
|
612
784
|
if (this.diffHeightManager) {
|
|
613
785
|
this.diffHeightManager.dispose();
|
|
614
786
|
this.diffHeightManager = null;
|
|
615
787
|
}
|
|
616
788
|
this.diffHeightManager = createHeightManager(container, () => this.computedHeight());
|
|
617
789
|
this.diffHeightManager.update();
|
|
790
|
+
const initialComputed = this.computedHeight();
|
|
791
|
+
if (initialComputed >= this.maxHeightValue - 1) {
|
|
792
|
+
container.style.height = `${this.maxHeightValue}px`;
|
|
793
|
+
container.style.overflow = "auto";
|
|
794
|
+
}
|
|
618
795
|
const me = this.diffEditorView.getModifiedEditor();
|
|
619
796
|
this.cachedScrollHeightDiff = ((_me$getScrollHeight2 = me.getScrollHeight) === null || _me$getScrollHeight2 === void 0 ? void 0 : _me$getScrollHeight2.call(me)) ?? null;
|
|
620
797
|
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 +801,54 @@ var DiffEditorManager = class {
|
|
|
624
801
|
(_oEditor$onDidContent = oEditor.onDidContentSizeChange) === null || _oEditor$onDidContent === void 0 || _oEditor$onDidContent.call(oEditor, () => {
|
|
625
802
|
this._hasScrollBar = false;
|
|
626
803
|
this.rafScheduler.schedule("content-size-change-diff", () => {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
804
|
+
var _oEditor$getScrollHei, _oEditor$getOption, _this$diffHeightManag, _this$diffHeightManag2;
|
|
805
|
+
this.cachedScrollHeightDiff = ((_oEditor$getScrollHei = oEditor.getScrollHeight) === null || _oEditor$getScrollHei === void 0 ? void 0 : _oEditor$getScrollHei.call(oEditor)) ?? this.cachedScrollHeightDiff;
|
|
806
|
+
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;
|
|
807
|
+
this.cachedComputedHeightDiff = this.computedHeight();
|
|
808
|
+
if ((_this$diffHeightManag = this.diffHeightManager) === null || _this$diffHeightManag === void 0 ? void 0 : _this$diffHeightManag.isSuppressed()) return;
|
|
809
|
+
(_this$diffHeightManag2 = this.diffHeightManager) === null || _this$diffHeightManag2 === void 0 || _this$diffHeightManag2.update();
|
|
810
|
+
const computed$2 = this.computedHeight();
|
|
811
|
+
if (this.lastContainer) {
|
|
812
|
+
const prevOverflow = this.lastContainer.style.overflow;
|
|
813
|
+
const newOverflow = computed$2 >= this.maxHeightValue - 1 ? "auto" : "hidden";
|
|
814
|
+
if (prevOverflow !== newOverflow) {
|
|
815
|
+
this.lastContainer.style.overflow = newOverflow;
|
|
816
|
+
if (newOverflow === "auto" && this.shouldAutoScrollDiff) {
|
|
817
|
+
var _this$modifiedModel;
|
|
818
|
+
this.maybeScrollDiffToBottom((_this$modifiedModel = this.modifiedModel) === null || _this$modifiedModel === void 0 ? void 0 : _this$modifiedModel.getLineCount());
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
}
|
|
635
822
|
});
|
|
636
823
|
});
|
|
637
824
|
(_mEditor$onDidContent = mEditor.onDidContentSizeChange) === null || _mEditor$onDidContent === void 0 || _mEditor$onDidContent.call(mEditor, () => {
|
|
638
825
|
this._hasScrollBar = false;
|
|
639
826
|
this.rafScheduler.schedule("content-size-change-diff", () => {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
827
|
+
var _mEditor$getScrollHei, _mEditor$getOption, _this$diffHeightManag3, _this$diffHeightManag4;
|
|
828
|
+
this.cachedScrollHeightDiff = ((_mEditor$getScrollHei = mEditor.getScrollHeight) === null || _mEditor$getScrollHei === void 0 ? void 0 : _mEditor$getScrollHei.call(mEditor)) ?? this.cachedScrollHeightDiff;
|
|
829
|
+
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;
|
|
830
|
+
this.cachedComputedHeightDiff = this.computedHeight();
|
|
831
|
+
if ((_this$diffHeightManag3 = this.diffHeightManager) === null || _this$diffHeightManag3 === void 0 ? void 0 : _this$diffHeightManag3.isSuppressed()) return;
|
|
832
|
+
(_this$diffHeightManag4 = this.diffHeightManager) === null || _this$diffHeightManag4 === void 0 || _this$diffHeightManag4.update();
|
|
833
|
+
const computed$2 = this.computedHeight();
|
|
834
|
+
if (this.lastContainer) {
|
|
835
|
+
const prevOverflow = this.lastContainer.style.overflow;
|
|
836
|
+
const newOverflow = computed$2 >= this.maxHeightValue - 1 ? "auto" : "hidden";
|
|
837
|
+
if (prevOverflow !== newOverflow) {
|
|
838
|
+
this.lastContainer.style.overflow = newOverflow;
|
|
839
|
+
if (newOverflow === "auto" && this.shouldAutoScrollDiff) {
|
|
840
|
+
var _this$modifiedModel2;
|
|
841
|
+
this.maybeScrollDiffToBottom((_this$modifiedModel2 = this.modifiedModel) === null || _this$modifiedModel2 === void 0 ? void 0 : _this$modifiedModel2.getLineCount());
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
648
845
|
});
|
|
649
846
|
});
|
|
650
847
|
mEditor.onDidChangeModelContent(() => {
|
|
651
848
|
this.lastKnownModifiedDirty = true;
|
|
652
849
|
this.rafScheduler.schedule("sync-last-known-modified", () => this.syncLastKnownModified());
|
|
653
850
|
});
|
|
851
|
+
this.maybeScrollDiffToBottom(this.modifiedModel.getLineCount(), this.lastKnownModifiedLineCount ?? void 0);
|
|
654
852
|
return this.diffEditorView;
|
|
655
853
|
}
|
|
656
854
|
updateDiff(originalCode, modifiedCode, codeLanguage) {
|
|
@@ -710,11 +908,37 @@ var DiffEditorManager = class {
|
|
|
710
908
|
}
|
|
711
909
|
const prev = this.lastKnownModifiedCode ?? this.modifiedModel.getValue();
|
|
712
910
|
if (prev === newCode) return;
|
|
911
|
+
const prevLine = this.modifiedModel.getLineCount();
|
|
713
912
|
if (newCode.startsWith(prev) && prev.length < newCode.length) {
|
|
714
|
-
const prevLine = this.modifiedModel.getLineCount();
|
|
715
913
|
this.appendToModel(this.modifiedModel, newCode.slice(prev.length));
|
|
716
914
|
this.maybeScrollDiffToBottom(this.modifiedModel.getLineCount(), prevLine);
|
|
717
|
-
} else
|
|
915
|
+
} else {
|
|
916
|
+
this.applyMinimalEditToModel(this.modifiedModel, prev, newCode);
|
|
917
|
+
const newLine = this.modifiedModel.getLineCount();
|
|
918
|
+
if (newLine !== prevLine) {
|
|
919
|
+
const shouldImmediate = this.shouldPerformImmediateRevealDiff();
|
|
920
|
+
if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
|
|
921
|
+
const computed$2 = this.computedHeight();
|
|
922
|
+
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) {
|
|
923
|
+
this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
924
|
+
this.lastContainer.style.overflow = "auto";
|
|
925
|
+
}
|
|
926
|
+
if (shouldImmediate) this.scheduleImmediateRevealAfterLayoutDiff(newLine);
|
|
927
|
+
else this.maybeScrollDiffToBottom(newLine, prevLine);
|
|
928
|
+
if (this.autoScrollOnUpdate && this.shouldAutoScrollDiff) try {
|
|
929
|
+
var _editor3, _me2$getModel, _me2$getScrollTop;
|
|
930
|
+
const ScrollType = monaco_shim_exports.ScrollType || ((_editor3 = monaco_shim_exports.editor) === null || _editor3 === void 0 ? void 0 : _editor3.ScrollType);
|
|
931
|
+
const immediate = ScrollType && typeof ScrollType.Immediate !== "undefined" ? ScrollType.Immediate : void 0;
|
|
932
|
+
const me2 = this.diffEditorView.getModifiedEditor();
|
|
933
|
+
const targetLine = ((_me2$getModel = me2.getModel()) === null || _me2$getModel === void 0 ? void 0 : _me2$getModel.getLineCount()) ?? newLine;
|
|
934
|
+
if (typeof immediate !== "undefined") me2.revealLine(targetLine, immediate);
|
|
935
|
+
else me2.revealLine(targetLine);
|
|
936
|
+
this.lastRevealLineDiff = targetLine;
|
|
937
|
+
this.shouldAutoScrollDiff = true;
|
|
938
|
+
this.lastScrollTopDiff = ((_me2$getScrollTop = me2.getScrollTop) === null || _me2$getScrollTop === void 0 ? void 0 : _me2$getScrollTop.call(me2)) ?? this.lastScrollTopDiff;
|
|
939
|
+
} catch {}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
718
942
|
this.lastKnownModifiedCode = newCode;
|
|
719
943
|
}
|
|
720
944
|
appendOriginal(appendText, codeLanguage) {
|
|
@@ -724,9 +948,7 @@ var DiffEditorManager = class {
|
|
|
724
948
|
if (lang && this.originalModel.getLanguageId() !== lang) monaco_shim_exports.editor.setModelLanguage(this.originalModel, lang);
|
|
725
949
|
}
|
|
726
950
|
this.appendToModel(this.originalModel, appendText);
|
|
727
|
-
|
|
728
|
-
this.lastKnownOriginalCode = this.originalModel.getValue();
|
|
729
|
-
} catch {}
|
|
951
|
+
this.lastKnownOriginalCode = this.originalModel.getValue();
|
|
730
952
|
}
|
|
731
953
|
appendModified(appendText, codeLanguage) {
|
|
732
954
|
if (!this.diffEditorView || !this.modifiedModel || !appendText) return;
|
|
@@ -795,6 +1017,15 @@ var DiffEditorManager = class {
|
|
|
795
1017
|
clearTimeout(this.revealDebounceIdDiff);
|
|
796
1018
|
this.revealDebounceIdDiff = null;
|
|
797
1019
|
}
|
|
1020
|
+
if (this.revealIdleTimerIdDiff != null) {
|
|
1021
|
+
clearTimeout(this.revealIdleTimerIdDiff);
|
|
1022
|
+
this.revealIdleTimerIdDiff = null;
|
|
1023
|
+
}
|
|
1024
|
+
if (this.diffScrollWatcherSuppressionTimer != null) {
|
|
1025
|
+
clearTimeout(this.diffScrollWatcherSuppressionTimer);
|
|
1026
|
+
this.diffScrollWatcherSuppressionTimer = null;
|
|
1027
|
+
}
|
|
1028
|
+
this.revealTicketDiff = 0;
|
|
798
1029
|
this.lastRevealLineDiff = null;
|
|
799
1030
|
}
|
|
800
1031
|
safeClean() {
|
|
@@ -815,6 +1046,15 @@ var DiffEditorManager = class {
|
|
|
815
1046
|
clearTimeout(this.revealDebounceIdDiff);
|
|
816
1047
|
this.revealDebounceIdDiff = null;
|
|
817
1048
|
}
|
|
1049
|
+
if (this.revealIdleTimerIdDiff != null) {
|
|
1050
|
+
clearTimeout(this.revealIdleTimerIdDiff);
|
|
1051
|
+
this.revealIdleTimerIdDiff = null;
|
|
1052
|
+
}
|
|
1053
|
+
if (this.diffScrollWatcherSuppressionTimer != null) {
|
|
1054
|
+
clearTimeout(this.diffScrollWatcherSuppressionTimer);
|
|
1055
|
+
this.diffScrollWatcherSuppressionTimer = null;
|
|
1056
|
+
}
|
|
1057
|
+
this.revealTicketDiff = 0;
|
|
818
1058
|
this.lastRevealLineDiff = null;
|
|
819
1059
|
this.rafScheduler.cancel("content-size-change-diff");
|
|
820
1060
|
this.rafScheduler.cancel("sync-last-known-modified");
|
|
@@ -828,7 +1068,7 @@ var DiffEditorManager = class {
|
|
|
828
1068
|
this.lastKnownModifiedCode = model.getValue();
|
|
829
1069
|
this.lastKnownModifiedLineCount = model.getLineCount();
|
|
830
1070
|
}
|
|
831
|
-
}
|
|
1071
|
+
} finally {
|
|
832
1072
|
this.lastKnownModifiedDirty = false;
|
|
833
1073
|
}
|
|
834
1074
|
}
|
|
@@ -872,10 +1112,20 @@ var DiffEditorManager = class {
|
|
|
872
1112
|
else this.applyMinimalEditToModel(m, prevM, modified);
|
|
873
1113
|
this.lastKnownModifiedCode = modified;
|
|
874
1114
|
const newMLineCount = m.getLineCount();
|
|
875
|
-
if (newMLineCount !== prevMLineCount)
|
|
1115
|
+
if (newMLineCount !== prevMLineCount) {
|
|
1116
|
+
const shouldImmediate = this.shouldPerformImmediateRevealDiff();
|
|
1117
|
+
if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
|
|
1118
|
+
const computed$2 = this.computedHeight();
|
|
1119
|
+
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) {
|
|
1120
|
+
this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
1121
|
+
this.lastContainer.style.overflow = "auto";
|
|
1122
|
+
}
|
|
1123
|
+
if (shouldImmediate) this.scheduleImmediateRevealAfterLayoutDiff(newMLineCount);
|
|
1124
|
+
else this.maybeScrollDiffToBottom(newMLineCount, prevMLineCount);
|
|
1125
|
+
}
|
|
876
1126
|
}
|
|
877
1127
|
}
|
|
878
|
-
flushAppendBufferDiff() {
|
|
1128
|
+
async flushAppendBufferDiff() {
|
|
879
1129
|
if (!this.diffEditorView) return;
|
|
880
1130
|
if (this.appendBufferDiff.length === 0) return;
|
|
881
1131
|
this.appendBufferDiffScheduled = false;
|
|
@@ -885,39 +1135,128 @@ var DiffEditorManager = class {
|
|
|
885
1135
|
this.appendBufferDiff.length = 0;
|
|
886
1136
|
return;
|
|
887
1137
|
}
|
|
888
|
-
|
|
1138
|
+
let parts = this.appendBufferDiff.splice(0);
|
|
1139
|
+
const prevLineInit = model.getLineCount();
|
|
1140
|
+
const totalText = parts.join("");
|
|
1141
|
+
const totalChars = totalText.length;
|
|
1142
|
+
if (parts.length === 1 && totalChars > 5e3) {
|
|
1143
|
+
const lines = totalText.split(/\r?\n/);
|
|
1144
|
+
const chunkSize = 200;
|
|
1145
|
+
const chunks = [];
|
|
1146
|
+
for (let i = 0; i < lines.length; i += chunkSize) chunks.push(`${lines.slice(i, i + chunkSize).join("\n")}\n`);
|
|
1147
|
+
if (chunks.length > 1) parts = chunks;
|
|
1148
|
+
}
|
|
1149
|
+
const applyChunked = parts.length > 1 && (totalChars > 2e3 || model.getLineCount && model.getLineCount() + 0 - prevLineInit > 50);
|
|
1150
|
+
log("diff", "flushAppendBufferDiff start", {
|
|
1151
|
+
partsCount: parts.length,
|
|
1152
|
+
totalChars,
|
|
1153
|
+
applyChunked
|
|
1154
|
+
});
|
|
1155
|
+
let prevLine = prevLineInit;
|
|
1156
|
+
const watcherApi = this.diffScrollWatcher;
|
|
1157
|
+
let suppressedByFlush = false;
|
|
1158
|
+
if (watcherApi && typeof watcherApi.setSuppressed === "function") try {
|
|
1159
|
+
if (this.diffScrollWatcherSuppressionTimer != null) {
|
|
1160
|
+
clearTimeout(this.diffScrollWatcherSuppressionTimer);
|
|
1161
|
+
this.diffScrollWatcherSuppressionTimer = null;
|
|
1162
|
+
}
|
|
1163
|
+
watcherApi.setSuppressed(true);
|
|
1164
|
+
suppressedByFlush = true;
|
|
1165
|
+
} catch {}
|
|
1166
|
+
if (applyChunked) {
|
|
1167
|
+
log("diff", "flushAppendBufferDiff applying chunked", { partsLen: parts.length });
|
|
1168
|
+
let idx = 0;
|
|
1169
|
+
for (const part of parts) {
|
|
1170
|
+
if (!part) continue;
|
|
1171
|
+
idx += 1;
|
|
1172
|
+
log("diff", "flushAppendBufferDiff chunk", {
|
|
1173
|
+
idx,
|
|
1174
|
+
partLen: part.length,
|
|
1175
|
+
prevLine
|
|
1176
|
+
});
|
|
1177
|
+
const lastColumn$1 = model.getLineMaxColumn(prevLine);
|
|
1178
|
+
const range$1 = new monaco_shim_exports.Range(prevLine, lastColumn$1, prevLine, lastColumn$1);
|
|
1179
|
+
model.applyEdits([{
|
|
1180
|
+
range: range$1,
|
|
1181
|
+
text: part,
|
|
1182
|
+
forceMoveMarkers: true
|
|
1183
|
+
}]);
|
|
1184
|
+
this.lastKnownModifiedCode = model.getValue();
|
|
1185
|
+
const newLine$1 = model.getLineCount();
|
|
1186
|
+
this.lastKnownModifiedLineCount = newLine$1;
|
|
1187
|
+
await new Promise((resolve) => typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame(resolve) : setTimeout(resolve, 0));
|
|
1188
|
+
const shouldImmediate$1 = this.shouldPerformImmediateRevealDiff();
|
|
1189
|
+
log("diff", "flushAppendBufferDiff chunk metrics", {
|
|
1190
|
+
idx,
|
|
1191
|
+
newLine: newLine$1,
|
|
1192
|
+
prevLine,
|
|
1193
|
+
shouldImmediate: shouldImmediate$1
|
|
1194
|
+
});
|
|
1195
|
+
if (shouldImmediate$1) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
|
|
1196
|
+
const computed$3 = this.computedHeight();
|
|
1197
|
+
if (computed$3 >= this.maxHeightValue - 1 && this.lastContainer) {
|
|
1198
|
+
this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
1199
|
+
this.lastContainer.style.overflow = "auto";
|
|
1200
|
+
}
|
|
1201
|
+
if (shouldImmediate$1) this.scheduleImmediateRevealAfterLayoutDiff(newLine$1);
|
|
1202
|
+
else this.maybeScrollDiffToBottom(newLine$1, prevLine);
|
|
1203
|
+
prevLine = newLine$1;
|
|
1204
|
+
log("diff", "flushAppendBufferDiff chunk applied", {
|
|
1205
|
+
idx,
|
|
1206
|
+
newLine: newLine$1
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
if (suppressedByFlush) watcherApi.setSuppressed(false);
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1212
|
+
const text = totalText;
|
|
889
1213
|
this.appendBufferDiff.length = 0;
|
|
1214
|
+
prevLine = model.getLineCount();
|
|
1215
|
+
const lastColumn = model.getLineMaxColumn(prevLine);
|
|
1216
|
+
const range = new monaco_shim_exports.Range(prevLine, lastColumn, prevLine, lastColumn);
|
|
1217
|
+
model.applyEdits([{
|
|
1218
|
+
range,
|
|
1219
|
+
text,
|
|
1220
|
+
forceMoveMarkers: true
|
|
1221
|
+
}]);
|
|
1222
|
+
this.lastKnownModifiedCode = model.getValue();
|
|
1223
|
+
const newLine = model.getLineCount();
|
|
1224
|
+
this.lastKnownModifiedLineCount = newLine;
|
|
1225
|
+
const shouldImmediate = this.shouldPerformImmediateRevealDiff();
|
|
1226
|
+
if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
|
|
1227
|
+
const computed$2 = this.computedHeight();
|
|
1228
|
+
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
1229
|
+
if (shouldImmediate) this.scheduleImmediateRevealAfterLayoutDiff(newLine);
|
|
1230
|
+
else this.maybeScrollDiffToBottom(newLine, prevLine);
|
|
1231
|
+
if (this.autoScrollOnUpdate && this.shouldAutoScrollDiff) try {
|
|
1232
|
+
var _editor4, _me2$getModel2, _me2$getScrollTop2;
|
|
1233
|
+
const ScrollType = monaco_shim_exports.ScrollType || ((_editor4 = monaco_shim_exports.editor) === null || _editor4 === void 0 ? void 0 : _editor4.ScrollType);
|
|
1234
|
+
const immediate = ScrollType && typeof ScrollType.Immediate !== "undefined" ? ScrollType.Immediate : void 0;
|
|
1235
|
+
const me2 = this.diffEditorView.getModifiedEditor();
|
|
1236
|
+
const targetLine = ((_me2$getModel2 = me2.getModel()) === null || _me2$getModel2 === void 0 ? void 0 : _me2$getModel2.getLineCount()) ?? newLine;
|
|
1237
|
+
if (typeof immediate !== "undefined") me2.revealLine(targetLine, immediate);
|
|
1238
|
+
else me2.revealLine(targetLine);
|
|
1239
|
+
this.lastRevealLineDiff = targetLine;
|
|
1240
|
+
this.shouldAutoScrollDiff = true;
|
|
1241
|
+
this.lastScrollTopDiff = ((_me2$getScrollTop2 = me2.getScrollTop) === null || _me2$getScrollTop2 === void 0 ? void 0 : _me2$getScrollTop2.call(me2)) ?? this.lastScrollTopDiff;
|
|
1242
|
+
} catch {}
|
|
1243
|
+
if (suppressedByFlush) watcherApi.setSuppressed(false);
|
|
890
1244
|
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;
|
|
1245
|
+
var _this$diffEditorView5, _this$diffEditorView6, _this$diffEditorView7;
|
|
1246
|
+
this.shouldAutoScrollDiff = true;
|
|
1247
|
+
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
1248
|
} catch {}
|
|
906
1249
|
}
|
|
907
1250
|
applyMinimalEditToModel(model, prev, next) {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
} catch {}
|
|
918
|
-
return;
|
|
919
|
-
}
|
|
920
|
-
} catch {}
|
|
1251
|
+
const maxChars = minimalEditMaxChars;
|
|
1252
|
+
const ratio = minimalEditMaxChangeRatio;
|
|
1253
|
+
const maxLen = Math.max(prev.length, next.length);
|
|
1254
|
+
const changeRatio = maxLen > 0 ? Math.abs(next.length - prev.length) / maxLen : 0;
|
|
1255
|
+
if (prev.length + next.length > maxChars || changeRatio > ratio) {
|
|
1256
|
+
model.setValue(next);
|
|
1257
|
+
if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
921
1260
|
const res = computeMinimalEdit(prev, next);
|
|
922
1261
|
if (!res) return;
|
|
923
1262
|
const { start, endPrevIncl, replaceText } = res;
|
|
@@ -929,9 +1268,7 @@ var DiffEditorManager = class {
|
|
|
929
1268
|
text: replaceText,
|
|
930
1269
|
forceMoveMarkers: true
|
|
931
1270
|
}]);
|
|
932
|
-
|
|
933
|
-
if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
|
|
934
|
-
} catch {}
|
|
1271
|
+
if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
|
|
935
1272
|
}
|
|
936
1273
|
appendToModel(model, appendText) {
|
|
937
1274
|
if (!appendText) return;
|
|
@@ -943,9 +1280,7 @@ var DiffEditorManager = class {
|
|
|
943
1280
|
text: appendText,
|
|
944
1281
|
forceMoveMarkers: true
|
|
945
1282
|
}]);
|
|
946
|
-
|
|
947
|
-
if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
|
|
948
|
-
} catch {}
|
|
1283
|
+
if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
|
|
949
1284
|
}
|
|
950
1285
|
};
|
|
951
1286
|
|
|
@@ -1044,14 +1379,12 @@ var EditorManager = class {
|
|
|
1044
1379
|
const lineCount = this.cachedLineCount ?? ((_editorView$getModel = editorView.getModel()) === null || _editorView$getModel === void 0 ? void 0 : _editorView$getModel.getLineCount()) ?? 1;
|
|
1045
1380
|
const lineHeight = editorView.getOption(monaco_shim_exports.editor.EditorOption.lineHeight);
|
|
1046
1381
|
const height = Math.min(lineCount * lineHeight + padding, this.maxHeightValue);
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
});
|
|
1054
|
-
} catch {}
|
|
1382
|
+
log("EditorManager.computedHeight", {
|
|
1383
|
+
lineCount,
|
|
1384
|
+
lineHeight,
|
|
1385
|
+
computed: height,
|
|
1386
|
+
maxHeightValue: this.maxHeightValue
|
|
1387
|
+
});
|
|
1055
1388
|
return height;
|
|
1056
1389
|
}
|
|
1057
1390
|
maybeScrollToBottom(targetLine) {
|
|
@@ -1102,7 +1435,6 @@ var EditorManager = class {
|
|
|
1102
1435
|
return;
|
|
1103
1436
|
}
|
|
1104
1437
|
this.dlog("performReveal executing, ticket=", ticket, "line=", line);
|
|
1105
|
-
this.lastPerformedRevealTicket = ticket;
|
|
1106
1438
|
const strategy = this.revealStrategyOption ?? this.options.revealStrategy ?? "centerIfOutside";
|
|
1107
1439
|
this.dlog("performReveal strategy=", strategy);
|
|
1108
1440
|
const ScrollType = monaco_shim_exports.ScrollType || ((_editor = monaco_shim_exports.editor) === null || _editor === void 0 ? void 0 : _editor.ScrollType);
|
|
@@ -1130,7 +1462,6 @@ var EditorManager = class {
|
|
|
1130
1462
|
this.dlog("performImmediateReveal skipped, stale ticket", ticket, "current", this.revealTicket);
|
|
1131
1463
|
return;
|
|
1132
1464
|
}
|
|
1133
|
-
this.lastPerformedRevealTicket = ticket;
|
|
1134
1465
|
const ScrollType = monaco_shim_exports.ScrollType || ((_editor2 = monaco_shim_exports.editor) === null || _editor2 === void 0 ? void 0 : _editor2.ScrollType);
|
|
1135
1466
|
const immediate = ScrollType && typeof ScrollType.Immediate !== "undefined" ? ScrollType.Immediate : void 0;
|
|
1136
1467
|
if (typeof immediate !== "undefined") this.editorView.revealLine(line, immediate);
|
|
@@ -1280,35 +1611,28 @@ var EditorManager = class {
|
|
|
1280
1611
|
}
|
|
1281
1612
|
syncLastKnownCode() {
|
|
1282
1613
|
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;
|
|
1614
|
+
const model = this.editorView.getModel();
|
|
1615
|
+
if (model) {
|
|
1616
|
+
this.lastKnownCode = model.getValue();
|
|
1617
|
+
this.cachedLineCount = model.getLineCount() ?? this.cachedLineCount;
|
|
1291
1618
|
}
|
|
1619
|
+
this.lastKnownCodeDirty = false;
|
|
1292
1620
|
}
|
|
1293
1621
|
suppressScrollWatcher(ms) {
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1622
|
+
if (!this.scrollWatcher || typeof this.scrollWatcher.setSuppressed !== "function") return;
|
|
1623
|
+
this.dlog("suppressScrollWatcher", ms);
|
|
1624
|
+
if (this.scrollWatcherSuppressionTimer != null) {
|
|
1625
|
+
clearTimeout(this.scrollWatcherSuppressionTimer);
|
|
1626
|
+
this.scrollWatcherSuppressionTimer = null;
|
|
1627
|
+
}
|
|
1628
|
+
this.scrollWatcher.setSuppressed(true);
|
|
1629
|
+
this.scrollWatcherSuppressionTimer = setTimeout(() => {
|
|
1630
|
+
if (this.scrollWatcher && typeof this.scrollWatcher.setSuppressed === "function") {
|
|
1631
|
+
this.scrollWatcher.setSuppressed(false);
|
|
1632
|
+
this.dlog("suppressScrollWatcher cleared");
|
|
1300
1633
|
}
|
|
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 {}
|
|
1634
|
+
this.scrollWatcherSuppressionTimer = null;
|
|
1635
|
+
}, ms);
|
|
1312
1636
|
}
|
|
1313
1637
|
scheduleImmediateRevealAfterLayout(line) {
|
|
1314
1638
|
const ticket = ++this.revealTicket;
|
|
@@ -1374,14 +1698,9 @@ var EditorManager = class {
|
|
|
1374
1698
|
if (newLineCount$1 !== prevLineCount$1) {
|
|
1375
1699
|
const shouldImmediate = this.shouldPerformImmediateReveal();
|
|
1376
1700
|
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);
|
|
1701
|
+
const computed$2 = this.computedHeight(this.editorView);
|
|
1702
|
+
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
1703
|
+
this.forceReveal(newLineCount$1);
|
|
1385
1704
|
}
|
|
1386
1705
|
return;
|
|
1387
1706
|
}
|
|
@@ -1423,21 +1742,19 @@ var EditorManager = class {
|
|
|
1423
1742
|
if (!this.editorView) return;
|
|
1424
1743
|
const model = this.editorView.getModel();
|
|
1425
1744
|
if (!model) return;
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
}
|
|
1440
|
-
} catch {}
|
|
1745
|
+
const maxChars = minimalEditMaxChars;
|
|
1746
|
+
const ratio = minimalEditMaxChangeRatio;
|
|
1747
|
+
const maxLen = Math.max(prev.length, next.length);
|
|
1748
|
+
const changeRatio = maxLen > 0 ? Math.abs(next.length - prev.length) / maxLen : 0;
|
|
1749
|
+
if (prev.length + next.length > maxChars || changeRatio > ratio) {
|
|
1750
|
+
const prevLineCount = model.getLineCount();
|
|
1751
|
+
model.setValue(next);
|
|
1752
|
+
this.lastKnownCode = next;
|
|
1753
|
+
const newLineCount = model.getLineCount();
|
|
1754
|
+
this.cachedLineCount = newLineCount;
|
|
1755
|
+
if (newLineCount !== prevLineCount) this.maybeScrollToBottom(newLineCount);
|
|
1756
|
+
return;
|
|
1757
|
+
}
|
|
1441
1758
|
const res = computeMinimalEdit(prev, next);
|
|
1442
1759
|
if (!res) return;
|
|
1443
1760
|
const { start, endPrevIncl, replaceText } = res;
|
|
@@ -1483,10 +1800,8 @@ var EditorManager = class {
|
|
|
1483
1800
|
this.cachedLineCount = newLineCount;
|
|
1484
1801
|
const shouldImmediate = this.shouldPerformImmediateReveal();
|
|
1485
1802
|
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 {}
|
|
1803
|
+
const computed$2 = this.computedHeight(this.editorView);
|
|
1804
|
+
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
1490
1805
|
if (shouldImmediate) try {
|
|
1491
1806
|
this.forceReveal(newLineCount);
|
|
1492
1807
|
} catch {}
|
|
@@ -2060,9 +2375,7 @@ function useMonaco(monacoOptions = {}) {
|
|
|
2060
2375
|
flush: "post",
|
|
2061
2376
|
immediate: true
|
|
2062
2377
|
});
|
|
2063
|
-
|
|
2064
|
-
if (editorView) lastKnownCode = editorView.getValue();
|
|
2065
|
-
} catch {}
|
|
2378
|
+
if (editorView) lastKnownCode = editorView.getValue();
|
|
2066
2379
|
return editorView;
|
|
2067
2380
|
}
|
|
2068
2381
|
function computedHeight(editorView$1) {
|