stream-monaco 0.0.21 → 0.0.36
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/README.md +16 -2
- package/README.zh-CN.md +16 -2
- package/dist/{index.base-Bt_RWV_F.d.ts → index.base-BB334pQY.d.ts} +1 -0
- package/dist/{index.base-DMJ2aLjO.d.cts → index.base-uTGkC8S0.d.cts} +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.legacy.cjs +1 -1
- package/dist/index.legacy.d.cts +1 -1
- package/dist/index.legacy.d.ts +1 -1
- package/dist/index.legacy.js +1 -1
- package/dist/{preloadMonacoWorkers.shared-DutEnjwJ.js → preloadMonacoWorkers.shared-B0KjUDJf.js} +1770 -1161
- package/dist/{preloadMonacoWorkers.shared-DAHEwJHs.cjs → preloadMonacoWorkers.shared-kHKw8Ju_.cjs} +1770 -1161
- package/package.json +41 -31
package/dist/{preloadMonacoWorkers.shared-DutEnjwJ.js → preloadMonacoWorkers.shared-B0KjUDJf.js}
RENAMED
|
@@ -141,10 +141,15 @@ function processedLanguage(language) {
|
|
|
141
141
|
//#endregion
|
|
142
142
|
//#region src/monaco-shim.ts
|
|
143
143
|
var monaco_shim_exports = {};
|
|
144
|
-
__export(monaco_shim_exports, {
|
|
144
|
+
__export(monaco_shim_exports, {
|
|
145
|
+
ScrollType: () => ScrollType,
|
|
146
|
+
default: () => monaco
|
|
147
|
+
});
|
|
145
148
|
import * as import_monaco_editor_esm_vs_editor_editor_api from "monaco-editor/esm/vs/editor/editor.api";
|
|
146
149
|
__reExport(monaco_shim_exports, import_monaco_editor_esm_vs_editor_editor_api);
|
|
150
|
+
var _editor;
|
|
147
151
|
const monaco = _monaco;
|
|
152
|
+
const ScrollType = Reflect.get(_monaco, "ScrollType") ?? ((_editor = _monaco.editor) === null || _editor === void 0 ? void 0 : _editor.ScrollType);
|
|
148
153
|
|
|
149
154
|
//#endregion
|
|
150
155
|
//#region src/constant.ts
|
|
@@ -467,6 +472,809 @@ function createScrollWatcherForEditor(ed, opts) {
|
|
|
467
472
|
return api;
|
|
468
473
|
}
|
|
469
474
|
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region src/core/diffAppearance.ts
|
|
477
|
+
function parseCssColorRgb(color) {
|
|
478
|
+
const normalized = color.trim().toLowerCase();
|
|
479
|
+
const rgbMatch = normalized.match(/^rgba?\(\s*([+\-.\d]+)\s*,\s*([+\-.\d]+)\s*,\s*([+\-.\d]+)/);
|
|
480
|
+
if (rgbMatch) return [
|
|
481
|
+
Number.parseFloat(rgbMatch[1]),
|
|
482
|
+
Number.parseFloat(rgbMatch[2]),
|
|
483
|
+
Number.parseFloat(rgbMatch[3])
|
|
484
|
+
];
|
|
485
|
+
const hexMatch = normalized.match(/^#([\da-f]{3,8})$/i);
|
|
486
|
+
if (!hexMatch) return null;
|
|
487
|
+
const hex = hexMatch[1];
|
|
488
|
+
if (hex.length === 3 || hex.length === 4) return [
|
|
489
|
+
Number.parseInt(`${hex[0]}${hex[0]}`, 16),
|
|
490
|
+
Number.parseInt(`${hex[1]}${hex[1]}`, 16),
|
|
491
|
+
Number.parseInt(`${hex[2]}${hex[2]}`, 16)
|
|
492
|
+
];
|
|
493
|
+
if (hex.length === 6 || hex.length === 8) return [
|
|
494
|
+
Number.parseInt(hex.slice(0, 2), 16),
|
|
495
|
+
Number.parseInt(hex.slice(2, 4), 16),
|
|
496
|
+
Number.parseInt(hex.slice(4, 6), 16)
|
|
497
|
+
];
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
function resolveCssColorLuminance(color) {
|
|
501
|
+
const rgb = parseCssColorRgb(color);
|
|
502
|
+
if (!rgb) return null;
|
|
503
|
+
const channel = (value) => {
|
|
504
|
+
const normalized = Math.max(0, Math.min(255, value)) / 255;
|
|
505
|
+
return normalized <= .03928 ? normalized / 12.92 : ((normalized + .055) / 1.055) ** 2.4;
|
|
506
|
+
};
|
|
507
|
+
const [r, g, b] = rgb;
|
|
508
|
+
return .2126 * channel(r) + .7152 * channel(g) + .0722 * channel(b);
|
|
509
|
+
}
|
|
510
|
+
function looksLikeDarkThemeName(themeName) {
|
|
511
|
+
if (!themeName) return false;
|
|
512
|
+
const normalized = themeName.toLowerCase();
|
|
513
|
+
return [
|
|
514
|
+
"dark",
|
|
515
|
+
"night",
|
|
516
|
+
"moon",
|
|
517
|
+
"black",
|
|
518
|
+
"dracula",
|
|
519
|
+
"mocha",
|
|
520
|
+
"frappe",
|
|
521
|
+
"macchiato",
|
|
522
|
+
"palenight",
|
|
523
|
+
"ocean",
|
|
524
|
+
"poimandres",
|
|
525
|
+
"monokai",
|
|
526
|
+
"laserwave",
|
|
527
|
+
"tokyo",
|
|
528
|
+
"slack-dark",
|
|
529
|
+
"rose-pine",
|
|
530
|
+
"github-dark",
|
|
531
|
+
"material-theme",
|
|
532
|
+
"one-dark",
|
|
533
|
+
"catppuccin-mocha",
|
|
534
|
+
"catppuccin-frappe",
|
|
535
|
+
"catppuccin-macchiato"
|
|
536
|
+
].some((token) => normalized.includes(token)) && !normalized.includes("light") && !normalized.includes("latte") && !normalized.includes("dawn") && !normalized.includes("lotus");
|
|
537
|
+
}
|
|
538
|
+
function looksLikeLightThemeName(themeName) {
|
|
539
|
+
if (!themeName) return false;
|
|
540
|
+
const normalized = themeName.toLowerCase();
|
|
541
|
+
return [
|
|
542
|
+
"light",
|
|
543
|
+
"day",
|
|
544
|
+
"dawn",
|
|
545
|
+
"latte",
|
|
546
|
+
"solarized-light",
|
|
547
|
+
"github-light",
|
|
548
|
+
"rose-pine-dawn",
|
|
549
|
+
"catppuccin-latte",
|
|
550
|
+
"one-light",
|
|
551
|
+
"vitesse-light",
|
|
552
|
+
"snazzy-light",
|
|
553
|
+
"material-lighter",
|
|
554
|
+
"material-theme-lighter",
|
|
555
|
+
"lotus"
|
|
556
|
+
].some((token) => normalized.includes(token));
|
|
557
|
+
}
|
|
558
|
+
function resolveDiffAppearance({ container, diffAppearance, diffEditorView, themeName }) {
|
|
559
|
+
var _diffEditorView$getMo, _diffEditorView$getMo2, _diffEditorView$getOr, _diffEditorView$getOr2;
|
|
560
|
+
if (diffAppearance === "light") return "light";
|
|
561
|
+
if (diffAppearance === "dark") return "dark";
|
|
562
|
+
if (looksLikeDarkThemeName(themeName)) return "dark";
|
|
563
|
+
if (looksLikeLightThemeName(themeName)) return "light";
|
|
564
|
+
const appearanceProbeNodes = [
|
|
565
|
+
diffEditorView === null || diffEditorView === void 0 || (_diffEditorView$getMo2 = (_diffEditorView$getMo = diffEditorView.getModifiedEditor()).getContainerDomNode) === null || _diffEditorView$getMo2 === void 0 ? void 0 : _diffEditorView$getMo2.call(_diffEditorView$getMo),
|
|
566
|
+
diffEditorView === null || diffEditorView === void 0 || (_diffEditorView$getOr2 = (_diffEditorView$getOr = diffEditorView.getOriginalEditor()).getContainerDomNode) === null || _diffEditorView$getOr2 === void 0 ? void 0 : _diffEditorView$getOr2.call(_diffEditorView$getOr),
|
|
567
|
+
container
|
|
568
|
+
];
|
|
569
|
+
for (const node of appearanceProbeNodes) {
|
|
570
|
+
if (!(node instanceof HTMLElement)) continue;
|
|
571
|
+
const style = globalThis.getComputedStyle(node);
|
|
572
|
+
const editorSurface = node.querySelector(".monaco-editor .monaco-editor-background, .monaco-editor .margin, .monaco-editor .lines-content");
|
|
573
|
+
const candidates = [
|
|
574
|
+
style.getPropertyValue("--stream-monaco-editor-bg"),
|
|
575
|
+
style.getPropertyValue("--vscode-editor-background"),
|
|
576
|
+
editorSurface ? globalThis.getComputedStyle(editorSurface).backgroundColor : "",
|
|
577
|
+
style.backgroundColor
|
|
578
|
+
];
|
|
579
|
+
for (const color of candidates) {
|
|
580
|
+
const luminance = resolveCssColorLuminance(color);
|
|
581
|
+
if (luminance == null) continue;
|
|
582
|
+
return luminance <= .42 ? "dark" : "light";
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
return looksLikeDarkThemeName(themeName) ? "dark" : "light";
|
|
586
|
+
}
|
|
587
|
+
function syncDiffRootThemeVariables(container, diffEditorView, appearance) {
|
|
588
|
+
var _diffEditorView$getMo3, _diffEditorView$getMo4, _diffEditorView$getOr3, _diffEditorView$getOr4;
|
|
589
|
+
const probeNodes = [
|
|
590
|
+
diffEditorView === null || diffEditorView === void 0 || (_diffEditorView$getMo4 = (_diffEditorView$getMo3 = diffEditorView.getModifiedEditor()).getContainerDomNode) === null || _diffEditorView$getMo4 === void 0 ? void 0 : _diffEditorView$getMo4.call(_diffEditorView$getMo3),
|
|
591
|
+
diffEditorView === null || diffEditorView === void 0 || (_diffEditorView$getOr4 = (_diffEditorView$getOr3 = diffEditorView.getOriginalEditor()).getContainerDomNode) === null || _diffEditorView$getOr4 === void 0 ? void 0 : _diffEditorView$getOr4.call(_diffEditorView$getOr3),
|
|
592
|
+
container
|
|
593
|
+
];
|
|
594
|
+
const containerStyle = globalThis.getComputedStyle(container);
|
|
595
|
+
const fixedBackgroundColor = containerStyle.getPropertyValue("--stream-monaco-fixed-editor-bg").trim() || null;
|
|
596
|
+
let backgroundColor = null;
|
|
597
|
+
let foregroundColor = null;
|
|
598
|
+
for (const node of probeNodes) {
|
|
599
|
+
if (!(node instanceof HTMLElement)) continue;
|
|
600
|
+
const backgroundProbe = node.querySelector(".monaco-editor-background, .margin, .lines-content") ?? node;
|
|
601
|
+
const foregroundProbe = node.querySelector(".view-lines, .monaco-editor, .view-overlays") ?? node;
|
|
602
|
+
const nextBackground = globalThis.getComputedStyle(backgroundProbe).backgroundColor;
|
|
603
|
+
if (!backgroundColor && resolveCssColorLuminance(nextBackground) != null) backgroundColor = nextBackground;
|
|
604
|
+
const nextForeground = globalThis.getComputedStyle(foregroundProbe).color;
|
|
605
|
+
if (!foregroundColor && resolveCssColorLuminance(nextForeground) != null) foregroundColor = nextForeground;
|
|
606
|
+
if (backgroundColor && foregroundColor) break;
|
|
607
|
+
}
|
|
608
|
+
const resolvedBackgroundColor = fixedBackgroundColor || backgroundColor || (appearance === "dark" ? "rgb(10 10 11)" : "rgb(255 255 255)");
|
|
609
|
+
if (resolvedBackgroundColor) container.style.setProperty("--stream-monaco-editor-bg", resolvedBackgroundColor);
|
|
610
|
+
else container.style.removeProperty("--stream-monaco-editor-bg");
|
|
611
|
+
if (foregroundColor) container.style.setProperty("--stream-monaco-editor-fg", foregroundColor);
|
|
612
|
+
else container.style.removeProperty("--stream-monaco-editor-fg");
|
|
613
|
+
}
|
|
614
|
+
function resolveDiffUnchangedLineInfoRailMetrics(node) {
|
|
615
|
+
const editorRoot = node.closest(".monaco-editor");
|
|
616
|
+
if (!editorRoot) return {
|
|
617
|
+
leftInset: 0,
|
|
618
|
+
width: null
|
|
619
|
+
};
|
|
620
|
+
const editorRect = editorRoot.getBoundingClientRect();
|
|
621
|
+
const lineNumberNode = Array.from(editorRoot.querySelectorAll(".line-numbers")).find((candidate) => {
|
|
622
|
+
const rect = candidate.getBoundingClientRect();
|
|
623
|
+
return rect.width > 0 && rect.height > 0;
|
|
624
|
+
});
|
|
625
|
+
if (!lineNumberNode) return {
|
|
626
|
+
leftInset: 0,
|
|
627
|
+
width: null
|
|
628
|
+
};
|
|
629
|
+
const lineNumberRect = lineNumberNode.getBoundingClientRect();
|
|
630
|
+
return {
|
|
631
|
+
leftInset: Math.max(0, lineNumberRect.left - editorRect.left),
|
|
632
|
+
width: Math.max(0, lineNumberRect.width) || null
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
function applyDiffRootAppearanceClass({ appearanceClasses, container, currentSignature, diffAppearance, diffEditorView, isInlineMode, layoutModeClasses, lineStyle, lineStyleClasses, themeName, unchangedRegionStyle, unchangedRegionStyleClasses }) {
|
|
636
|
+
if (!container) return currentSignature;
|
|
637
|
+
const resolvedAppearance = resolveDiffAppearance({
|
|
638
|
+
container,
|
|
639
|
+
diffAppearance,
|
|
640
|
+
diffEditorView,
|
|
641
|
+
themeName
|
|
642
|
+
});
|
|
643
|
+
syncDiffRootThemeVariables(container, diffEditorView, resolvedAppearance);
|
|
644
|
+
const containerClassList = container.classList;
|
|
645
|
+
const activeLineStyleClass = `stream-monaco-diff-style-${lineStyle}`;
|
|
646
|
+
const activeUnchangedRegionStyleClass = `stream-monaco-diff-unchanged-style-${unchangedRegionStyle}`;
|
|
647
|
+
const activeLayoutModeClass = isInlineMode ? "stream-monaco-diff-inline" : "stream-monaco-diff-side-by-side";
|
|
648
|
+
const activeAppearanceClass = `stream-monaco-diff-appearance-${resolvedAppearance}`;
|
|
649
|
+
const nextSignature = [
|
|
650
|
+
activeLineStyleClass,
|
|
651
|
+
activeUnchangedRegionStyleClass,
|
|
652
|
+
activeLayoutModeClass,
|
|
653
|
+
activeAppearanceClass
|
|
654
|
+
].join("|");
|
|
655
|
+
if (currentSignature === nextSignature && containerClassList.contains("stream-monaco-diff-root")) return currentSignature;
|
|
656
|
+
containerClassList.add("stream-monaco-diff-root");
|
|
657
|
+
for (const className of lineStyleClasses) containerClassList.toggle(className, className === activeLineStyleClass);
|
|
658
|
+
for (const className of unchangedRegionStyleClasses) containerClassList.toggle(className, className === activeUnchangedRegionStyleClass);
|
|
659
|
+
for (const className of layoutModeClasses) containerClassList.toggle(className, className === activeLayoutModeClass);
|
|
660
|
+
for (const className of appearanceClasses) containerClassList.toggle(className, className === activeAppearanceClass);
|
|
661
|
+
return nextSignature;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
//#endregion
|
|
665
|
+
//#region src/core/diffHunk.ts
|
|
666
|
+
function createDiffHunkActionNode(side, onAction) {
|
|
667
|
+
const node = document.createElement("div");
|
|
668
|
+
node.className = "stream-monaco-diff-hunk-actions";
|
|
669
|
+
node.dataset.side = side;
|
|
670
|
+
const createButton = (action, label) => {
|
|
671
|
+
const button = document.createElement("button");
|
|
672
|
+
button.type = "button";
|
|
673
|
+
button.textContent = label;
|
|
674
|
+
button.dataset.action = action;
|
|
675
|
+
button.addEventListener("click", (event) => {
|
|
676
|
+
event.preventDefault();
|
|
677
|
+
event.stopPropagation();
|
|
678
|
+
onAction(side, action);
|
|
679
|
+
});
|
|
680
|
+
return button;
|
|
681
|
+
};
|
|
682
|
+
node.append(createButton("revert", "Revert"), createButton("stage", "Stage"));
|
|
683
|
+
return node;
|
|
684
|
+
}
|
|
685
|
+
function hasOriginalLines(change) {
|
|
686
|
+
return change.originalStartLineNumber > 0 && change.originalEndLineNumber >= change.originalStartLineNumber;
|
|
687
|
+
}
|
|
688
|
+
function hasModifiedLines(change) {
|
|
689
|
+
return change.modifiedStartLineNumber > 0 && change.modifiedEndLineNumber >= change.modifiedStartLineNumber;
|
|
690
|
+
}
|
|
691
|
+
function inferInlineDiffHunkHoverSide(change, hoverLine, targetElement) {
|
|
692
|
+
if (targetElement === null || targetElement === void 0 ? void 0 : targetElement.closest(".line-delete, .char-delete, .inline-deleted-text, .inline-deleted-margin-view-zone")) return "upper";
|
|
693
|
+
if (targetElement === null || targetElement === void 0 ? void 0 : targetElement.closest(".line-insert, .char-insert, .gutter-insert, .view-line")) return "lower";
|
|
694
|
+
if (!hasModifiedLines(change)) return "upper";
|
|
695
|
+
if (!hasOriginalLines(change)) return "lower";
|
|
696
|
+
const modifiedAnchor = Math.max(1, change.modifiedStartLineNumber || change.modifiedEndLineNumber || 1);
|
|
697
|
+
return hoverLine < modifiedAnchor ? "upper" : "lower";
|
|
698
|
+
}
|
|
699
|
+
function distanceToLineChange(side, change, line) {
|
|
700
|
+
const hasRange = side === "original" ? hasOriginalLines(change) : hasModifiedLines(change);
|
|
701
|
+
const start = side === "original" ? change.originalStartLineNumber : change.modifiedStartLineNumber;
|
|
702
|
+
const end = side === "original" ? change.originalEndLineNumber : change.modifiedEndLineNumber;
|
|
703
|
+
if (hasRange) {
|
|
704
|
+
if (line < start) return start - line;
|
|
705
|
+
if (line > end) return line - end;
|
|
706
|
+
return 0;
|
|
707
|
+
}
|
|
708
|
+
const fallbackAnchor = Math.max(1, start || end || 1);
|
|
709
|
+
return Math.abs(line - fallbackAnchor);
|
|
710
|
+
}
|
|
711
|
+
function findLineChangeByHoverLine(lineChanges, side, line) {
|
|
712
|
+
if (lineChanges.length === 0) return null;
|
|
713
|
+
let best = null;
|
|
714
|
+
let bestDistance = Number.POSITIVE_INFINITY;
|
|
715
|
+
for (const change of lineChanges) {
|
|
716
|
+
const distance = distanceToLineChange(side, change, line);
|
|
717
|
+
if (distance < bestDistance) {
|
|
718
|
+
bestDistance = distance;
|
|
719
|
+
best = change;
|
|
720
|
+
if (distance === 0) break;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
if (bestDistance > 2) return null;
|
|
724
|
+
return best;
|
|
725
|
+
}
|
|
726
|
+
function getFullLineRange(model, startLine, endLine) {
|
|
727
|
+
if (endLine < startLine) return null;
|
|
728
|
+
const lineCount = model.getLineCount();
|
|
729
|
+
if (lineCount < 1) return null;
|
|
730
|
+
const start = Math.max(1, Math.min(startLine, lineCount));
|
|
731
|
+
const end = Math.max(start, Math.min(endLine, lineCount));
|
|
732
|
+
if (end < lineCount) return new monaco_shim_exports.Range(start, 1, end + 1, 1);
|
|
733
|
+
return new monaco_shim_exports.Range(start, 1, end, model.getLineMaxColumn(end));
|
|
734
|
+
}
|
|
735
|
+
function getLinesText(model, startLine, endLine) {
|
|
736
|
+
const range = getFullLineRange(model, startLine, endLine);
|
|
737
|
+
if (!range) return "";
|
|
738
|
+
return model.getValueInRange(range);
|
|
739
|
+
}
|
|
740
|
+
function getInsertRangeBeforeLine(model, lineNumber) {
|
|
741
|
+
const lineCount = model.getLineCount();
|
|
742
|
+
if (lineNumber <= 1) return new monaco_shim_exports.Range(1, 1, 1, 1);
|
|
743
|
+
if (lineNumber <= lineCount) return new monaco_shim_exports.Range(lineNumber, 1, lineNumber, 1);
|
|
744
|
+
const lastLine = lineCount;
|
|
745
|
+
const lastColumn = model.getLineMaxColumn(lastLine);
|
|
746
|
+
return new monaco_shim_exports.Range(lastLine, lastColumn, lastLine, lastColumn);
|
|
747
|
+
}
|
|
748
|
+
function getInsertRangeAfterLine(model, lineNumber) {
|
|
749
|
+
const lineCount = model.getLineCount();
|
|
750
|
+
if (lineNumber < 1) return new monaco_shim_exports.Range(1, 1, 1, 1);
|
|
751
|
+
if (lineNumber < lineCount) return new monaco_shim_exports.Range(lineNumber + 1, 1, lineNumber + 1, 1);
|
|
752
|
+
const lastLine = lineCount;
|
|
753
|
+
const lastColumn = model.getLineMaxColumn(lastLine);
|
|
754
|
+
return new monaco_shim_exports.Range(lastLine, lastColumn, lastLine, lastColumn);
|
|
755
|
+
}
|
|
756
|
+
function applyDefaultDiffHunkAction(context) {
|
|
757
|
+
const { action, side, lineChange, originalModel, modifiedModel } = context;
|
|
758
|
+
const hasOriginal = hasOriginalLines(lineChange);
|
|
759
|
+
const hasModified = hasModifiedLines(lineChange);
|
|
760
|
+
if (action === "revert" && side === "upper") {
|
|
761
|
+
if (!hasOriginal) return;
|
|
762
|
+
const text = getLinesText(originalModel, lineChange.originalStartLineNumber, lineChange.originalEndLineNumber);
|
|
763
|
+
if (!text) return;
|
|
764
|
+
const range = hasModified ? getInsertRangeBeforeLine(modifiedModel, lineChange.modifiedStartLineNumber) : getInsertRangeAfterLine(modifiedModel, Math.max(0, lineChange.modifiedStartLineNumber || lineChange.modifiedEndLineNumber));
|
|
765
|
+
modifiedModel.applyEdits([{
|
|
766
|
+
range,
|
|
767
|
+
text,
|
|
768
|
+
forceMoveMarkers: true
|
|
769
|
+
}]);
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
if (action === "revert" && side === "lower") {
|
|
773
|
+
if (!hasModified) return;
|
|
774
|
+
const range = getFullLineRange(modifiedModel, lineChange.modifiedStartLineNumber, lineChange.modifiedEndLineNumber);
|
|
775
|
+
if (!range) return;
|
|
776
|
+
modifiedModel.applyEdits([{
|
|
777
|
+
range,
|
|
778
|
+
text: "",
|
|
779
|
+
forceMoveMarkers: true
|
|
780
|
+
}]);
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
if (action === "stage" && side === "upper") {
|
|
784
|
+
if (!hasOriginal) return;
|
|
785
|
+
const range = getFullLineRange(originalModel, lineChange.originalStartLineNumber, lineChange.originalEndLineNumber);
|
|
786
|
+
if (!range) return;
|
|
787
|
+
originalModel.applyEdits([{
|
|
788
|
+
range,
|
|
789
|
+
text: "",
|
|
790
|
+
forceMoveMarkers: true
|
|
791
|
+
}]);
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
if (action === "stage" && side === "lower") {
|
|
795
|
+
if (!hasModified) return;
|
|
796
|
+
const text = getLinesText(modifiedModel, lineChange.modifiedStartLineNumber, lineChange.modifiedEndLineNumber);
|
|
797
|
+
if (!text) return;
|
|
798
|
+
const anchor = hasOriginal ? lineChange.originalEndLineNumber : Math.max(0, lineChange.originalStartLineNumber);
|
|
799
|
+
const range = getInsertRangeAfterLine(originalModel, anchor);
|
|
800
|
+
originalModel.applyEdits([{
|
|
801
|
+
range,
|
|
802
|
+
text,
|
|
803
|
+
forceMoveMarkers: true
|
|
804
|
+
}]);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
function setDiffHunkNodeEnabled(node, enabled) {
|
|
808
|
+
if (!node) return;
|
|
809
|
+
const buttons = node.querySelectorAll("button");
|
|
810
|
+
buttons.forEach((button) => {
|
|
811
|
+
button.disabled = !enabled;
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
function positionDiffHunkNode(node, editor, anchorLine, extraOffsetY = 0) {
|
|
815
|
+
var _editor$getScrollTop;
|
|
816
|
+
const host = editor.getContainerDomNode();
|
|
817
|
+
const line = Math.max(1, anchorLine);
|
|
818
|
+
const rawTop = editor.getTopForLineNumber(line) - (((_editor$getScrollTop = editor.getScrollTop) === null || _editor$getScrollTop === void 0 ? void 0 : _editor$getScrollTop.call(editor)) ?? 0);
|
|
819
|
+
const lineHeight = editor.getOption(monaco_shim_exports.editor.EditorOption.lineHeight);
|
|
820
|
+
const nodeWidth = node.offsetWidth || 130;
|
|
821
|
+
const nodeHeight = node.offsetHeight || 30;
|
|
822
|
+
const left = host.offsetLeft + Math.max(6, host.clientWidth - nodeWidth - 10);
|
|
823
|
+
const hostTop = host.offsetTop;
|
|
824
|
+
const minTop = hostTop + 4;
|
|
825
|
+
const maxTop = hostTop + Math.max(4, host.clientHeight - nodeHeight - 4);
|
|
826
|
+
const top = Math.min(maxTop, Math.max(minTop, hostTop + rawTop + Math.round(lineHeight * .2) + extraOffsetY));
|
|
827
|
+
node.style.transform = `translate(${Math.round(left)}px, ${Math.round(top)}px)`;
|
|
828
|
+
node.style.display = "flex";
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
//#endregion
|
|
832
|
+
//#region src/core/diffUnchanged.ts
|
|
833
|
+
function formatDiffUnchangedCountLabel(text) {
|
|
834
|
+
const match = text.match(/\d+/);
|
|
835
|
+
const count = match ? Number.parseInt(match[0], 10) : NaN;
|
|
836
|
+
if (Number.isFinite(count)) return `${count} unmodified ${count === 1 ? "line" : "lines"}`;
|
|
837
|
+
return text.replace(/hidden/gi, "unmodified");
|
|
838
|
+
}
|
|
839
|
+
function countDiffLines(startLineNumber, endLineNumber) {
|
|
840
|
+
return endLineNumber >= startLineNumber ? endLineNumber - startLineNumber + 1 : 0;
|
|
841
|
+
}
|
|
842
|
+
function measureDiffUnchangedSurroundingLines(primaryNode) {
|
|
843
|
+
const editorRoot = primaryNode.closest(".editor.modified") ?? primaryNode.closest(".monaco-editor");
|
|
844
|
+
if (!editorRoot) return {
|
|
845
|
+
previousVisibleLine: null,
|
|
846
|
+
nextVisibleLine: null
|
|
847
|
+
};
|
|
848
|
+
const widgetRect = primaryNode.getBoundingClientRect();
|
|
849
|
+
let previousVisibleLine = null;
|
|
850
|
+
let nextVisibleLine = null;
|
|
851
|
+
const lineNumberNodes = editorRoot.querySelectorAll(".line-numbers");
|
|
852
|
+
lineNumberNodes.forEach((node) => {
|
|
853
|
+
var _node$textContent;
|
|
854
|
+
const lineNumber = Number.parseInt(((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.trim()) || "", 10);
|
|
855
|
+
if (!Number.isFinite(lineNumber)) return;
|
|
856
|
+
const top = node.getBoundingClientRect().top;
|
|
857
|
+
if (top < widgetRect.top - 1) previousVisibleLine = previousVisibleLine == null ? lineNumber : Math.max(previousVisibleLine, lineNumber);
|
|
858
|
+
else if (top > widgetRect.bottom + 1) nextVisibleLine = nextVisibleLine == null ? lineNumber : Math.min(nextVisibleLine, lineNumber);
|
|
859
|
+
});
|
|
860
|
+
return {
|
|
861
|
+
previousVisibleLine,
|
|
862
|
+
nextVisibleLine
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
function formatDiffMetadataRange(startLineNumber, lineCount) {
|
|
866
|
+
return `${startLineNumber},${Math.max(0, lineCount)}`;
|
|
867
|
+
}
|
|
868
|
+
function buildDiffHunkMetadataLabel(change, options) {
|
|
869
|
+
const { contextLineCount, modifiedTotalLines, originalTotalLines } = options;
|
|
870
|
+
const originalChangedCount = countDiffLines(change.originalStartLineNumber, change.originalEndLineNumber);
|
|
871
|
+
const modifiedChangedCount = countDiffLines(change.modifiedStartLineNumber, change.modifiedEndLineNumber);
|
|
872
|
+
const originalAnchor = Math.min(Math.max(change.originalStartLineNumber, 1), Math.max(1, originalTotalLines + 1));
|
|
873
|
+
const modifiedAnchor = Math.min(Math.max(change.modifiedStartLineNumber, 1), Math.max(1, modifiedTotalLines + 1));
|
|
874
|
+
const originalStart = Math.max(1, originalAnchor - contextLineCount);
|
|
875
|
+
const modifiedStart = Math.max(1, modifiedAnchor - contextLineCount);
|
|
876
|
+
const originalEnd = originalChangedCount > 0 ? Math.min(originalTotalLines, change.originalEndLineNumber + contextLineCount) : Math.min(originalTotalLines, originalAnchor + contextLineCount - 1);
|
|
877
|
+
const modifiedEnd = modifiedChangedCount > 0 ? Math.min(modifiedTotalLines, change.modifiedEndLineNumber + contextLineCount) : Math.min(modifiedTotalLines, modifiedAnchor + contextLineCount - 1);
|
|
878
|
+
const originalDisplayCount = originalEnd >= originalStart ? originalEnd - originalStart + 1 : 0;
|
|
879
|
+
const modifiedDisplayCount = modifiedEnd >= modifiedStart ? modifiedEnd - modifiedStart + 1 : 0;
|
|
880
|
+
return {
|
|
881
|
+
modifiedStart,
|
|
882
|
+
originalStart,
|
|
883
|
+
label: `@@ -${formatDiffMetadataRange(originalStart, originalDisplayCount)} +${formatDiffMetadataRange(modifiedStart, modifiedDisplayCount)} @@`
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
function resolveDiffMetadataLabel(options) {
|
|
887
|
+
var _metadataEntries$Math;
|
|
888
|
+
const { contextLineCount, lineChanges, modifiedTotalLines, originalTotalLines, pairIndex, primaryNode } = options;
|
|
889
|
+
if (lineChanges.length === 0) return null;
|
|
890
|
+
const metadataEntries = lineChanges.map((change) => buildDiffHunkMetadataLabel(change, {
|
|
891
|
+
contextLineCount,
|
|
892
|
+
modifiedTotalLines,
|
|
893
|
+
originalTotalLines
|
|
894
|
+
}));
|
|
895
|
+
const { nextVisibleLine } = measureDiffUnchangedSurroundingLines(primaryNode);
|
|
896
|
+
if (nextVisibleLine != null) {
|
|
897
|
+
const candidateStarts = [nextVisibleLine, nextVisibleLine - 1].filter((value) => value >= 1);
|
|
898
|
+
for (const candidateStart of candidateStarts) {
|
|
899
|
+
const matching = metadataEntries.find((entry) => entry.modifiedStart === candidateStart);
|
|
900
|
+
if (matching) return matching.label;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
return ((_metadataEntries$Math = metadataEntries[Math.min(pairIndex, metadataEntries.length - 1)]) === null || _metadataEntries$Math === void 0 ? void 0 : _metadataEntries$Math.label) ?? null;
|
|
904
|
+
}
|
|
905
|
+
function resolveDiffUnchangedSummaryLabel(options) {
|
|
906
|
+
const { countText, unchangedRegionStyle,...metadataOptions } = options;
|
|
907
|
+
if (unchangedRegionStyle !== "metadata") return countText;
|
|
908
|
+
return resolveDiffMetadataLabel(metadataOptions) ?? countText;
|
|
909
|
+
}
|
|
910
|
+
function resolveDiffUnchangedRevealLayout(options) {
|
|
911
|
+
const { countText, modelLineCount, pairCount, pairIndex, primaryNode } = options;
|
|
912
|
+
let showTopHandle = pairCount === 1 || pairIndex > 0;
|
|
913
|
+
let showBottomHandle = pairCount === 1 || pairIndex < pairCount - 1;
|
|
914
|
+
const countMatch = countText.match(/\d+/);
|
|
915
|
+
const hiddenCount = countMatch ? Number.parseInt(countMatch[0], 10) : NaN;
|
|
916
|
+
if (!Number.isFinite(hiddenCount)) return {
|
|
917
|
+
showTopHandle,
|
|
918
|
+
showBottomHandle
|
|
919
|
+
};
|
|
920
|
+
const { previousVisibleLine, nextVisibleLine } = measureDiffUnchangedSurroundingLines(primaryNode);
|
|
921
|
+
if (previousVisibleLine == null && nextVisibleLine != null) {
|
|
922
|
+
showTopHandle = false;
|
|
923
|
+
showBottomHandle = true;
|
|
924
|
+
return {
|
|
925
|
+
showTopHandle,
|
|
926
|
+
showBottomHandle
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
if (nextVisibleLine == null && previousVisibleLine != null) {
|
|
930
|
+
showTopHandle = true;
|
|
931
|
+
showBottomHandle = false;
|
|
932
|
+
return {
|
|
933
|
+
showTopHandle,
|
|
934
|
+
showBottomHandle
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
if (nextVisibleLine != null && nextVisibleLine - hiddenCount === 1) {
|
|
938
|
+
showTopHandle = false;
|
|
939
|
+
showBottomHandle = true;
|
|
940
|
+
}
|
|
941
|
+
if (previousVisibleLine != null && modelLineCount != null && previousVisibleLine + hiddenCount === modelLineCount) {
|
|
942
|
+
showTopHandle = true;
|
|
943
|
+
showBottomHandle = false;
|
|
944
|
+
}
|
|
945
|
+
return {
|
|
946
|
+
showTopHandle,
|
|
947
|
+
showBottomHandle
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
function resolveDiffUnchangedMergeRole(options) {
|
|
951
|
+
const { diffRoot, modifiedHost, node, originalHost } = options;
|
|
952
|
+
if (typeof HTMLElement === "undefined") return "none";
|
|
953
|
+
if (!(diffRoot instanceof HTMLElement)) return "none";
|
|
954
|
+
const nodeRect = node.getBoundingClientRect();
|
|
955
|
+
const nodeCenter = nodeRect.left + nodeRect.width / 2;
|
|
956
|
+
if (originalHost instanceof HTMLElement && modifiedHost instanceof HTMLElement) {
|
|
957
|
+
const originalRect = originalHost.getBoundingClientRect();
|
|
958
|
+
const modifiedRect = modifiedHost.getBoundingClientRect();
|
|
959
|
+
const originalCenter = originalRect.left + originalRect.width / 2;
|
|
960
|
+
const modifiedCenter = modifiedRect.left + modifiedRect.width / 2;
|
|
961
|
+
return Math.abs(nodeCenter - originalCenter) <= Math.abs(nodeCenter - modifiedCenter) ? "secondary" : "primary";
|
|
962
|
+
}
|
|
963
|
+
const diffRect = diffRoot.getBoundingClientRect();
|
|
964
|
+
return nodeCenter < diffRect.left + diffRect.width / 2 ? "secondary" : "primary";
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
//#endregion
|
|
968
|
+
//#region src/core/diffUnchangedDom.ts
|
|
969
|
+
const diffUnchangedSummaryStyleClasses = [
|
|
970
|
+
"stream-monaco-unchanged-summary-line-info",
|
|
971
|
+
"stream-monaco-unchanged-summary-line-info-basic",
|
|
972
|
+
"stream-monaco-unchanged-summary-metadata",
|
|
973
|
+
"stream-monaco-unchanged-summary-simple"
|
|
974
|
+
];
|
|
975
|
+
function createDiffUnchangedBridgeScaffold() {
|
|
976
|
+
const bridge = document.createElement("div");
|
|
977
|
+
bridge.className = "stream-monaco-diff-unchanged-bridge";
|
|
978
|
+
bridge.setAttribute("role", "group");
|
|
979
|
+
syncDiffUnchangedBridgeVisibility(bridge, false);
|
|
980
|
+
const summary = document.createElement("button");
|
|
981
|
+
summary.type = "button";
|
|
982
|
+
summary.className = "stream-monaco-unchanged-summary";
|
|
983
|
+
const visualMeta = document.createElement("div");
|
|
984
|
+
visualMeta.className = "stream-monaco-unchanged-meta";
|
|
985
|
+
summary.append(visualMeta);
|
|
986
|
+
const divider = document.createElement("span");
|
|
987
|
+
divider.className = "stream-monaco-unchanged-pane-divider";
|
|
988
|
+
divider.setAttribute("aria-hidden", "true");
|
|
989
|
+
bridge.append(summary, divider);
|
|
990
|
+
return {
|
|
991
|
+
bridge,
|
|
992
|
+
summary,
|
|
993
|
+
visualMeta,
|
|
994
|
+
divider
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
function createDiffUnchangedBridgeOverlay() {
|
|
998
|
+
const overlay = document.createElement("div");
|
|
999
|
+
overlay.className = "stream-monaco-diff-unchanged-overlay";
|
|
1000
|
+
return overlay;
|
|
1001
|
+
}
|
|
1002
|
+
function syncDiffUnchangedBridgeVisibility(bridge, visible) {
|
|
1003
|
+
bridge.hidden = !visible;
|
|
1004
|
+
bridge.toggleAttribute("aria-hidden", !visible);
|
|
1005
|
+
}
|
|
1006
|
+
function clearDiffUnchangedBridgeSourceClasses(container) {
|
|
1007
|
+
const bridgedCenters = container.querySelectorAll(".stream-monaco-unchanged-bridge-source");
|
|
1008
|
+
bridgedCenters.forEach((node) => node.classList.remove("stream-monaco-unchanged-bridge-source"));
|
|
1009
|
+
}
|
|
1010
|
+
function resetDiffUnchangedOverlayTransform(overlay) {
|
|
1011
|
+
if (!overlay) return;
|
|
1012
|
+
overlay.style.transform = "translate3d(0px, 0px, 0px)";
|
|
1013
|
+
}
|
|
1014
|
+
function resolveDiffUnchangedViewZoneHeight(unchangedRegionStyle) {
|
|
1015
|
+
return unchangedRegionStyle === "simple" ? 28 : 32;
|
|
1016
|
+
}
|
|
1017
|
+
function collectDiffUnchangedViewZoneIds(editorRoot, scrollTop) {
|
|
1018
|
+
const widgetTopValues = Array.from(editorRoot.querySelectorAll(".diff-hidden-lines-widget")).map((node) => Number.parseFloat(node.style.top || "NaN")).filter((value) => Number.isFinite(value) && value > -1e5);
|
|
1019
|
+
if (widgetTopValues.length === 0) return [];
|
|
1020
|
+
return Array.from(editorRoot.querySelectorAll(".view-zones > div[monaco-view-zone][monaco-visible-view-zone=\"true\"]")).filter((node) => {
|
|
1021
|
+
const zoneTop = Number.parseFloat(node.style.top || "NaN");
|
|
1022
|
+
const currentHeight = Number.parseFloat(node.style.height || "0");
|
|
1023
|
+
return Number.isFinite(zoneTop) && Number.isFinite(currentHeight) && currentHeight > 0 && widgetTopValues.some((widgetTop) => Math.abs(zoneTop - scrollTop - widgetTop) < .5);
|
|
1024
|
+
}).map((node) => node.getAttribute("monaco-view-zone")).filter((value) => Boolean(value));
|
|
1025
|
+
}
|
|
1026
|
+
function findDiffUnchangedActivationAction(...roots) {
|
|
1027
|
+
for (const root of roots) {
|
|
1028
|
+
const action = (root === null || root === void 0 ? void 0 : root.querySelector("a, button")) ?? null;
|
|
1029
|
+
if (action) return action;
|
|
1030
|
+
}
|
|
1031
|
+
return null;
|
|
1032
|
+
}
|
|
1033
|
+
function findDiffUnchangedExpandAction(root) {
|
|
1034
|
+
return (root === null || root === void 0 ? void 0 : root.querySelector("a")) ?? null;
|
|
1035
|
+
}
|
|
1036
|
+
function shouldIgnoreDiffUnchangedCenterClickTarget(target) {
|
|
1037
|
+
return target instanceof HTMLElement && Boolean(target.closest("a, .breadcrumb-item"));
|
|
1038
|
+
}
|
|
1039
|
+
function shouldHandleDiffUnchangedCenterClick(event) {
|
|
1040
|
+
return event.button === 0 && !shouldIgnoreDiffUnchangedCenterClickTarget(event.target);
|
|
1041
|
+
}
|
|
1042
|
+
function activateDiffUnchangedExpandAction(root, onBeforeActivate) {
|
|
1043
|
+
const action = findDiffUnchangedExpandAction(root);
|
|
1044
|
+
if (!action) return false;
|
|
1045
|
+
onBeforeActivate === null || onBeforeActivate === void 0 || onBeforeActivate(action);
|
|
1046
|
+
action.click();
|
|
1047
|
+
return true;
|
|
1048
|
+
}
|
|
1049
|
+
function syncDiffUnchangedCenterNode(node, mergeRole) {
|
|
1050
|
+
node.classList.add("stream-monaco-clickable");
|
|
1051
|
+
node.title = "Click to expand all unmodified lines";
|
|
1052
|
+
node.classList.toggle("stream-monaco-unchanged-merged-secondary", mergeRole === "secondary");
|
|
1053
|
+
node.classList.toggle("stream-monaco-unchanged-merged-primary", mergeRole === "primary");
|
|
1054
|
+
}
|
|
1055
|
+
function syncDiffUnchangedMetaNode(metaNode, unchangedRegionStyle, summaryLabel) {
|
|
1056
|
+
const lastStyle = metaNode.dataset.style;
|
|
1057
|
+
const lastLabel = metaNode.dataset.label;
|
|
1058
|
+
if (lastStyle === unchangedRegionStyle && lastLabel === summaryLabel) return;
|
|
1059
|
+
metaNode.dataset.style = unchangedRegionStyle;
|
|
1060
|
+
metaNode.dataset.label = summaryLabel;
|
|
1061
|
+
metaNode.replaceChildren();
|
|
1062
|
+
metaNode.classList.toggle("stream-monaco-unchanged-meta-simple", unchangedRegionStyle === "simple");
|
|
1063
|
+
if (unchangedRegionStyle === "simple") {
|
|
1064
|
+
const simpleBar = document.createElement("span");
|
|
1065
|
+
simpleBar.className = "stream-monaco-unchanged-simple-bar";
|
|
1066
|
+
simpleBar.setAttribute("aria-hidden", "true");
|
|
1067
|
+
metaNode.append(simpleBar);
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
const label = document.createElement("span");
|
|
1071
|
+
label.className = unchangedRegionStyle === "metadata" ? "stream-monaco-unchanged-metadata-label" : "stream-monaco-unchanged-count";
|
|
1072
|
+
label.textContent = summaryLabel;
|
|
1073
|
+
metaNode.append(label);
|
|
1074
|
+
}
|
|
1075
|
+
function syncDiffUnchangedSummaryButton(summary, unchangedRegionStyle, summaryLabel) {
|
|
1076
|
+
summary.classList.remove(...diffUnchangedSummaryStyleClasses);
|
|
1077
|
+
summary.classList.add(`stream-monaco-unchanged-summary-${unchangedRegionStyle}`);
|
|
1078
|
+
const summaryInteractive = unchangedRegionStyle === "line-info" || unchangedRegionStyle === "line-info-basic";
|
|
1079
|
+
summary.disabled = !summaryInteractive;
|
|
1080
|
+
summary.tabIndex = summaryInteractive ? 0 : -1;
|
|
1081
|
+
if (summaryInteractive) {
|
|
1082
|
+
summary.removeAttribute("aria-hidden");
|
|
1083
|
+
summary.setAttribute("aria-label", `${summaryLabel}. Expand all unmodified lines`);
|
|
1084
|
+
summary.title = "Expand all unmodified lines";
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
if (unchangedRegionStyle === "simple") {
|
|
1088
|
+
summary.setAttribute("aria-hidden", "true");
|
|
1089
|
+
summary.removeAttribute("aria-label");
|
|
1090
|
+
summary.title = "";
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
summary.removeAttribute("aria-hidden");
|
|
1094
|
+
summary.removeAttribute("aria-label");
|
|
1095
|
+
summary.title = "";
|
|
1096
|
+
}
|
|
1097
|
+
function syncDiffUnchangedExpandAction(action, hidden) {
|
|
1098
|
+
action.classList.add("stream-monaco-unchanged-expand");
|
|
1099
|
+
action.dataset.streamMonacoLabel = "Expand all";
|
|
1100
|
+
action.title = "Expand all unmodified lines";
|
|
1101
|
+
action.setAttribute("aria-label", "Expand all unmodified lines");
|
|
1102
|
+
action.toggleAttribute("aria-hidden", hidden);
|
|
1103
|
+
action.tabIndex = hidden ? -1 : 0;
|
|
1104
|
+
}
|
|
1105
|
+
function createDiffUnchangedRevealButton(direction) {
|
|
1106
|
+
const button = document.createElement("button");
|
|
1107
|
+
button.type = "button";
|
|
1108
|
+
button.className = "stream-monaco-unchanged-reveal";
|
|
1109
|
+
button.innerHTML = `<span class="codicon codicon-chevron-${direction}"></span>`;
|
|
1110
|
+
button.dataset.direction = direction;
|
|
1111
|
+
return button;
|
|
1112
|
+
}
|
|
1113
|
+
function syncDiffUnchangedRevealButtonNode(button, handle, label) {
|
|
1114
|
+
button.hidden = !handle;
|
|
1115
|
+
button.disabled = !handle;
|
|
1116
|
+
button.toggleAttribute("aria-hidden", !handle);
|
|
1117
|
+
button.title = handle ? label : "";
|
|
1118
|
+
button.setAttribute("aria-label", handle ? label : "");
|
|
1119
|
+
}
|
|
1120
|
+
function bindDiffUnchangedRevealButtonAction(button, handle, onActivate) {
|
|
1121
|
+
button.onclick = handle ? (event) => {
|
|
1122
|
+
event.preventDefault();
|
|
1123
|
+
event.stopPropagation();
|
|
1124
|
+
onActivate(handle);
|
|
1125
|
+
} : null;
|
|
1126
|
+
}
|
|
1127
|
+
function shouldHandleDiffUnchangedWheel(event) {
|
|
1128
|
+
return Math.abs(event.deltaY) >= .5 || Math.abs(event.deltaX) >= .5;
|
|
1129
|
+
}
|
|
1130
|
+
function resolveDiffUnchangedWheelScrollTarget(scrollTop, scrollLeft, event) {
|
|
1131
|
+
return {
|
|
1132
|
+
targetScrollTop: scrollTop + event.deltaY,
|
|
1133
|
+
targetScrollLeft: scrollLeft + event.deltaX,
|
|
1134
|
+
syncHorizontal: Math.abs(event.deltaX) >= .5
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
function syncDiffUnchangedBridgeNode(options) {
|
|
1138
|
+
const { bridge, bridgeLeftInset, bridgeRailWidth, containerRect, containerScrollLeft, containerScrollTop, editorBackgroundColor, primaryAnchorRect, primaryStyle, secondaryAnchorRect, unchangedRegionStyle } = options;
|
|
1139
|
+
bridge.className = "stream-monaco-diff-unchanged-bridge";
|
|
1140
|
+
bridge.classList.add(`stream-monaco-diff-unchanged-bridge-${unchangedRegionStyle}`);
|
|
1141
|
+
bridge.style.left = `${secondaryAnchorRect.left - containerRect.left + containerScrollLeft + bridgeLeftInset}px`;
|
|
1142
|
+
bridge.style.top = `${primaryAnchorRect.top - containerRect.top + containerScrollTop}px`;
|
|
1143
|
+
bridge.style.width = `${Math.max(0, primaryAnchorRect.right - secondaryAnchorRect.left - bridgeLeftInset)}px`;
|
|
1144
|
+
bridge.style.height = `${Math.max(secondaryAnchorRect.height, primaryAnchorRect.height)}px`;
|
|
1145
|
+
bridge.style.color = primaryStyle.color;
|
|
1146
|
+
bridge.style.fontFamily = primaryStyle.fontFamily;
|
|
1147
|
+
bridge.style.fontSize = primaryStyle.fontSize;
|
|
1148
|
+
bridge.style.lineHeight = primaryStyle.lineHeight;
|
|
1149
|
+
bridge.style.setProperty("--stream-monaco-unchanged-fg", primaryStyle.color);
|
|
1150
|
+
bridge.style.setProperty("--stream-monaco-editor-bg", editorBackgroundColor);
|
|
1151
|
+
bridge.style.setProperty("--stream-monaco-unchanged-split-offset", `${Math.max(0, secondaryAnchorRect.width - bridgeLeftInset)}px`);
|
|
1152
|
+
if (bridgeRailWidth) {
|
|
1153
|
+
bridge.style.setProperty("--stream-monaco-unchanged-rail-width", `${bridgeRailWidth}px`);
|
|
1154
|
+
return;
|
|
1155
|
+
}
|
|
1156
|
+
bridge.style.removeProperty("--stream-monaco-unchanged-rail-width");
|
|
1157
|
+
}
|
|
1158
|
+
function syncDiffUnchangedRailNode(rail, showTopHandle, showBottomHandle) {
|
|
1159
|
+
const shouldRenderRail = showTopHandle || showBottomHandle;
|
|
1160
|
+
rail.hidden = !shouldRenderRail;
|
|
1161
|
+
rail.toggleAttribute("aria-hidden", !shouldRenderRail);
|
|
1162
|
+
rail.classList.toggle("stream-monaco-unchanged-rail-top-only", showTopHandle && !showBottomHandle);
|
|
1163
|
+
rail.classList.toggle("stream-monaco-unchanged-rail-bottom-only", !showTopHandle && showBottomHandle);
|
|
1164
|
+
rail.classList.toggle("stream-monaco-unchanged-rail-both", showTopHandle && showBottomHandle);
|
|
1165
|
+
}
|
|
1166
|
+
function dispatchSyntheticPrimaryMouseDown(node) {
|
|
1167
|
+
const view = node.ownerDocument.defaultView;
|
|
1168
|
+
if (!view) return;
|
|
1169
|
+
const rect = node.getBoundingClientRect();
|
|
1170
|
+
node.dispatchEvent(new view.MouseEvent("mousedown", {
|
|
1171
|
+
bubbles: true,
|
|
1172
|
+
cancelable: true,
|
|
1173
|
+
button: 0,
|
|
1174
|
+
clientX: rect.left + rect.width / 2,
|
|
1175
|
+
clientY: rect.top + rect.height / 2
|
|
1176
|
+
}));
|
|
1177
|
+
}
|
|
1178
|
+
function dispatchSyntheticPrimaryMouseTap(node) {
|
|
1179
|
+
const view = node.ownerDocument.defaultView;
|
|
1180
|
+
if (!view) return;
|
|
1181
|
+
const rect = node.getBoundingClientRect();
|
|
1182
|
+
const clientX = rect.left + rect.width / 2;
|
|
1183
|
+
const clientY = rect.top + rect.height / 2;
|
|
1184
|
+
node.dispatchEvent(new view.MouseEvent("mousedown", {
|
|
1185
|
+
bubbles: true,
|
|
1186
|
+
cancelable: true,
|
|
1187
|
+
button: 0,
|
|
1188
|
+
clientX,
|
|
1189
|
+
clientY
|
|
1190
|
+
}));
|
|
1191
|
+
node.dispatchEvent(new view.MouseEvent("mouseup", {
|
|
1192
|
+
bubbles: true,
|
|
1193
|
+
cancelable: true,
|
|
1194
|
+
button: 0,
|
|
1195
|
+
clientX,
|
|
1196
|
+
clientY
|
|
1197
|
+
}));
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
//#endregion
|
|
1201
|
+
//#region src/core/diffViewport.ts
|
|
1202
|
+
function computeDiffRawHeight({ diffEditorView, maxHeightValue }) {
|
|
1203
|
+
var _originalEditor$getMo, _modifiedEditor$getMo, _originalEditor$getSc, _modifiedEditor$getSc;
|
|
1204
|
+
if (!diffEditorView) return Math.min(18 + padding, maxHeightValue);
|
|
1205
|
+
const modifiedEditor = diffEditorView.getModifiedEditor();
|
|
1206
|
+
const originalEditor = diffEditorView.getOriginalEditor();
|
|
1207
|
+
const lineHeight = modifiedEditor.getOption(monaco_shim_exports.editor.EditorOption.lineHeight);
|
|
1208
|
+
const originalLineCount = ((_originalEditor$getMo = originalEditor.getModel()) === null || _originalEditor$getMo === void 0 ? void 0 : _originalEditor$getMo.getLineCount()) ?? 1;
|
|
1209
|
+
const modifiedLineCount = ((_modifiedEditor$getMo = modifiedEditor.getModel()) === null || _modifiedEditor$getMo === void 0 ? void 0 : _modifiedEditor$getMo.getLineCount()) ?? 1;
|
|
1210
|
+
const lineCount = Math.max(originalLineCount, modifiedLineCount);
|
|
1211
|
+
const fromLines = lineCount * lineHeight + padding;
|
|
1212
|
+
const scrollHeight = Math.max(((_originalEditor$getSc = originalEditor.getScrollHeight) === null || _originalEditor$getSc === void 0 ? void 0 : _originalEditor$getSc.call(originalEditor)) ?? 0, ((_modifiedEditor$getSc = modifiedEditor.getScrollHeight) === null || _modifiedEditor$getSc === void 0 ? void 0 : _modifiedEditor$getSc.call(modifiedEditor)) ?? 0);
|
|
1213
|
+
return Math.min(Math.max(fromLines, scrollHeight), maxHeightValue);
|
|
1214
|
+
}
|
|
1215
|
+
function computeDiffHeight({ inlineDiffStreamingHeightFloor, inlineDiffStreamingPresentationActive, isInlineMode, rawHeight }) {
|
|
1216
|
+
if (!isInlineMode || !inlineDiffStreamingPresentationActive && inlineDiffStreamingHeightFloor <= 0) return {
|
|
1217
|
+
height: rawHeight,
|
|
1218
|
+
nextInlineDiffStreamingHeightFloor: inlineDiffStreamingHeightFloor
|
|
1219
|
+
};
|
|
1220
|
+
const nextInlineDiffStreamingHeightFloor = Math.max(rawHeight, inlineDiffStreamingHeightFloor);
|
|
1221
|
+
return {
|
|
1222
|
+
height: nextInlineDiffStreamingHeightFloor,
|
|
1223
|
+
nextInlineDiffStreamingHeightFloor
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
function readContainerLayoutSize(container) {
|
|
1227
|
+
var _container$getBoundin;
|
|
1228
|
+
const rect = (_container$getBoundin = container.getBoundingClientRect) === null || _container$getBoundin === void 0 ? void 0 : _container$getBoundin.call(container);
|
|
1229
|
+
return {
|
|
1230
|
+
width: container.clientWidth || (rect === null || rect === void 0 ? void 0 : rect.width) || 0,
|
|
1231
|
+
height: container.clientHeight || (rect === null || rect === void 0 ? void 0 : rect.height) || 0
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
function hasVerticalScrollbar(measurement) {
|
|
1235
|
+
const epsilon = Math.max(2, Math.round(measurement.lineHeight / 8));
|
|
1236
|
+
return measurement.scrollHeight > measurement.computedHeight + Math.max(padding / 2, epsilon);
|
|
1237
|
+
}
|
|
1238
|
+
function isUserNearBottom(measurement, options) {
|
|
1239
|
+
const lineThreshold = options.autoScrollThresholdLines * measurement.lineHeight;
|
|
1240
|
+
const threshold = Math.max(lineThreshold || 0, options.autoScrollThresholdPx);
|
|
1241
|
+
const distance = measurement.scrollHeight - (measurement.scrollTop + measurement.viewportHeight);
|
|
1242
|
+
return distance <= threshold;
|
|
1243
|
+
}
|
|
1244
|
+
function revealEditorLine(editor, line, strategy, scrollType) {
|
|
1245
|
+
if (strategy === "bottom") {
|
|
1246
|
+
if (typeof scrollType !== "undefined") editor.revealLine(line, scrollType);
|
|
1247
|
+
else editor.revealLine(line);
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
if (strategy === "center") {
|
|
1251
|
+
if (typeof scrollType !== "undefined") editor.revealLineInCenter(line, scrollType);
|
|
1252
|
+
else editor.revealLineInCenter(line);
|
|
1253
|
+
return;
|
|
1254
|
+
}
|
|
1255
|
+
if (typeof scrollType !== "undefined") editor.revealLineInCenterIfOutsideViewport(line, scrollType);
|
|
1256
|
+
else editor.revealLineInCenterIfOutsideViewport(line);
|
|
1257
|
+
}
|
|
1258
|
+
function waitForElementHeightApplied(element, target, timeoutMs = 500) {
|
|
1259
|
+
return new Promise((resolve) => {
|
|
1260
|
+
const start = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
|
|
1261
|
+
const check = () => {
|
|
1262
|
+
const applied = element ? Number.parseFloat((element.style.height || "").replace("px", "")) || 0 : -1;
|
|
1263
|
+
if (applied >= target - 1) {
|
|
1264
|
+
resolve();
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
const now = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
|
|
1268
|
+
if (now - start > timeoutMs) {
|
|
1269
|
+
resolve();
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1272
|
+
requestAnimationFrame(check);
|
|
1273
|
+
};
|
|
1274
|
+
check();
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
|
|
470
1278
|
//#endregion
|
|
471
1279
|
//#region src/core/DiffEditorManager.ts
|
|
472
1280
|
var DiffEditorManager = class DiffEditorManager {
|
|
@@ -490,6 +1298,8 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
490
1298
|
lastKnownModifiedCode = null;
|
|
491
1299
|
lastKnownModifiedLineCount = null;
|
|
492
1300
|
pendingDiffUpdate = null;
|
|
1301
|
+
minimalEditMaxCharsValue = minimalEditMaxChars;
|
|
1302
|
+
minimalEditMaxChangeRatioValue = minimalEditMaxChangeRatio;
|
|
493
1303
|
shouldAutoScrollDiff = true;
|
|
494
1304
|
diffScrollWatcher = null;
|
|
495
1305
|
lastScrollTopDiff = 0;
|
|
@@ -498,6 +1308,7 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
498
1308
|
cachedLineHeightDiff = null;
|
|
499
1309
|
cachedComputedHeightDiff = null;
|
|
500
1310
|
lastKnownModifiedDirty = false;
|
|
1311
|
+
programmaticModifiedContentChangeDepth = 0;
|
|
501
1312
|
measureViewportDiff() {
|
|
502
1313
|
var _me$getLayoutInfo, _me$getScrollTop, _me$getScrollHeight;
|
|
503
1314
|
if (!this.diffEditorView) return null;
|
|
@@ -550,8 +1361,14 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
550
1361
|
diffComputedVersions = null;
|
|
551
1362
|
preserveNativeDiffDecorationsOnStaleAppend = false;
|
|
552
1363
|
diffPresentationDisposables = [];
|
|
1364
|
+
diffPresentationObserver = null;
|
|
553
1365
|
fallbackOriginalDecorationIds = [];
|
|
554
1366
|
fallbackModifiedDecorationIds = [];
|
|
1367
|
+
fallbackInlineDeletedZoneIds = [];
|
|
1368
|
+
fallbackInlineDeletedZoneSignature = null;
|
|
1369
|
+
inlineDiffStreamingPresentationActive = false;
|
|
1370
|
+
inlineDiffStreamingPresentationIdleTimer = null;
|
|
1371
|
+
inlineDiffStreamingHeightFloor = 0;
|
|
555
1372
|
diffHunkHideTimer = null;
|
|
556
1373
|
diffUnchangedRegionDisposables = [];
|
|
557
1374
|
diffUnchangedRegionObserver = null;
|
|
@@ -564,9 +1381,11 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
564
1381
|
diffUnchangedOverlayScrollLeft = 0;
|
|
565
1382
|
diffRootAppearanceSignature = null;
|
|
566
1383
|
diffPersistedUnchangedModelState = null;
|
|
1384
|
+
diffPreviousUnchangedModelState = null;
|
|
567
1385
|
pendingPreparedDiffViewModel = null;
|
|
568
1386
|
cancelRafs() {
|
|
569
1387
|
this.rafScheduler.cancel("sync-diff-presentation");
|
|
1388
|
+
this.rafScheduler.cancel("sync-diff-layout");
|
|
570
1389
|
this.rafScheduler.cancel("capture-diff-unchanged-state");
|
|
571
1390
|
this.rafScheduler.cancel("restore-diff-unchanged-state");
|
|
572
1391
|
this.rafScheduler.cancel("patch-diff-unchanged-regions");
|
|
@@ -629,6 +1448,8 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
629
1448
|
this.diffAutoScroll = diffAutoScroll;
|
|
630
1449
|
this.revealDebounceMsOption = revealDebounceMsOption;
|
|
631
1450
|
this.diffUpdateThrottleMsOption = diffUpdateThrottleMsOption;
|
|
1451
|
+
this.minimalEditMaxCharsValue = this.options.minimalEditMaxChars ?? minimalEditMaxChars;
|
|
1452
|
+
this.minimalEditMaxChangeRatioValue = this.options.minimalEditMaxChangeRatio ?? minimalEditMaxChangeRatio;
|
|
632
1453
|
}
|
|
633
1454
|
resolveDiffHideUnchangedRegionsOption() {
|
|
634
1455
|
const normalize = (value) => {
|
|
@@ -653,6 +1474,9 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
653
1474
|
revealLineCount: 5
|
|
654
1475
|
};
|
|
655
1476
|
}
|
|
1477
|
+
resolveDiffGlyphMarginOption(hideUnchangedRegions = this.resolveDiffHideUnchangedRegionsOption()) {
|
|
1478
|
+
return (hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled) ? true : this.options.glyphMargin;
|
|
1479
|
+
}
|
|
656
1480
|
resolveDiffLineStyleOption() {
|
|
657
1481
|
return this.options.diffLineStyle === "bar" ? "bar" : "background";
|
|
658
1482
|
}
|
|
@@ -666,188 +1490,21 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
666
1490
|
if (typeof explicitThrottle === "number") return explicitThrottle;
|
|
667
1491
|
return 50;
|
|
668
1492
|
}
|
|
669
|
-
parseCssColorRgb(color) {
|
|
670
|
-
const normalized = color.trim().toLowerCase();
|
|
671
|
-
const rgbMatch = normalized.match(/^rgba?\(\s*([+\-.\d]+)\s*,\s*([+\-.\d]+)\s*,\s*([+\-.\d]+)/);
|
|
672
|
-
if (rgbMatch) return [
|
|
673
|
-
Number.parseFloat(rgbMatch[1]),
|
|
674
|
-
Number.parseFloat(rgbMatch[2]),
|
|
675
|
-
Number.parseFloat(rgbMatch[3])
|
|
676
|
-
];
|
|
677
|
-
const hexMatch = normalized.match(/^#([\da-f]{3,8})$/i);
|
|
678
|
-
if (!hexMatch) return null;
|
|
679
|
-
const hex = hexMatch[1];
|
|
680
|
-
if (hex.length === 3 || hex.length === 4) return [
|
|
681
|
-
Number.parseInt(`${hex[0]}${hex[0]}`, 16),
|
|
682
|
-
Number.parseInt(`${hex[1]}${hex[1]}`, 16),
|
|
683
|
-
Number.parseInt(`${hex[2]}${hex[2]}`, 16)
|
|
684
|
-
];
|
|
685
|
-
if (hex.length === 6 || hex.length === 8) return [
|
|
686
|
-
Number.parseInt(hex.slice(0, 2), 16),
|
|
687
|
-
Number.parseInt(hex.slice(2, 4), 16),
|
|
688
|
-
Number.parseInt(hex.slice(4, 6), 16)
|
|
689
|
-
];
|
|
690
|
-
return null;
|
|
691
|
-
}
|
|
692
|
-
resolveCssColorLuminance(color) {
|
|
693
|
-
const rgb = this.parseCssColorRgb(color);
|
|
694
|
-
if (!rgb) return null;
|
|
695
|
-
const channel = (value) => {
|
|
696
|
-
const normalized = Math.max(0, Math.min(255, value)) / 255;
|
|
697
|
-
return normalized <= .03928 ? normalized / 12.92 : ((normalized + .055) / 1.055) ** 2.4;
|
|
698
|
-
};
|
|
699
|
-
const [r, g, b] = rgb;
|
|
700
|
-
return .2126 * channel(r) + .7152 * channel(g) + .0722 * channel(b);
|
|
701
|
-
}
|
|
702
|
-
resolveDiffUnchangedLineInfoRailMetrics(node) {
|
|
703
|
-
const editorRoot = node.closest(".monaco-editor");
|
|
704
|
-
if (!editorRoot) return {
|
|
705
|
-
leftInset: 0,
|
|
706
|
-
width: null
|
|
707
|
-
};
|
|
708
|
-
const editorRect = editorRoot.getBoundingClientRect();
|
|
709
|
-
const lineNumberNode = Array.from(editorRoot.querySelectorAll(".line-numbers")).find((candidate) => {
|
|
710
|
-
const rect = candidate.getBoundingClientRect();
|
|
711
|
-
return rect.width > 0 && rect.height > 0;
|
|
712
|
-
});
|
|
713
|
-
if (!lineNumberNode) return {
|
|
714
|
-
leftInset: 0,
|
|
715
|
-
width: null
|
|
716
|
-
};
|
|
717
|
-
const lineNumberRect = lineNumberNode.getBoundingClientRect();
|
|
718
|
-
return {
|
|
719
|
-
leftInset: Math.max(0, lineNumberRect.left - editorRect.left),
|
|
720
|
-
width: Math.max(0, lineNumberRect.width) || null
|
|
721
|
-
};
|
|
722
|
-
}
|
|
723
|
-
looksLikeDarkThemeName(themeName) {
|
|
724
|
-
if (!themeName) return false;
|
|
725
|
-
const normalized = themeName.toLowerCase();
|
|
726
|
-
return [
|
|
727
|
-
"dark",
|
|
728
|
-
"night",
|
|
729
|
-
"moon",
|
|
730
|
-
"black",
|
|
731
|
-
"dracula",
|
|
732
|
-
"mocha",
|
|
733
|
-
"frappe",
|
|
734
|
-
"macchiato",
|
|
735
|
-
"palenight",
|
|
736
|
-
"ocean",
|
|
737
|
-
"poimandres",
|
|
738
|
-
"monokai",
|
|
739
|
-
"laserwave",
|
|
740
|
-
"tokyo",
|
|
741
|
-
"slack-dark",
|
|
742
|
-
"rose-pine",
|
|
743
|
-
"github-dark",
|
|
744
|
-
"material-theme",
|
|
745
|
-
"one-dark",
|
|
746
|
-
"catppuccin-mocha",
|
|
747
|
-
"catppuccin-frappe",
|
|
748
|
-
"catppuccin-macchiato"
|
|
749
|
-
].some((token) => normalized.includes(token)) && !normalized.includes("light") && !normalized.includes("latte") && !normalized.includes("dawn") && !normalized.includes("lotus");
|
|
750
|
-
}
|
|
751
|
-
looksLikeLightThemeName(themeName) {
|
|
752
|
-
if (!themeName) return false;
|
|
753
|
-
const normalized = themeName.toLowerCase();
|
|
754
|
-
return [
|
|
755
|
-
"light",
|
|
756
|
-
"day",
|
|
757
|
-
"dawn",
|
|
758
|
-
"latte",
|
|
759
|
-
"solarized-light",
|
|
760
|
-
"github-light",
|
|
761
|
-
"rose-pine-dawn",
|
|
762
|
-
"catppuccin-latte",
|
|
763
|
-
"one-light",
|
|
764
|
-
"vitesse-light",
|
|
765
|
-
"snazzy-light",
|
|
766
|
-
"material-lighter",
|
|
767
|
-
"material-theme-lighter",
|
|
768
|
-
"lotus"
|
|
769
|
-
].some((token) => normalized.includes(token));
|
|
770
|
-
}
|
|
771
|
-
resolveDiffAppearanceOption() {
|
|
772
|
-
var _this$diffEditorView, _this$diffEditorView$, _this$diffEditorView$2, _this$diffEditorView2, _this$diffEditorView3, _this$diffEditorView4;
|
|
773
|
-
if (this.options.diffAppearance === "light") return "light";
|
|
774
|
-
if (this.options.diffAppearance === "dark") return "dark";
|
|
775
|
-
if (this.looksLikeDarkThemeName(this.options.theme)) return "dark";
|
|
776
|
-
if (this.looksLikeLightThemeName(this.options.theme)) return "light";
|
|
777
|
-
const appearanceProbeNodes = [
|
|
778
|
-
(_this$diffEditorView = this.diffEditorView) === null || _this$diffEditorView === void 0 || (_this$diffEditorView$2 = (_this$diffEditorView$ = _this$diffEditorView.getModifiedEditor()).getContainerDomNode) === null || _this$diffEditorView$2 === void 0 ? void 0 : _this$diffEditorView$2.call(_this$diffEditorView$),
|
|
779
|
-
(_this$diffEditorView2 = this.diffEditorView) === null || _this$diffEditorView2 === void 0 || (_this$diffEditorView4 = (_this$diffEditorView3 = _this$diffEditorView2.getOriginalEditor()).getContainerDomNode) === null || _this$diffEditorView4 === void 0 ? void 0 : _this$diffEditorView4.call(_this$diffEditorView3),
|
|
780
|
-
this.lastContainer
|
|
781
|
-
];
|
|
782
|
-
for (const node of appearanceProbeNodes) {
|
|
783
|
-
if (!(node instanceof HTMLElement)) continue;
|
|
784
|
-
const style = globalThis.getComputedStyle(node);
|
|
785
|
-
const editorSurface = node.querySelector(".monaco-editor .monaco-editor-background, .monaco-editor .margin, .monaco-editor .lines-content");
|
|
786
|
-
const candidates = [
|
|
787
|
-
style.getPropertyValue("--stream-monaco-editor-bg"),
|
|
788
|
-
style.getPropertyValue("--vscode-editor-background"),
|
|
789
|
-
editorSurface ? globalThis.getComputedStyle(editorSurface).backgroundColor : "",
|
|
790
|
-
style.backgroundColor
|
|
791
|
-
];
|
|
792
|
-
for (const color of candidates) {
|
|
793
|
-
const luminance = this.resolveCssColorLuminance(color);
|
|
794
|
-
if (luminance == null) continue;
|
|
795
|
-
return luminance <= .42 ? "dark" : "light";
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
return this.looksLikeDarkThemeName(this.options.theme) ? "dark" : "light";
|
|
799
|
-
}
|
|
800
|
-
syncDiffRootThemeVariables(appearance) {
|
|
801
|
-
var _this$diffEditorView5, _this$diffEditorView6, _this$diffEditorView7, _this$diffEditorView8, _this$diffEditorView9, _this$diffEditorView10;
|
|
802
|
-
if (!(this.lastContainer instanceof HTMLElement)) return;
|
|
803
|
-
const probeNodes = [
|
|
804
|
-
(_this$diffEditorView5 = this.diffEditorView) === null || _this$diffEditorView5 === void 0 || (_this$diffEditorView7 = (_this$diffEditorView6 = _this$diffEditorView5.getModifiedEditor()).getContainerDomNode) === null || _this$diffEditorView7 === void 0 ? void 0 : _this$diffEditorView7.call(_this$diffEditorView6),
|
|
805
|
-
(_this$diffEditorView8 = this.diffEditorView) === null || _this$diffEditorView8 === void 0 || (_this$diffEditorView10 = (_this$diffEditorView9 = _this$diffEditorView8.getOriginalEditor()).getContainerDomNode) === null || _this$diffEditorView10 === void 0 ? void 0 : _this$diffEditorView10.call(_this$diffEditorView9),
|
|
806
|
-
this.lastContainer
|
|
807
|
-
];
|
|
808
|
-
const containerStyle = globalThis.getComputedStyle(this.lastContainer);
|
|
809
|
-
const fixedBackgroundColor = containerStyle.getPropertyValue("--stream-monaco-fixed-editor-bg").trim() || null;
|
|
810
|
-
let backgroundColor = null;
|
|
811
|
-
let foregroundColor = null;
|
|
812
|
-
for (const node of probeNodes) {
|
|
813
|
-
if (!(node instanceof HTMLElement)) continue;
|
|
814
|
-
const backgroundProbe = node.querySelector(".monaco-editor-background, .margin, .lines-content") ?? node;
|
|
815
|
-
const foregroundProbe = node.querySelector(".view-lines, .monaco-editor, .view-overlays") ?? node;
|
|
816
|
-
const nextBackground = globalThis.getComputedStyle(backgroundProbe).backgroundColor;
|
|
817
|
-
if (!backgroundColor && this.resolveCssColorLuminance(nextBackground) != null) backgroundColor = nextBackground;
|
|
818
|
-
const nextForeground = globalThis.getComputedStyle(foregroundProbe).color;
|
|
819
|
-
if (!foregroundColor && this.resolveCssColorLuminance(nextForeground) != null) foregroundColor = nextForeground;
|
|
820
|
-
if (backgroundColor && foregroundColor) break;
|
|
821
|
-
}
|
|
822
|
-
const resolvedBackgroundColor = fixedBackgroundColor || backgroundColor || (appearance === "dark" ? "rgb(10 10 11)" : "rgb(255 255 255)");
|
|
823
|
-
if (resolvedBackgroundColor) this.lastContainer.style.setProperty("--stream-monaco-editor-bg", resolvedBackgroundColor);
|
|
824
|
-
else this.lastContainer.style.removeProperty("--stream-monaco-editor-bg");
|
|
825
|
-
if (foregroundColor) this.lastContainer.style.setProperty("--stream-monaco-editor-fg", foregroundColor);
|
|
826
|
-
else this.lastContainer.style.removeProperty("--stream-monaco-editor-fg");
|
|
827
|
-
}
|
|
828
1493
|
applyDiffRootAppearanceClass() {
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
].join("|");
|
|
844
|
-
if (this.diffRootAppearanceSignature === nextSignature && containerClassList.contains("stream-monaco-diff-root")) return;
|
|
845
|
-
containerClassList.add("stream-monaco-diff-root");
|
|
846
|
-
for (const className of DiffEditorManager.diffLineStyleClasses) containerClassList.toggle(className, className === activeLineStyleClass);
|
|
847
|
-
for (const className of DiffEditorManager.diffUnchangedRegionStyleClasses) containerClassList.toggle(className, className === activeUnchangedRegionStyleClass);
|
|
848
|
-
for (const className of DiffEditorManager.diffLayoutModeClasses) containerClassList.toggle(className, className === activeLayoutModeClass);
|
|
849
|
-
for (const className of DiffEditorManager.diffAppearanceClasses) containerClassList.toggle(className, className === activeAppearanceClass);
|
|
850
|
-
this.diffRootAppearanceSignature = nextSignature;
|
|
1494
|
+
this.diffRootAppearanceSignature = applyDiffRootAppearanceClass({
|
|
1495
|
+
container: this.lastContainer,
|
|
1496
|
+
diffEditorView: this.diffEditorView,
|
|
1497
|
+
diffAppearance: this.options.diffAppearance,
|
|
1498
|
+
themeName: this.options.theme ?? null,
|
|
1499
|
+
currentSignature: this.diffRootAppearanceSignature,
|
|
1500
|
+
lineStyle: this.resolveDiffLineStyleOption(),
|
|
1501
|
+
unchangedRegionStyle: this.resolveDiffUnchangedRegionStyleOption(),
|
|
1502
|
+
isInlineMode: this.isDiffInlineMode(),
|
|
1503
|
+
lineStyleClasses: DiffEditorManager.diffLineStyleClasses,
|
|
1504
|
+
unchangedRegionStyleClasses: DiffEditorManager.diffUnchangedRegionStyleClasses,
|
|
1505
|
+
layoutModeClasses: DiffEditorManager.diffLayoutModeClasses,
|
|
1506
|
+
appearanceClasses: DiffEditorManager.diffAppearanceClasses
|
|
1507
|
+
});
|
|
851
1508
|
}
|
|
852
1509
|
disposeDiffHunkInteractions() {
|
|
853
1510
|
if (this.diffHunkHideTimer != null) {
|
|
@@ -975,13 +1632,226 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
975
1632
|
});
|
|
976
1633
|
}
|
|
977
1634
|
clearFallbackDiffDecorations() {
|
|
978
|
-
var _this$
|
|
979
|
-
const originalEditor = (_this$
|
|
980
|
-
const modifiedEditor = (_this$
|
|
1635
|
+
var _this$diffEditorView, _this$diffEditorView2;
|
|
1636
|
+
const originalEditor = (_this$diffEditorView = this.diffEditorView) === null || _this$diffEditorView === void 0 ? void 0 : _this$diffEditorView.getOriginalEditor();
|
|
1637
|
+
const modifiedEditor = (_this$diffEditorView2 = this.diffEditorView) === null || _this$diffEditorView2 === void 0 ? void 0 : _this$diffEditorView2.getModifiedEditor();
|
|
981
1638
|
if (originalEditor && this.fallbackOriginalDecorationIds.length > 0) this.fallbackOriginalDecorationIds = originalEditor.deltaDecorations(this.fallbackOriginalDecorationIds, []);
|
|
982
1639
|
else this.fallbackOriginalDecorationIds = [];
|
|
983
1640
|
if (modifiedEditor && this.fallbackModifiedDecorationIds.length > 0) this.fallbackModifiedDecorationIds = modifiedEditor.deltaDecorations(this.fallbackModifiedDecorationIds, []);
|
|
984
1641
|
else this.fallbackModifiedDecorationIds = [];
|
|
1642
|
+
this.clearFallbackInlineDeletedZones();
|
|
1643
|
+
}
|
|
1644
|
+
clearFallbackInlineDeletedZones() {
|
|
1645
|
+
var _this$diffEditorView3;
|
|
1646
|
+
const modifiedEditor = (_this$diffEditorView3 = this.diffEditorView) === null || _this$diffEditorView3 === void 0 ? void 0 : _this$diffEditorView3.getModifiedEditor();
|
|
1647
|
+
if (modifiedEditor && this.fallbackInlineDeletedZoneIds.length > 0) try {
|
|
1648
|
+
var _modifiedEditor$chang;
|
|
1649
|
+
(_modifiedEditor$chang = modifiedEditor.changeViewZones) === null || _modifiedEditor$chang === void 0 || _modifiedEditor$chang.call(modifiedEditor, (accessor) => {
|
|
1650
|
+
for (const id of this.fallbackInlineDeletedZoneIds) accessor.removeZone(id);
|
|
1651
|
+
});
|
|
1652
|
+
} catch {}
|
|
1653
|
+
this.fallbackInlineDeletedZoneIds = [];
|
|
1654
|
+
this.clearFallbackInlineDeletedZoneWrapperContent();
|
|
1655
|
+
this.fallbackInlineDeletedZoneSignature = null;
|
|
1656
|
+
}
|
|
1657
|
+
clearFallbackInlineDeletedZoneWrapperContent() {
|
|
1658
|
+
var _this$lastContainer, _this$lastContainer2, _node$parentElement;
|
|
1659
|
+
const querySelectorAll = typeof ((_this$lastContainer = this.lastContainer) === null || _this$lastContainer === void 0 ? void 0 : _this$lastContainer.querySelectorAll) === "function" ? (_this$lastContainer2 = this.lastContainer) === null || _this$lastContainer2 === void 0 ? void 0 : _this$lastContainer2.querySelectorAll.bind(this.lastContainer) : null;
|
|
1660
|
+
if (!querySelectorAll) return;
|
|
1661
|
+
const nodes = Array.from(querySelectorAll(".stream-monaco-fallback-inline-delete-zone[data-stream-monaco-native-wrapper=\"true\"], .stream-monaco-fallback-inline-delete-margin[data-stream-monaco-native-wrapper=\"true\"]") ?? []);
|
|
1662
|
+
for (const node of nodes) (_node$parentElement = node.parentElement) === null || _node$parentElement === void 0 || _node$parentElement.removeChild(node);
|
|
1663
|
+
}
|
|
1664
|
+
clearInlineDiffStreamingPresentationIdleTimer() {
|
|
1665
|
+
if (this.inlineDiffStreamingPresentationIdleTimer != null) {
|
|
1666
|
+
clearTimeout(this.inlineDiffStreamingPresentationIdleTimer);
|
|
1667
|
+
this.inlineDiffStreamingPresentationIdleTimer = null;
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
resetInlineDiffStreamingHeightFloor() {
|
|
1671
|
+
this.inlineDiffStreamingHeightFloor = 0;
|
|
1672
|
+
}
|
|
1673
|
+
syncDiffEditorLayoutToContainer() {
|
|
1674
|
+
if (!this.diffEditorView || !this.lastContainer) return;
|
|
1675
|
+
const { width, height } = readContainerLayoutSize(this.lastContainer);
|
|
1676
|
+
if (!(width > 0) || !(height > 0)) return;
|
|
1677
|
+
try {
|
|
1678
|
+
var _layout, _ref;
|
|
1679
|
+
(_layout = (_ref = this.diffEditorView).layout) === null || _layout === void 0 || _layout.call(_ref, {
|
|
1680
|
+
width: Math.round(width),
|
|
1681
|
+
height: Math.round(height)
|
|
1682
|
+
});
|
|
1683
|
+
} catch {
|
|
1684
|
+
try {
|
|
1685
|
+
var _layout2, _ref2;
|
|
1686
|
+
(_layout2 = (_ref2 = this.diffEditorView).layout) === null || _layout2 === void 0 || _layout2.call(_ref2);
|
|
1687
|
+
} catch {}
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
scheduleSyncDiffEditorLayoutToContainer() {
|
|
1691
|
+
this.rafScheduler.schedule("sync-diff-layout", () => {
|
|
1692
|
+
this.syncDiffEditorLayoutToContainer();
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1695
|
+
readModelLineContent(model, lineNumber) {
|
|
1696
|
+
const direct = model.getLineContent;
|
|
1697
|
+
if (typeof direct === "function") return direct.call(model, lineNumber);
|
|
1698
|
+
return model.getValue().split(/\r?\n/)[lineNumber - 1] ?? "";
|
|
1699
|
+
}
|
|
1700
|
+
hasVisibleNativeInlineDeleteNodes() {
|
|
1701
|
+
if (!this.lastContainer) return false;
|
|
1702
|
+
const querySelectorAll = typeof this.lastContainer.querySelectorAll === "function" ? this.lastContainer.querySelectorAll.bind(this.lastContainer) : null;
|
|
1703
|
+
if (!querySelectorAll) return false;
|
|
1704
|
+
const nodes = Array.from(querySelectorAll(".editor.modified .view-zones .line-delete, .editor.modified .inline-deleted-text, .editor.modified .inline-deleted-margin-view-zone") ?? []);
|
|
1705
|
+
return nodes.some((node) => {
|
|
1706
|
+
var _node$getBoundingClie, _globalThis$getComput, _globalThis;
|
|
1707
|
+
if (!(node instanceof HTMLElement)) return false;
|
|
1708
|
+
const rect = (_node$getBoundingClie = node.getBoundingClientRect) === null || _node$getBoundingClie === void 0 ? void 0 : _node$getBoundingClie.call(node);
|
|
1709
|
+
const style = (_globalThis$getComput = (_globalThis = globalThis).getComputedStyle) === null || _globalThis$getComput === void 0 ? void 0 : _globalThis$getComput.call(_globalThis, node);
|
|
1710
|
+
return ((rect === null || rect === void 0 ? void 0 : rect.width) ?? 0) > 0 && ((rect === null || rect === void 0 ? void 0 : rect.height) ?? 0) > 0 && (style === null || style === void 0 ? void 0 : style.display) !== "none" && (style === null || style === void 0 ? void 0 : style.visibility) !== "hidden" && Number.parseFloat((style === null || style === void 0 ? void 0 : style.opacity) || "1") > .01;
|
|
1711
|
+
});
|
|
1712
|
+
}
|
|
1713
|
+
countNativeInlineDeleteZoneNodes() {
|
|
1714
|
+
if (!this.lastContainer) return 0;
|
|
1715
|
+
const querySelectorAll = typeof this.lastContainer.querySelectorAll === "function" ? this.lastContainer.querySelectorAll.bind(this.lastContainer) : null;
|
|
1716
|
+
if (!querySelectorAll) return 0;
|
|
1717
|
+
const nodes = Array.from(querySelectorAll(".editor.modified .view-zones [monaco-view-zone], .editor.modified .margin-view-zones [monaco-view-zone]") ?? []);
|
|
1718
|
+
return nodes.filter((node) => {
|
|
1719
|
+
if (!(node instanceof HTMLElement)) return false;
|
|
1720
|
+
return node.matches(".view-lines.line-delete") || !!node.querySelector(".view-lines.line-delete") || node.matches(".inline-deleted-margin-view-zone") || !!node.querySelector(".inline-deleted-margin-view-zone");
|
|
1721
|
+
}).length;
|
|
1722
|
+
}
|
|
1723
|
+
syncFallbackInlineDeletedZones(lineChanges) {
|
|
1724
|
+
var _modifiedEditor$getMo, _EditorOption, _modifiedEditor$getOp, _this$lastContainer3, _this$lastContainer3$, _this$lastContainer4, _this$lastContainer4$;
|
|
1725
|
+
if (typeof document === "undefined" || !this.diffEditorView || !this.originalModel || !this.isDiffInlineMode()) {
|
|
1726
|
+
this.clearFallbackInlineDeletedZones();
|
|
1727
|
+
return;
|
|
1728
|
+
}
|
|
1729
|
+
const modifiedEditor = this.diffEditorView.getModifiedEditor();
|
|
1730
|
+
const modifiedModel = modifiedEditor === null || modifiedEditor === void 0 || (_modifiedEditor$getMo = modifiedEditor.getModel) === null || _modifiedEditor$getMo === void 0 ? void 0 : _modifiedEditor$getMo.call(modifiedEditor);
|
|
1731
|
+
const originalModel = this.originalModel;
|
|
1732
|
+
if (!modifiedEditor || !modifiedModel || !originalModel) {
|
|
1733
|
+
this.fallbackInlineDeletedZoneIds = [];
|
|
1734
|
+
return;
|
|
1735
|
+
}
|
|
1736
|
+
const lineHeightOption = (_EditorOption = monaco_shim_exports.editor.EditorOption) === null || _EditorOption === void 0 ? void 0 : _EditorOption.lineHeight;
|
|
1737
|
+
const lineHeight = ((_modifiedEditor$getOp = modifiedEditor.getOption) === null || _modifiedEditor$getOp === void 0 ? void 0 : _modifiedEditor$getOp.call(modifiedEditor, lineHeightOption)) ?? 20;
|
|
1738
|
+
const relevantChanges = lineChanges.filter((change) => hasOriginalLines(change));
|
|
1739
|
+
const nativeViewWrappers = Array.from(((_this$lastContainer3 = this.lastContainer) === null || _this$lastContainer3 === void 0 || (_this$lastContainer3$ = _this$lastContainer3.querySelectorAll) === null || _this$lastContainer3$ === void 0 ? void 0 : _this$lastContainer3$.call(_this$lastContainer3, ".editor.modified .view-zones [monaco-view-zone]")) ?? []).filter((node) => {
|
|
1740
|
+
return node instanceof HTMLElement && !!node.querySelector(".view-lines.line-delete");
|
|
1741
|
+
});
|
|
1742
|
+
const nativeMarginWrappers = Array.from(((_this$lastContainer4 = this.lastContainer) === null || _this$lastContainer4 === void 0 || (_this$lastContainer4$ = _this$lastContainer4.querySelectorAll) === null || _this$lastContainer4$ === void 0 ? void 0 : _this$lastContainer4$.call(_this$lastContainer4, ".editor.modified .margin-view-zones [monaco-view-zone]")) ?? []).filter((node) => {
|
|
1743
|
+
return node instanceof HTMLElement && !!node.querySelector(".inline-deleted-margin-view-zone");
|
|
1744
|
+
});
|
|
1745
|
+
const nativePairs = nativeViewWrappers.map((viewWrapper) => {
|
|
1746
|
+
const id = viewWrapper.getAttribute("monaco-view-zone");
|
|
1747
|
+
if (!id) return null;
|
|
1748
|
+
const marginWrapper = nativeMarginWrappers.find((candidate) => candidate.getAttribute("monaco-view-zone") === id);
|
|
1749
|
+
return {
|
|
1750
|
+
id,
|
|
1751
|
+
top: Number.parseFloat(viewWrapper.style.top || "NaN"),
|
|
1752
|
+
viewWrapper,
|
|
1753
|
+
marginWrapper: marginWrapper ?? null
|
|
1754
|
+
};
|
|
1755
|
+
}).filter((entry) => !!entry && Number.isFinite(entry.top)).sort((left, right) => left.top - right.top);
|
|
1756
|
+
if (nativePairs.length >= relevantChanges.length && relevantChanges.length > 0) {
|
|
1757
|
+
const nextSignature$1 = nativePairs.slice(0, relevantChanges.length).map((pair, index) => {
|
|
1758
|
+
const change = relevantChanges[index];
|
|
1759
|
+
const text = Array.from({ length: change.originalEndLineNumber - change.originalStartLineNumber + 1 }, (_, offset) => this.readModelLineContent(originalModel, change.originalStartLineNumber + offset)).join("\n");
|
|
1760
|
+
return `${pair.id}:${text}`;
|
|
1761
|
+
}).join("|");
|
|
1762
|
+
if (nextSignature$1 && this.fallbackInlineDeletedZoneSignature === nextSignature$1 && this.fallbackInlineDeletedZoneIds.length === 0) return;
|
|
1763
|
+
if (this.fallbackInlineDeletedZoneIds.length > 0) {
|
|
1764
|
+
try {
|
|
1765
|
+
var _modifiedEditor$chang2;
|
|
1766
|
+
(_modifiedEditor$chang2 = modifiedEditor.changeViewZones) === null || _modifiedEditor$chang2 === void 0 || _modifiedEditor$chang2.call(modifiedEditor, (accessor) => {
|
|
1767
|
+
for (const id of this.fallbackInlineDeletedZoneIds) accessor.removeZone(id);
|
|
1768
|
+
});
|
|
1769
|
+
} catch {}
|
|
1770
|
+
this.fallbackInlineDeletedZoneIds = [];
|
|
1771
|
+
}
|
|
1772
|
+
this.clearFallbackInlineDeletedZoneWrapperContent();
|
|
1773
|
+
relevantChanges.forEach((change, index) => {
|
|
1774
|
+
var _modifiedEditor$apply;
|
|
1775
|
+
const pair = nativePairs[index];
|
|
1776
|
+
const domNode = document.createElement("div");
|
|
1777
|
+
domNode.className = "stream-monaco-fallback-inline-delete-zone";
|
|
1778
|
+
domNode.setAttribute("aria-hidden", "true");
|
|
1779
|
+
domNode.setAttribute("data-stream-monaco-native-wrapper", "true");
|
|
1780
|
+
(_modifiedEditor$apply = modifiedEditor.applyFontInfo) === null || _modifiedEditor$apply === void 0 || _modifiedEditor$apply.call(modifiedEditor, domNode);
|
|
1781
|
+
for (let line = change.originalStartLineNumber; line <= change.originalEndLineNumber; line++) {
|
|
1782
|
+
const lineNode = document.createElement("div");
|
|
1783
|
+
lineNode.className = "stream-monaco-fallback-inline-delete-line";
|
|
1784
|
+
lineNode.textContent = this.readModelLineContent(originalModel, line);
|
|
1785
|
+
lineNode.style.height = `${lineHeight}px`;
|
|
1786
|
+
lineNode.style.lineHeight = `${lineHeight}px`;
|
|
1787
|
+
domNode.append(lineNode);
|
|
1788
|
+
}
|
|
1789
|
+
pair.viewWrapper.append(domNode);
|
|
1790
|
+
if (pair.marginWrapper) {
|
|
1791
|
+
var _modifiedEditor$apply2;
|
|
1792
|
+
const marginDomNode = document.createElement("div");
|
|
1793
|
+
marginDomNode.className = "stream-monaco-fallback-inline-delete-margin";
|
|
1794
|
+
marginDomNode.setAttribute("aria-hidden", "true");
|
|
1795
|
+
marginDomNode.setAttribute("data-stream-monaco-native-wrapper", "true");
|
|
1796
|
+
marginDomNode.style.height = "100%";
|
|
1797
|
+
(_modifiedEditor$apply2 = modifiedEditor.applyFontInfo) === null || _modifiedEditor$apply2 === void 0 || _modifiedEditor$apply2.call(modifiedEditor, marginDomNode);
|
|
1798
|
+
pair.marginWrapper.append(marginDomNode);
|
|
1799
|
+
}
|
|
1800
|
+
});
|
|
1801
|
+
this.fallbackInlineDeletedZoneSignature = nextSignature$1 || null;
|
|
1802
|
+
return;
|
|
1803
|
+
}
|
|
1804
|
+
this.clearFallbackInlineDeletedZoneWrapperContent();
|
|
1805
|
+
const nextZones = relevantChanges.map((change) => {
|
|
1806
|
+
var _modifiedEditor$apply3, _modifiedEditor$apply4;
|
|
1807
|
+
const lineCount = change.originalEndLineNumber - change.originalStartLineNumber + 1;
|
|
1808
|
+
if (lineCount < 1) return null;
|
|
1809
|
+
const domNode = document.createElement("div");
|
|
1810
|
+
domNode.className = "stream-monaco-fallback-inline-delete-zone";
|
|
1811
|
+
domNode.setAttribute("aria-hidden", "true");
|
|
1812
|
+
(_modifiedEditor$apply3 = modifiedEditor.applyFontInfo) === null || _modifiedEditor$apply3 === void 0 || _modifiedEditor$apply3.call(modifiedEditor, domNode);
|
|
1813
|
+
for (let line = change.originalStartLineNumber; line <= change.originalEndLineNumber; line++) {
|
|
1814
|
+
const lineNode = document.createElement("div");
|
|
1815
|
+
lineNode.className = "stream-monaco-fallback-inline-delete-line";
|
|
1816
|
+
lineNode.textContent = this.readModelLineContent(originalModel, line);
|
|
1817
|
+
lineNode.style.height = `${lineHeight}px`;
|
|
1818
|
+
lineNode.style.lineHeight = `${lineHeight}px`;
|
|
1819
|
+
domNode.append(lineNode);
|
|
1820
|
+
}
|
|
1821
|
+
const marginDomNode = document.createElement("div");
|
|
1822
|
+
marginDomNode.className = "stream-monaco-fallback-inline-delete-margin";
|
|
1823
|
+
marginDomNode.setAttribute("aria-hidden", "true");
|
|
1824
|
+
(_modifiedEditor$apply4 = modifiedEditor.applyFontInfo) === null || _modifiedEditor$apply4 === void 0 || _modifiedEditor$apply4.call(modifiedEditor, marginDomNode);
|
|
1825
|
+
const anchorLine = Math.max(0, Math.min(modifiedModel.getLineCount(), (change.modifiedStartLineNumber || 1) - 1));
|
|
1826
|
+
return {
|
|
1827
|
+
afterLineNumber: anchorLine,
|
|
1828
|
+
heightInLines: lineCount,
|
|
1829
|
+
domNode,
|
|
1830
|
+
marginDomNode
|
|
1831
|
+
};
|
|
1832
|
+
}).filter(Boolean);
|
|
1833
|
+
const nextSignature = nextZones.map((zone) => {
|
|
1834
|
+
var _zone$domNode;
|
|
1835
|
+
const text = typeof ((_zone$domNode = zone.domNode) === null || _zone$domNode === void 0 ? void 0 : _zone$domNode.textContent) === "string" ? zone.domNode.textContent : "";
|
|
1836
|
+
return `${zone.afterLineNumber}:${zone.heightInLines}:${text}`;
|
|
1837
|
+
}).join("|");
|
|
1838
|
+
if (nextSignature && this.fallbackInlineDeletedZoneSignature === nextSignature && this.fallbackInlineDeletedZoneIds.length === nextZones.length) return;
|
|
1839
|
+
try {
|
|
1840
|
+
var _modifiedEditor$chang3;
|
|
1841
|
+
(_modifiedEditor$chang3 = modifiedEditor.changeViewZones) === null || _modifiedEditor$chang3 === void 0 || _modifiedEditor$chang3.call(modifiedEditor, (accessor) => {
|
|
1842
|
+
for (const id of this.fallbackInlineDeletedZoneIds) accessor.removeZone(id);
|
|
1843
|
+
this.fallbackInlineDeletedZoneIds = nextZones.map((zone) => accessor.addZone(zone));
|
|
1844
|
+
});
|
|
1845
|
+
this.fallbackInlineDeletedZoneSignature = nextSignature || null;
|
|
1846
|
+
} catch {
|
|
1847
|
+
this.fallbackInlineDeletedZoneIds = [];
|
|
1848
|
+
this.fallbackInlineDeletedZoneSignature = null;
|
|
1849
|
+
}
|
|
1850
|
+
try {
|
|
1851
|
+
var _modifiedEditor$layou, _render;
|
|
1852
|
+
(_modifiedEditor$layou = modifiedEditor.layout) === null || _modifiedEditor$layou === void 0 || _modifiedEditor$layou.call(modifiedEditor);
|
|
1853
|
+
(_render = modifiedEditor.render) === null || _render === void 0 || _render.call(modifiedEditor, true);
|
|
1854
|
+
} catch {}
|
|
985
1855
|
}
|
|
986
1856
|
toWholeLineDecoration(side, startLineNumber, endLineNumber) {
|
|
987
1857
|
if (endLineNumber < startLineNumber || startLineNumber < 1) return null;
|
|
@@ -999,26 +1869,45 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
999
1869
|
};
|
|
1000
1870
|
}
|
|
1001
1871
|
syncDiffPresentationDecorations() {
|
|
1002
|
-
var _this$diffEditorView
|
|
1872
|
+
var _this$diffEditorView$, _this$lastContainer$q, _this$lastContainer5;
|
|
1003
1873
|
if (!this.diffEditorView || !this.lastContainer) return;
|
|
1004
1874
|
const nativeFresh = this.hasFreshNativeDiffResult();
|
|
1005
|
-
const
|
|
1875
|
+
const useInlineMode = this.isDiffInlineMode();
|
|
1876
|
+
const lineChanges = this.getEffectiveLineChanges();
|
|
1877
|
+
const nativeInlineDeleteZoneCount = useInlineMode ? this.countNativeInlineDeleteZoneNodes() : 0;
|
|
1878
|
+
const hasNativeInlineDeleteZoneNodes = nativeInlineDeleteZoneCount > 0;
|
|
1879
|
+
const hasNativeInlineDeleteNodes = useInlineMode && this.hasVisibleNativeInlineDeleteNodes();
|
|
1880
|
+
const shouldKeepInlineFallback = useInlineMode && lineChanges.some((change) => hasOriginalLines(change)) && !hasNativeInlineDeleteZoneNodes;
|
|
1881
|
+
const useInlineStaleFallback = shouldKeepInlineFallback;
|
|
1882
|
+
this.lastContainer.classList.toggle("stream-monaco-diff-inline-native-ready", useInlineMode && !shouldKeepInlineFallback && (nativeFresh || hasNativeInlineDeleteNodes || hasNativeInlineDeleteZoneNodes));
|
|
1883
|
+
const keepNativeDecorationsWhileStale = !useInlineStaleFallback && !nativeFresh && this.preserveNativeDiffDecorationsOnStaleAppend && ((((_this$diffEditorView$ = this.diffEditorView.getLineChanges()) === null || _this$diffEditorView$ === void 0 ? void 0 : _this$diffEditorView$.length) ?? 0) > 0 || !!((_this$lastContainer$q = (_this$lastContainer5 = this.lastContainer).querySelector) === null || _this$lastContainer$q === void 0 ? void 0 : _this$lastContainer$q.call(_this$lastContainer5, ".line-insert, .line-delete, .gutter-insert, .gutter-delete")));
|
|
1006
1884
|
this.lastContainer.classList.toggle("stream-monaco-diff-native-stale", !nativeFresh && !keepNativeDecorationsWhileStale);
|
|
1007
|
-
if (nativeFresh) {
|
|
1885
|
+
if (nativeFresh && !shouldKeepInlineFallback) {
|
|
1008
1886
|
this.clearFallbackDiffDecorations();
|
|
1009
1887
|
return;
|
|
1010
1888
|
}
|
|
1011
1889
|
const originalEditor = this.diffEditorView.getOriginalEditor();
|
|
1012
1890
|
const modifiedEditor = this.diffEditorView.getModifiedEditor();
|
|
1013
|
-
const lineChanges = this.getEffectiveLineChanges();
|
|
1014
1891
|
const originalDecorations = lineChanges.map((change) => this.toWholeLineDecoration("original", change.originalStartLineNumber, change.originalEndLineNumber)).filter(Boolean);
|
|
1015
1892
|
const modifiedDecorations = lineChanges.map((change) => this.toWholeLineDecoration("modified", change.modifiedStartLineNumber, change.modifiedEndLineNumber)).filter(Boolean);
|
|
1016
1893
|
this.fallbackOriginalDecorationIds = originalEditor.deltaDecorations(this.fallbackOriginalDecorationIds, originalDecorations);
|
|
1017
1894
|
this.fallbackModifiedDecorationIds = modifiedEditor.deltaDecorations(this.fallbackModifiedDecorationIds, modifiedDecorations);
|
|
1895
|
+
if (useInlineStaleFallback) this.syncFallbackInlineDeletedZones(lineChanges);
|
|
1896
|
+
else this.clearFallbackInlineDeletedZones();
|
|
1018
1897
|
}
|
|
1019
1898
|
disposeDiffPresentationTracking() {
|
|
1020
1899
|
this.clearFallbackDiffDecorations();
|
|
1021
|
-
if (this.
|
|
1900
|
+
if (this.diffPresentationObserver) {
|
|
1901
|
+
this.diffPresentationObserver.disconnect();
|
|
1902
|
+
this.diffPresentationObserver = null;
|
|
1903
|
+
}
|
|
1904
|
+
this.clearInlineDiffStreamingPresentationIdleTimer();
|
|
1905
|
+
this.inlineDiffStreamingPresentationActive = false;
|
|
1906
|
+
this.resetInlineDiffStreamingHeightFloor();
|
|
1907
|
+
if (this.lastContainer) {
|
|
1908
|
+
this.lastContainer.classList.remove("stream-monaco-diff-native-stale");
|
|
1909
|
+
this.lastContainer.classList.remove("stream-monaco-diff-inline-native-ready");
|
|
1910
|
+
}
|
|
1022
1911
|
this.diffComputedVersions = null;
|
|
1023
1912
|
this.diffPresentationDisposables.forEach((disposable) => disposable.dispose());
|
|
1024
1913
|
this.diffPresentationDisposables = [];
|
|
@@ -1369,6 +2258,31 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
1369
2258
|
border: 0 !important;
|
|
1370
2259
|
box-shadow: var(--stream-monaco-removed-line-shadow);
|
|
1371
2260
|
}
|
|
2261
|
+
.stream-monaco-diff-root .monaco-editor .stream-monaco-fallback-inline-delete-zone {
|
|
2262
|
+
box-sizing: border-box;
|
|
2263
|
+
width: 100%;
|
|
2264
|
+
pointer-events: none;
|
|
2265
|
+
}
|
|
2266
|
+
.stream-monaco-diff-root .monaco-editor .stream-monaco-fallback-inline-delete-line {
|
|
2267
|
+
box-sizing: border-box;
|
|
2268
|
+
width: 100%;
|
|
2269
|
+
overflow: hidden;
|
|
2270
|
+
white-space: pre;
|
|
2271
|
+
color: inherit;
|
|
2272
|
+
background: var(--stream-monaco-removed-line-fill);
|
|
2273
|
+
box-shadow: var(--stream-monaco-removed-line-shadow);
|
|
2274
|
+
}
|
|
2275
|
+
.stream-monaco-diff-root .monaco-editor .stream-monaco-fallback-inline-delete-margin {
|
|
2276
|
+
box-sizing: border-box;
|
|
2277
|
+
width: 100%;
|
|
2278
|
+
background: var(--stream-monaco-removed-gutter);
|
|
2279
|
+
pointer-events: none;
|
|
2280
|
+
}
|
|
2281
|
+
.stream-monaco-diff-root.stream-monaco-diff-inline-native-ready .stream-monaco-fallback-inline-delete-zone,
|
|
2282
|
+
.stream-monaco-diff-root.stream-monaco-diff-inline-native-ready .stream-monaco-fallback-inline-delete-line,
|
|
2283
|
+
.stream-monaco-diff-root.stream-monaco-diff-inline-native-ready .stream-monaco-fallback-inline-delete-margin {
|
|
2284
|
+
display: none !important;
|
|
2285
|
+
}
|
|
1372
2286
|
.stream-monaco-diff-root .monaco-editor .stream-monaco-fallback-gutter-insert,
|
|
1373
2287
|
.stream-monaco-diff-root .monaco-diff-editor .stream-monaco-fallback-gutter-insert {
|
|
1374
2288
|
background: var(--stream-monaco-added-gutter) !important;
|
|
@@ -1498,6 +2412,9 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
1498
2412
|
}
|
|
1499
2413
|
.stream-monaco-diff-root .monaco-diff-editor .editor.original .current-line {
|
|
1500
2414
|
width: var(--stream-monaco-original-margin-width, auto) !important;
|
|
2415
|
+
display: none !important;
|
|
2416
|
+
opacity: 0 !important;
|
|
2417
|
+
pointer-events: none !important;
|
|
1501
2418
|
}
|
|
1502
2419
|
.stream-monaco-diff-root .monaco-diff-editor .editor.original .monaco-scrollable-element.editor-scrollable {
|
|
1503
2420
|
left: var(--stream-monaco-original-scrollable-left, auto) !important;
|
|
@@ -1510,6 +2427,9 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
1510
2427
|
}
|
|
1511
2428
|
.stream-monaco-diff-root .monaco-diff-editor .editor.modified .current-line {
|
|
1512
2429
|
width: var(--stream-monaco-modified-margin-width) !important;
|
|
2430
|
+
display: none !important;
|
|
2431
|
+
opacity: 0 !important;
|
|
2432
|
+
pointer-events: none !important;
|
|
1513
2433
|
}
|
|
1514
2434
|
.stream-monaco-diff-root .monaco-diff-editor .editor.modified .monaco-scrollable-element.editor-scrollable {
|
|
1515
2435
|
left: var(--stream-monaco-modified-scrollable-left, var(--stream-monaco-modified-margin-width)) !important;
|
|
@@ -1540,15 +2460,39 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
1540
2460
|
border: 0 !important;
|
|
1541
2461
|
overflow: hidden !important;
|
|
1542
2462
|
}
|
|
2463
|
+
.stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .monaco-editor,
|
|
2464
|
+
.stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .monaco-editor-background,
|
|
2465
|
+
.stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .lines-content {
|
|
2466
|
+
width: 0 !important;
|
|
2467
|
+
min-width: 0 !important;
|
|
2468
|
+
background: transparent !important;
|
|
2469
|
+
opacity: 0 !important;
|
|
2470
|
+
pointer-events: none !important;
|
|
2471
|
+
}
|
|
1543
2472
|
.stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .monaco-scrollable-element.editor-scrollable {
|
|
1544
2473
|
left: 0 !important;
|
|
1545
2474
|
width: 0 !important;
|
|
1546
2475
|
}
|
|
2476
|
+
.stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .margin,
|
|
2477
|
+
.stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .margin-view-overlays,
|
|
2478
|
+
.stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .margin-view-zones,
|
|
2479
|
+
.stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .overflow-guard {
|
|
2480
|
+
display: none !important;
|
|
2481
|
+
width: 0 !important;
|
|
2482
|
+
min-width: 0 !important;
|
|
2483
|
+
}
|
|
1547
2484
|
.stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.modified {
|
|
1548
2485
|
left: 0 !important;
|
|
1549
2486
|
width: 100% !important;
|
|
1550
2487
|
border-left: 0 !important;
|
|
1551
2488
|
}
|
|
2489
|
+
.stream-monaco-diff-root.stream-monaco-diff-inline.stream-monaco-diff-native-stale .monaco-diff-editor .editor.modified .view-lines.line-delete,
|
|
2490
|
+
.stream-monaco-diff-root.stream-monaco-diff-inline.stream-monaco-diff-native-stale .monaco-diff-editor .editor.modified .inline-deleted-margin-view-zone {
|
|
2491
|
+
display: none !important;
|
|
2492
|
+
height: 0 !important;
|
|
2493
|
+
min-height: 0 !important;
|
|
2494
|
+
overflow: hidden !important;
|
|
2495
|
+
}
|
|
1552
2496
|
.stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .gutter-delete,
|
|
1553
2497
|
.stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .gutter-insert,
|
|
1554
2498
|
.stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .line-delete,
|
|
@@ -2138,6 +3082,9 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2138
3082
|
opacity: 0.92 !important;
|
|
2139
3083
|
transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.14s ease, opacity 0.14s ease, box-shadow 0.14s ease;
|
|
2140
3084
|
}
|
|
3085
|
+
.stream-monaco-diff-root .monaco-editor .fold-unchanged.stream-monaco-fold-unchanged-hidden {
|
|
3086
|
+
display: none !important;
|
|
3087
|
+
}
|
|
2141
3088
|
.stream-monaco-diff-root .monaco-editor .fold-unchanged:hover,
|
|
2142
3089
|
.stream-monaco-diff-root .monaco-editor .fold-unchanged.stream-monaco-focus-visible {
|
|
2143
3090
|
opacity: 1 !important;
|
|
@@ -2208,33 +3155,14 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2208
3155
|
el.addEventListener(eventName, listener);
|
|
2209
3156
|
bucket.push({ dispose: () => el.removeEventListener(eventName, listener) });
|
|
2210
3157
|
}
|
|
2211
|
-
createDiffHunkActionNode(side) {
|
|
2212
|
-
const node = document.createElement("div");
|
|
2213
|
-
node.className = "stream-monaco-diff-hunk-actions";
|
|
2214
|
-
node.dataset.side = side;
|
|
2215
|
-
const createButton = (action, label) => {
|
|
2216
|
-
const button = document.createElement("button");
|
|
2217
|
-
button.type = "button";
|
|
2218
|
-
button.textContent = label;
|
|
2219
|
-
button.dataset.action = action;
|
|
2220
|
-
button.addEventListener("click", (event) => {
|
|
2221
|
-
event.preventDefault();
|
|
2222
|
-
event.stopPropagation();
|
|
2223
|
-
this.applyDiffHunkAction(side, action);
|
|
2224
|
-
});
|
|
2225
|
-
return button;
|
|
2226
|
-
};
|
|
2227
|
-
node.append(createButton("revert", "Revert"), createButton("stage", "Stage"));
|
|
2228
|
-
this.createDomDisposable(this.diffHunkDisposables, node, "mouseenter", () => this.cancelScheduledHideDiffHunkActions());
|
|
2229
|
-
this.createDomDisposable(this.diffHunkDisposables, node, "mouseleave", () => this.scheduleHideDiffHunkActions());
|
|
2230
|
-
return node;
|
|
2231
|
-
}
|
|
2232
3158
|
cloneSerializableValue(value) {
|
|
2233
3159
|
if (typeof structuredClone === "function") return structuredClone(value);
|
|
2234
3160
|
return JSON.parse(JSON.stringify(value));
|
|
2235
3161
|
}
|
|
2236
3162
|
capturePersistedDiffUnchangedState() {
|
|
2237
3163
|
if (!this.diffEditorView) return;
|
|
3164
|
+
const hideUnchangedRegions = this.diffHideUnchangedRegionsResolved ?? this.resolveDiffHideUnchangedRegionsOption();
|
|
3165
|
+
if (!(hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled) || this.diffHideUnchangedRegionsDeferred) return;
|
|
2238
3166
|
const state = this.diffEditorView.saveViewState();
|
|
2239
3167
|
if (!(state === null || state === void 0 ? void 0 : state.modelState)) {
|
|
2240
3168
|
this.diffPersistedUnchangedModelState = null;
|
|
@@ -2242,6 +3170,14 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2242
3170
|
}
|
|
2243
3171
|
this.diffPersistedUnchangedModelState = this.cloneSerializableValue(state.modelState);
|
|
2244
3172
|
}
|
|
3173
|
+
capturePreviousDiffUnchangedState() {
|
|
3174
|
+
if (!this.diffEditorView) return;
|
|
3175
|
+
const hideUnchangedRegions = this.diffHideUnchangedRegionsResolved ?? this.resolveDiffHideUnchangedRegionsOption();
|
|
3176
|
+
if (!(hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled) || this.diffHideUnchangedRegionsDeferred) return;
|
|
3177
|
+
const state = this.diffEditorView.saveViewState();
|
|
3178
|
+
if (!(state === null || state === void 0 ? void 0 : state.modelState)) return;
|
|
3179
|
+
this.diffPreviousUnchangedModelState = this.cloneSerializableValue(state.modelState);
|
|
3180
|
+
}
|
|
2245
3181
|
scheduleCapturePersistedDiffUnchangedState(frames = 1) {
|
|
2246
3182
|
this.rafScheduler.schedule("capture-diff-unchanged-state", () => {
|
|
2247
3183
|
let remaining = Math.max(0, frames);
|
|
@@ -2267,6 +3203,20 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2267
3203
|
});
|
|
2268
3204
|
this.applyPendingDiffScrollRestore();
|
|
2269
3205
|
}
|
|
3206
|
+
restorePreviousDiffUnchangedState() {
|
|
3207
|
+
if (!this.diffEditorView || !this.diffPreviousUnchangedModelState) return false;
|
|
3208
|
+
const current = this.diffEditorView.saveViewState();
|
|
3209
|
+
if (!current) return false;
|
|
3210
|
+
const previous = this.cloneSerializableValue(this.diffPreviousUnchangedModelState);
|
|
3211
|
+
this.diffEditorView.restoreViewState({
|
|
3212
|
+
original: current.original,
|
|
3213
|
+
modified: current.modified,
|
|
3214
|
+
modelState: previous
|
|
3215
|
+
});
|
|
3216
|
+
this.diffPersistedUnchangedModelState = this.cloneSerializableValue(previous);
|
|
3217
|
+
this.applyPendingDiffScrollRestore();
|
|
3218
|
+
return true;
|
|
3219
|
+
}
|
|
2270
3220
|
scheduleRestorePersistedDiffUnchangedState() {
|
|
2271
3221
|
if (this.diffHideUnchangedRegionsDeferred) return;
|
|
2272
3222
|
if (!this.diffPersistedUnchangedModelState) return;
|
|
@@ -2430,7 +3380,7 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2430
3380
|
readOnly: this.options.readOnly ?? true,
|
|
2431
3381
|
lineDecorationsWidth: this.options.lineDecorationsWidth,
|
|
2432
3382
|
lineNumbersMinChars: this.options.lineNumbersMinChars,
|
|
2433
|
-
glyphMargin: this.
|
|
3383
|
+
glyphMargin: this.resolveDiffGlyphMarginOption(hideUnchangedRegions),
|
|
2434
3384
|
fontFamily: this.options.fontFamily,
|
|
2435
3385
|
fontSize: this.options.fontSize,
|
|
2436
3386
|
lineHeight: this.options.lineHeight,
|
|
@@ -2450,9 +3400,10 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2450
3400
|
};
|
|
2451
3401
|
}
|
|
2452
3402
|
refreshDiffPresentation() {
|
|
2453
|
-
var _this$diffHeightManag;
|
|
3403
|
+
var _this$diffHideUnchang, _this$diffHeightManag;
|
|
2454
3404
|
if (!this.diffEditorView) return;
|
|
2455
3405
|
const hideUnchangedRegions = this.resolveDiffHideUnchangedRegionsOption();
|
|
3406
|
+
const shouldRecomputeDiffViewModelForUnchangedRegions = !this.diffHideUnchangedRegionsDeferred && (hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled) === true && ((_this$diffHideUnchang = this.diffHideUnchangedRegionsResolved) === null || _this$diffHideUnchang === void 0 ? void 0 : _this$diffHideUnchang.enabled) === false && !!this.originalModel && !!this.modifiedModel;
|
|
2456
3407
|
const presentationOptions = this.resolveDiffPresentationEditorOptions(hideUnchangedRegions);
|
|
2457
3408
|
this.diffHideUnchangedRegionsResolved = hideUnchangedRegions;
|
|
2458
3409
|
this.diffUpdateThrottleMs = this.resolveDiffStreamingThrottleMs();
|
|
@@ -2462,13 +3413,20 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2462
3413
|
this.lastContainer.style.removeProperty("--stream-monaco-editor-fg");
|
|
2463
3414
|
}
|
|
2464
3415
|
this.withLockedDiffScrollPosition(() => {
|
|
2465
|
-
var _this$
|
|
2466
|
-
(_this$
|
|
3416
|
+
var _this$diffEditorView4;
|
|
3417
|
+
(_this$diffEditorView4 = this.diffEditorView) === null || _this$diffEditorView4 === void 0 || _this$diffEditorView4.updateOptions(presentationOptions);
|
|
2467
3418
|
});
|
|
2468
3419
|
(_this$diffHeightManag = this.diffHeightManager) === null || _this$diffHeightManag === void 0 || _this$diffHeightManag.update();
|
|
2469
3420
|
this.applyDiffRootAppearanceClass();
|
|
2470
3421
|
this.schedulePatchDiffUnchangedRegionsAfterInteraction(1);
|
|
2471
3422
|
this.repositionDiffHunkNodes();
|
|
3423
|
+
if (shouldRecomputeDiffViewModelForUnchangedRegions) this.setDiffModels({
|
|
3424
|
+
original: this.originalModel,
|
|
3425
|
+
modified: this.modifiedModel
|
|
3426
|
+
}, {
|
|
3427
|
+
preserveViewState: true,
|
|
3428
|
+
preserveModelState: false
|
|
3429
|
+
});
|
|
2472
3430
|
}
|
|
2473
3431
|
restoreDeferredDiffUnchangedRegions() {
|
|
2474
3432
|
this.clearDeferredDiffUnchangedRegionsIdleTimer();
|
|
@@ -2478,8 +3436,8 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2478
3436
|
if (!this.diffHideUnchangedRegionsDeferred) return;
|
|
2479
3437
|
this.diffHideUnchangedRegionsDeferred = false;
|
|
2480
3438
|
this.withLockedDiffScrollPosition(() => {
|
|
2481
|
-
var _this$
|
|
2482
|
-
(_this$
|
|
3439
|
+
var _this$diffEditorView5;
|
|
3440
|
+
(_this$diffEditorView5 = this.diffEditorView) === null || _this$diffEditorView5 === void 0 || _this$diffEditorView5.updateOptions({ hideUnchangedRegions });
|
|
2483
3441
|
});
|
|
2484
3442
|
this.schedulePatchDiffUnchangedRegionsAfterInteraction(1);
|
|
2485
3443
|
if (this.shouldAutoScrollDiff) {
|
|
@@ -2488,6 +3446,22 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2488
3446
|
}
|
|
2489
3447
|
}
|
|
2490
3448
|
markDiffStreamingActivity() {
|
|
3449
|
+
var _this$lastContainer6;
|
|
3450
|
+
(_this$lastContainer6 = this.lastContainer) === null || _this$lastContainer6 === void 0 || (_this$lastContainer6 = _this$lastContainer6.classList) === null || _this$lastContainer6 === void 0 || _this$lastContainer6.remove("stream-monaco-diff-inline-native-ready");
|
|
3451
|
+
if (this.isDiffInlineMode()) {
|
|
3452
|
+
var _this$diffHeightManag2, _this$lastContainer7, _this$lastContainer7$;
|
|
3453
|
+
this.inlineDiffStreamingPresentationActive = true;
|
|
3454
|
+
this.inlineDiffStreamingHeightFloor = Math.max(this.inlineDiffStreamingHeightFloor, ((_this$diffHeightManag2 = this.diffHeightManager) === null || _this$diffHeightManag2 === void 0 ? void 0 : _this$diffHeightManag2.getLastApplied()) ?? 0, ((_this$lastContainer7 = this.lastContainer) === null || _this$lastContainer7 === void 0 || (_this$lastContainer7$ = _this$lastContainer7.getBoundingClientRect) === null || _this$lastContainer7$ === void 0 ? void 0 : _this$lastContainer7$.call(_this$lastContainer7).height) ?? 0);
|
|
3455
|
+
this.clearInlineDiffStreamingPresentationIdleTimer();
|
|
3456
|
+
this.inlineDiffStreamingPresentationIdleTimer = setTimeout(() => {
|
|
3457
|
+
var _this$diffHeightManag3;
|
|
3458
|
+
this.inlineDiffStreamingPresentationIdleTimer = null;
|
|
3459
|
+
this.inlineDiffStreamingPresentationActive = false;
|
|
3460
|
+
this.resetInlineDiffStreamingHeightFloor();
|
|
3461
|
+
this.scheduleSyncDiffPresentationDecorations();
|
|
3462
|
+
(_this$diffHeightManag3 = this.diffHeightManager) === null || _this$diffHeightManag3 === void 0 || _this$diffHeightManag3.update();
|
|
3463
|
+
}, 3e3);
|
|
3464
|
+
}
|
|
2491
3465
|
const hideUnchangedRegions = this.diffHideUnchangedRegionsResolved;
|
|
2492
3466
|
if (!this.diffEditorView || !(hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled)) return;
|
|
2493
3467
|
this.clearDeferredDiffUnchangedRegionsIdleTimer();
|
|
@@ -2499,8 +3473,8 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2499
3473
|
this.diffHideUnchangedRegionsDeferred = true;
|
|
2500
3474
|
this.hideAllDiffUnchangedBridgeEntries();
|
|
2501
3475
|
this.withLockedDiffScrollPosition(() => {
|
|
2502
|
-
var _this$
|
|
2503
|
-
(_this$
|
|
3476
|
+
var _this$diffEditorView6;
|
|
3477
|
+
(_this$diffEditorView6 = this.diffEditorView) === null || _this$diffEditorView6 === void 0 || _this$diffEditorView6.updateOptions({ hideUnchangedRegions: {
|
|
2504
3478
|
...hideUnchangedRegions,
|
|
2505
3479
|
enabled: false
|
|
2506
3480
|
} });
|
|
@@ -2574,7 +3548,7 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2574
3548
|
var _this$diffUnchangedBr;
|
|
2575
3549
|
this.clearDiffUnchangedBridgeSources();
|
|
2576
3550
|
if (this.diffUnchangedBridgeOverlay) this.diffUnchangedBridgeOverlay.replaceChildren();
|
|
2577
|
-
|
|
3551
|
+
resetDiffUnchangedOverlayTransform(this.diffUnchangedBridgeOverlay);
|
|
2578
3552
|
this.diffUnchangedBridgeEntries.clear();
|
|
2579
3553
|
this.diffUnchangedBridgePool.length = 0;
|
|
2580
3554
|
this.diffUnchangedOverlayScrollTop = 0;
|
|
@@ -2584,30 +3558,27 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2584
3558
|
}
|
|
2585
3559
|
clearDiffUnchangedBridgeSources() {
|
|
2586
3560
|
if (!this.lastContainer) return;
|
|
2587
|
-
|
|
2588
|
-
bridgedCenters.forEach((node) => node.classList.remove("stream-monaco-unchanged-bridge-source"));
|
|
3561
|
+
clearDiffUnchangedBridgeSourceClasses(this.lastContainer);
|
|
2589
3562
|
}
|
|
2590
3563
|
ensureDiffUnchangedBridgeOverlay() {
|
|
2591
3564
|
if (!this.lastContainer) return null;
|
|
2592
3565
|
if (!this.diffUnchangedBridgeOverlay) {
|
|
2593
|
-
const overlay =
|
|
2594
|
-
overlay.className = "stream-monaco-diff-unchanged-overlay";
|
|
3566
|
+
const overlay = createDiffUnchangedBridgeOverlay();
|
|
2595
3567
|
this.lastContainer.append(overlay);
|
|
2596
3568
|
this.diffUnchangedBridgeOverlay = overlay;
|
|
2597
3569
|
}
|
|
2598
3570
|
return this.diffUnchangedBridgeOverlay;
|
|
2599
3571
|
}
|
|
2600
3572
|
readDiffUnchangedOverlayScrollState() {
|
|
2601
|
-
var _this$
|
|
2602
|
-
const modifiedEditor = (_this$
|
|
3573
|
+
var _this$diffEditorView7, _modifiedEditor$getSc6, _modifiedEditor$getSc7;
|
|
3574
|
+
const modifiedEditor = (_this$diffEditorView7 = this.diffEditorView) === null || _this$diffEditorView7 === void 0 ? void 0 : _this$diffEditorView7.getModifiedEditor();
|
|
2603
3575
|
return {
|
|
2604
3576
|
top: (modifiedEditor === null || modifiedEditor === void 0 || (_modifiedEditor$getSc6 = modifiedEditor.getScrollTop) === null || _modifiedEditor$getSc6 === void 0 ? void 0 : _modifiedEditor$getSc6.call(modifiedEditor)) ?? 0,
|
|
2605
3577
|
left: (modifiedEditor === null || modifiedEditor === void 0 || (_modifiedEditor$getSc7 = modifiedEditor.getScrollLeft) === null || _modifiedEditor$getSc7 === void 0 ? void 0 : _modifiedEditor$getSc7.call(modifiedEditor)) ?? 0
|
|
2606
3578
|
};
|
|
2607
3579
|
}
|
|
2608
3580
|
syncDiffUnchangedOverlayScrollBaseline() {
|
|
2609
|
-
|
|
2610
|
-
if (overlay) overlay.style.transform = "translate3d(0px, 0px, 0px)";
|
|
3581
|
+
resetDiffUnchangedOverlayTransform(this.diffUnchangedBridgeOverlay);
|
|
2611
3582
|
const { top, left } = this.readDiffUnchangedOverlayScrollState();
|
|
2612
3583
|
this.diffUnchangedOverlayScrollTop = top;
|
|
2613
3584
|
this.diffUnchangedOverlayScrollLeft = left;
|
|
@@ -2621,28 +3592,10 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2621
3592
|
if (Math.abs(deltaY) < .5 && Math.abs(deltaX) < .5) return;
|
|
2622
3593
|
overlay.style.transform = `translate3d(${deltaX}px, ${deltaY}px, 0px)`;
|
|
2623
3594
|
}
|
|
2624
|
-
resolveDiffUnchangedViewZoneHeight() {
|
|
2625
|
-
switch (this.resolveDiffUnchangedRegionStyleOption()) {
|
|
2626
|
-
case "line-info":
|
|
2627
|
-
case "line-info-basic":
|
|
2628
|
-
case "metadata": return 32;
|
|
2629
|
-
case "simple": return 28;
|
|
2630
|
-
default: return 32;
|
|
2631
|
-
}
|
|
2632
|
-
}
|
|
2633
|
-
collectDiffUnchangedViewZoneIds(editorRoot, scrollTop) {
|
|
2634
|
-
const widgetTopValues = Array.from(editorRoot.querySelectorAll(".diff-hidden-lines-widget")).map((node) => Number.parseFloat(node.style.top || "NaN")).filter((value) => Number.isFinite(value) && value > -1e5);
|
|
2635
|
-
if (widgetTopValues.length === 0) return [];
|
|
2636
|
-
return Array.from(editorRoot.querySelectorAll(".view-zones > div[monaco-view-zone][monaco-visible-view-zone=\"true\"]")).filter((node) => {
|
|
2637
|
-
const zoneTop = Number.parseFloat(node.style.top || "NaN");
|
|
2638
|
-
const currentHeight = Number.parseFloat(node.style.height || "0");
|
|
2639
|
-
return Number.isFinite(zoneTop) && Number.isFinite(currentHeight) && currentHeight > 0 && widgetTopValues.some((widgetTop) => Math.abs(zoneTop - scrollTop - widgetTop) < .5);
|
|
2640
|
-
}).map((node) => node.getAttribute("monaco-view-zone")).filter((value) => Boolean(value));
|
|
2641
|
-
}
|
|
2642
3595
|
syncDiffUnchangedViewZoneHeightsForEditor(editor, editorRoot, targetHeight) {
|
|
2643
3596
|
var _editor$getScrollTop, _editorInternal$_mode;
|
|
2644
3597
|
if (!editor || !(editorRoot instanceof HTMLElement)) return false;
|
|
2645
|
-
const zoneIds =
|
|
3598
|
+
const zoneIds = collectDiffUnchangedViewZoneIds(editorRoot, ((_editor$getScrollTop = editor.getScrollTop) === null || _editor$getScrollTop === void 0 ? void 0 : _editor$getScrollTop.call(editor)) ?? 0);
|
|
2646
3599
|
if (zoneIds.length === 0) return false;
|
|
2647
3600
|
const editorInternal = editor;
|
|
2648
3601
|
const zones = (_editorInternal$_mode = editorInternal._modelData) === null || _editorInternal$_mode === void 0 || (_editorInternal$_mode = _editorInternal$_mode.view) === null || _editorInternal$_mode === void 0 || (_editorInternal$_mode = _editorInternal$_mode._viewZones) === null || _editorInternal$_mode === void 0 ? void 0 : _editorInternal$_mode._zones;
|
|
@@ -2667,7 +3620,7 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2667
3620
|
syncDiffUnchangedViewZoneHeights() {
|
|
2668
3621
|
var _originalEditor$getCo, _modifiedEditor$getCo3;
|
|
2669
3622
|
if (!this.diffEditorView) return false;
|
|
2670
|
-
const targetHeight = this.
|
|
3623
|
+
const targetHeight = resolveDiffUnchangedViewZoneHeight(this.resolveDiffUnchangedRegionStyleOption());
|
|
2671
3624
|
const originalEditor = this.diffEditorView.getOriginalEditor();
|
|
2672
3625
|
const modifiedEditor = this.diffEditorView.getModifiedEditor();
|
|
2673
3626
|
const originalChanged = this.syncDiffUnchangedViewZoneHeightsForEditor(originalEditor, (_originalEditor$getCo = originalEditor.getContainerDomNode) === null || _originalEditor$getCo === void 0 ? void 0 : _originalEditor$getCo.call(originalEditor), targetHeight);
|
|
@@ -2685,19 +3638,7 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2685
3638
|
return `${this.getDiffUnchangedNodeId(secondaryNode)}:${this.getDiffUnchangedNodeId(primaryNode)}`;
|
|
2686
3639
|
}
|
|
2687
3640
|
createDiffUnchangedBridgeEntry(key) {
|
|
2688
|
-
const bridge =
|
|
2689
|
-
bridge.className = "stream-monaco-diff-unchanged-bridge";
|
|
2690
|
-
bridge.setAttribute("role", "group");
|
|
2691
|
-
bridge.hidden = true;
|
|
2692
|
-
const summary = document.createElement("button");
|
|
2693
|
-
summary.type = "button";
|
|
2694
|
-
summary.className = "stream-monaco-unchanged-summary";
|
|
2695
|
-
const visualMeta = document.createElement("div");
|
|
2696
|
-
visualMeta.className = "stream-monaco-unchanged-meta";
|
|
2697
|
-
summary.append(visualMeta);
|
|
2698
|
-
const divider = document.createElement("span");
|
|
2699
|
-
divider.className = "stream-monaco-unchanged-pane-divider";
|
|
2700
|
-
divider.setAttribute("aria-hidden", "true");
|
|
3641
|
+
const { bridge, summary, visualMeta, divider } = createDiffUnchangedBridgeScaffold();
|
|
2701
3642
|
const entry = {
|
|
2702
3643
|
key,
|
|
2703
3644
|
bridge,
|
|
@@ -2716,16 +3657,15 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2716
3657
|
const onWheel = (event) => {
|
|
2717
3658
|
var _modifiedEditor$getSc8, _modifiedEditor$getSc9, _originalEditor$setSc6, _modifiedEditor$setSc6;
|
|
2718
3659
|
if (!this.diffEditorView) return;
|
|
2719
|
-
if (
|
|
3660
|
+
if (!shouldHandleDiffUnchangedWheel(event)) return;
|
|
2720
3661
|
event.preventDefault();
|
|
2721
3662
|
event.stopPropagation();
|
|
2722
3663
|
const originalEditor = this.diffEditorView.getOriginalEditor();
|
|
2723
3664
|
const modifiedEditor = this.diffEditorView.getModifiedEditor();
|
|
2724
|
-
const targetScrollTop = (((_modifiedEditor$getSc8 = modifiedEditor.getScrollTop) === null || _modifiedEditor$getSc8 === void 0 ? void 0 : _modifiedEditor$getSc8.call(modifiedEditor)) ?? 0)
|
|
2725
|
-
const targetScrollLeft = (((_modifiedEditor$getSc9 = modifiedEditor.getScrollLeft) === null || _modifiedEditor$getSc9 === void 0 ? void 0 : _modifiedEditor$getSc9.call(modifiedEditor)) ?? 0) + event.deltaX;
|
|
3665
|
+
const { syncHorizontal, targetScrollLeft, targetScrollTop } = resolveDiffUnchangedWheelScrollTarget(((_modifiedEditor$getSc8 = modifiedEditor.getScrollTop) === null || _modifiedEditor$getSc8 === void 0 ? void 0 : _modifiedEditor$getSc8.call(modifiedEditor)) ?? 0, ((_modifiedEditor$getSc9 = modifiedEditor.getScrollLeft) === null || _modifiedEditor$getSc9 === void 0 ? void 0 : _modifiedEditor$getSc9.call(modifiedEditor)) ?? 0, event);
|
|
2726
3666
|
(_originalEditor$setSc6 = originalEditor.setScrollTop) === null || _originalEditor$setSc6 === void 0 || _originalEditor$setSc6.call(originalEditor, targetScrollTop);
|
|
2727
3667
|
(_modifiedEditor$setSc6 = modifiedEditor.setScrollTop) === null || _modifiedEditor$setSc6 === void 0 || _modifiedEditor$setSc6.call(modifiedEditor, targetScrollTop);
|
|
2728
|
-
if (
|
|
3668
|
+
if (syncHorizontal) {
|
|
2729
3669
|
var _originalEditor$setSc7, _modifiedEditor$setSc7;
|
|
2730
3670
|
(_originalEditor$setSc7 = originalEditor.setScrollLeft) === null || _originalEditor$setSc7 === void 0 || _originalEditor$setSc7.call(originalEditor, targetScrollLeft);
|
|
2731
3671
|
(_modifiedEditor$setSc7 = modifiedEditor.setScrollLeft) === null || _modifiedEditor$setSc7 === void 0 || _modifiedEditor$setSc7.call(modifiedEditor, targetScrollLeft);
|
|
@@ -2734,7 +3674,6 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2734
3674
|
};
|
|
2735
3675
|
bridge.addEventListener("wheel", onWheel, { passive: false });
|
|
2736
3676
|
this.diffUnchangedRegionDisposables.push({ dispose: () => bridge.removeEventListener("wheel", onWheel) });
|
|
2737
|
-
bridge.append(summary, divider);
|
|
2738
3677
|
return entry;
|
|
2739
3678
|
}
|
|
2740
3679
|
acquireDiffUnchangedBridgeEntry(key) {
|
|
@@ -2742,16 +3681,14 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2742
3681
|
if (existing) return existing;
|
|
2743
3682
|
const entry = this.diffUnchangedBridgePool.pop() ?? this.createDiffUnchangedBridgeEntry(key);
|
|
2744
3683
|
entry.key = key;
|
|
2745
|
-
entry.bridge
|
|
2746
|
-
entry.bridge.removeAttribute("aria-hidden");
|
|
3684
|
+
syncDiffUnchangedBridgeVisibility(entry.bridge, true);
|
|
2747
3685
|
this.diffUnchangedBridgeEntries.set(key, entry);
|
|
2748
3686
|
return entry;
|
|
2749
3687
|
}
|
|
2750
3688
|
releaseDiffUnchangedBridgeEntry(entry) {
|
|
2751
3689
|
if (entry.key) this.diffUnchangedBridgeEntries.delete(entry.key);
|
|
2752
3690
|
entry.key = null;
|
|
2753
|
-
entry.bridge
|
|
2754
|
-
entry.bridge.setAttribute("aria-hidden", "true");
|
|
3691
|
+
syncDiffUnchangedBridgeVisibility(entry.bridge, false);
|
|
2755
3692
|
this.diffUnchangedBridgePool.push(entry);
|
|
2756
3693
|
}
|
|
2757
3694
|
hideAllDiffUnchangedBridgeEntries() {
|
|
@@ -2777,51 +3714,15 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2777
3714
|
entry.activate();
|
|
2778
3715
|
this.schedulePatchDiffUnchangedRegionsAfterInteraction();
|
|
2779
3716
|
}
|
|
2780
|
-
updateDiffUnchangedBridgeMeta(entry, unchangedRegionStyle, summaryLabel) {
|
|
2781
|
-
this.updateDiffUnchangedMetaNode(entry.visualMeta, unchangedRegionStyle, summaryLabel);
|
|
2782
|
-
}
|
|
2783
|
-
updateDiffUnchangedMetaNode(metaNode, unchangedRegionStyle, summaryLabel) {
|
|
2784
|
-
const lastStyle = metaNode.dataset.style;
|
|
2785
|
-
const lastLabel = metaNode.dataset.label;
|
|
2786
|
-
if (lastStyle === unchangedRegionStyle && lastLabel === summaryLabel) return;
|
|
2787
|
-
metaNode.dataset.style = unchangedRegionStyle;
|
|
2788
|
-
metaNode.dataset.label = summaryLabel;
|
|
2789
|
-
metaNode.replaceChildren();
|
|
2790
|
-
metaNode.classList.toggle("stream-monaco-unchanged-meta-simple", unchangedRegionStyle === "simple");
|
|
2791
|
-
if (unchangedRegionStyle === "simple") {
|
|
2792
|
-
const simpleBar = document.createElement("span");
|
|
2793
|
-
simpleBar.className = "stream-monaco-unchanged-simple-bar";
|
|
2794
|
-
simpleBar.setAttribute("aria-hidden", "true");
|
|
2795
|
-
metaNode.append(simpleBar);
|
|
2796
|
-
return;
|
|
2797
|
-
}
|
|
2798
|
-
const label = document.createElement("span");
|
|
2799
|
-
if (unchangedRegionStyle === "metadata") label.className = "stream-monaco-unchanged-metadata-label";
|
|
2800
|
-
else label.className = "stream-monaco-unchanged-count";
|
|
2801
|
-
label.textContent = summaryLabel;
|
|
2802
|
-
metaNode.append(label);
|
|
2803
|
-
}
|
|
2804
3717
|
syncDiffUnchangedRevealButton(entry, slot, handle, direction, label) {
|
|
2805
3718
|
const existingButton = entry[slot];
|
|
2806
|
-
const button = existingButton ??
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
button.className = "stream-monaco-unchanged-reveal";
|
|
2810
|
-
button.innerHTML = `<span class="codicon codicon-chevron-${direction}"></span>`;
|
|
2811
|
-
}
|
|
2812
|
-
button.dataset.direction = direction;
|
|
2813
|
-
button.hidden = !handle;
|
|
2814
|
-
button.disabled = !handle;
|
|
2815
|
-
button.toggleAttribute("aria-hidden", !handle);
|
|
2816
|
-
button.title = handle ? label : "";
|
|
2817
|
-
button.setAttribute("aria-label", handle ? label : "");
|
|
2818
|
-
button.onclick = handle ? (event) => {
|
|
2819
|
-
event.preventDefault();
|
|
2820
|
-
event.stopPropagation();
|
|
3719
|
+
const button = existingButton ?? createDiffUnchangedRevealButton(direction);
|
|
3720
|
+
syncDiffUnchangedRevealButtonNode(button, handle, label);
|
|
3721
|
+
bindDiffUnchangedRevealButtonAction(button, handle, (nextHandle) => {
|
|
2821
3722
|
this.hideAllDiffUnchangedBridgeEntries();
|
|
2822
|
-
this.activateDiffUnchangedHandle(
|
|
3723
|
+
this.activateDiffUnchangedHandle(nextHandle);
|
|
2823
3724
|
this.schedulePatchDiffUnchangedRegionsAfterInteraction();
|
|
2824
|
-
}
|
|
3725
|
+
});
|
|
2825
3726
|
entry[slot] = button;
|
|
2826
3727
|
}
|
|
2827
3728
|
syncDiffUnchangedBridgeRail(entry, showTopHandle, topHandle, showBottomHandle, bottomHandle) {
|
|
@@ -2829,14 +3730,9 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2829
3730
|
entry.rail = document.createElement("div");
|
|
2830
3731
|
entry.rail.className = "stream-monaco-unchanged-rail";
|
|
2831
3732
|
}
|
|
2832
|
-
const shouldRenderRail = showTopHandle || showBottomHandle;
|
|
2833
3733
|
this.syncDiffUnchangedRevealButton(entry, "topButton", showTopHandle ? topHandle : null, "down", "Reveal more unmodified lines below");
|
|
2834
3734
|
this.syncDiffUnchangedRevealButton(entry, "bottomButton", showBottomHandle ? bottomHandle : null, "up", "Reveal more unmodified lines above");
|
|
2835
|
-
entry.rail
|
|
2836
|
-
entry.rail.toggleAttribute("aria-hidden", !shouldRenderRail);
|
|
2837
|
-
entry.rail.classList.toggle("stream-monaco-unchanged-rail-top-only", showTopHandle && !showBottomHandle);
|
|
2838
|
-
entry.rail.classList.toggle("stream-monaco-unchanged-rail-bottom-only", !showTopHandle && showBottomHandle);
|
|
2839
|
-
entry.rail.classList.toggle("stream-monaco-unchanged-rail-both", showTopHandle && showBottomHandle);
|
|
3735
|
+
syncDiffUnchangedRailNode(entry.rail, showTopHandle, showBottomHandle);
|
|
2840
3736
|
if (entry.topButton && entry.topButton.parentElement !== entry.rail) entry.rail.append(entry.topButton);
|
|
2841
3737
|
if (entry.bottomButton && entry.bottomButton.parentElement !== entry.rail) entry.rail.append(entry.bottomButton);
|
|
2842
3738
|
}
|
|
@@ -2846,203 +3742,53 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
2846
3742
|
this.releaseDiffUnchangedBridgeEntry(entry);
|
|
2847
3743
|
}
|
|
2848
3744
|
}
|
|
2849
|
-
dispatchSyntheticMouseDown(node) {
|
|
2850
|
-
const view = node.ownerDocument.defaultView;
|
|
2851
|
-
if (!view) return;
|
|
2852
|
-
const rect = node.getBoundingClientRect();
|
|
2853
|
-
node.dispatchEvent(new view.MouseEvent("mousedown", {
|
|
2854
|
-
bubbles: true,
|
|
2855
|
-
cancelable: true,
|
|
2856
|
-
button: 0,
|
|
2857
|
-
clientX: rect.left + rect.width / 2,
|
|
2858
|
-
clientY: rect.top + rect.height / 2
|
|
2859
|
-
}));
|
|
2860
|
-
}
|
|
2861
|
-
dispatchSyntheticMouseTap(node) {
|
|
2862
|
-
const view = node.ownerDocument.defaultView;
|
|
2863
|
-
if (!view) return;
|
|
2864
|
-
const rect = node.getBoundingClientRect();
|
|
2865
|
-
const clientX = rect.left + rect.width / 2;
|
|
2866
|
-
const clientY = rect.top + rect.height / 2;
|
|
2867
|
-
node.dispatchEvent(new view.MouseEvent("mousedown", {
|
|
2868
|
-
bubbles: true,
|
|
2869
|
-
cancelable: true,
|
|
2870
|
-
button: 0,
|
|
2871
|
-
clientX,
|
|
2872
|
-
clientY
|
|
2873
|
-
}));
|
|
2874
|
-
node.dispatchEvent(new view.MouseEvent("mouseup", {
|
|
2875
|
-
bubbles: true,
|
|
2876
|
-
cancelable: true,
|
|
2877
|
-
button: 0,
|
|
2878
|
-
clientX,
|
|
2879
|
-
clientY
|
|
2880
|
-
}));
|
|
2881
|
-
}
|
|
2882
|
-
formatDiffUnchangedCountLabel(text) {
|
|
2883
|
-
const match = text.match(/\d+/);
|
|
2884
|
-
const count = match ? Number.parseInt(match[0], 10) : NaN;
|
|
2885
|
-
if (Number.isFinite(count)) return `${count} unmodified ${count === 1 ? "line" : "lines"}`;
|
|
2886
|
-
return text.replace(/hidden/gi, "unmodified");
|
|
2887
|
-
}
|
|
2888
|
-
countDiffLines(startLineNumber, endLineNumber) {
|
|
2889
|
-
return endLineNumber >= startLineNumber ? endLineNumber - startLineNumber + 1 : 0;
|
|
2890
|
-
}
|
|
2891
|
-
measureDiffUnchangedSurroundingLines(primaryNode) {
|
|
2892
|
-
const editorRoot = primaryNode.closest(".editor.modified") ?? primaryNode.closest(".monaco-editor");
|
|
2893
|
-
if (!editorRoot) return {
|
|
2894
|
-
previousVisibleLine: null,
|
|
2895
|
-
nextVisibleLine: null
|
|
2896
|
-
};
|
|
2897
|
-
const widgetRect = primaryNode.getBoundingClientRect();
|
|
2898
|
-
let previousVisibleLine = null;
|
|
2899
|
-
let nextVisibleLine = null;
|
|
2900
|
-
const lineNumberNodes = editorRoot.querySelectorAll(".line-numbers");
|
|
2901
|
-
lineNumberNodes.forEach((node) => {
|
|
2902
|
-
var _node$textContent3;
|
|
2903
|
-
const lineNumber = Number.parseInt(((_node$textContent3 = node.textContent) === null || _node$textContent3 === void 0 ? void 0 : _node$textContent3.trim()) || "", 10);
|
|
2904
|
-
if (!Number.isFinite(lineNumber)) return;
|
|
2905
|
-
const top = node.getBoundingClientRect().top;
|
|
2906
|
-
if (top < widgetRect.top - 1) previousVisibleLine = previousVisibleLine == null ? lineNumber : Math.max(previousVisibleLine, lineNumber);
|
|
2907
|
-
else if (top > widgetRect.bottom + 1) nextVisibleLine = nextVisibleLine == null ? lineNumber : Math.min(nextVisibleLine, lineNumber);
|
|
2908
|
-
});
|
|
2909
|
-
return {
|
|
2910
|
-
previousVisibleLine,
|
|
2911
|
-
nextVisibleLine
|
|
2912
|
-
};
|
|
2913
|
-
}
|
|
2914
|
-
formatDiffMetadataRange(startLineNumber, lineCount) {
|
|
2915
|
-
return `${startLineNumber},${Math.max(0, lineCount)}`;
|
|
2916
|
-
}
|
|
2917
|
-
buildDiffHunkMetadataLabel(change) {
|
|
2918
|
-
var _this$originalModel, _this$modifiedModel2;
|
|
2919
|
-
const contextLineCount = this.resolveDiffHideUnchangedRegionsOption().contextLineCount ?? 3;
|
|
2920
|
-
const originalTotalLines = ((_this$originalModel = this.originalModel) === null || _this$originalModel === void 0 ? void 0 : _this$originalModel.getLineCount()) ?? 0;
|
|
2921
|
-
const modifiedTotalLines = ((_this$modifiedModel2 = this.modifiedModel) === null || _this$modifiedModel2 === void 0 ? void 0 : _this$modifiedModel2.getLineCount()) ?? 0;
|
|
2922
|
-
const originalChangedCount = this.countDiffLines(change.originalStartLineNumber, change.originalEndLineNumber);
|
|
2923
|
-
const modifiedChangedCount = this.countDiffLines(change.modifiedStartLineNumber, change.modifiedEndLineNumber);
|
|
2924
|
-
const originalAnchor = Math.min(Math.max(change.originalStartLineNumber, 1), Math.max(1, originalTotalLines + 1));
|
|
2925
|
-
const modifiedAnchor = Math.min(Math.max(change.modifiedStartLineNumber, 1), Math.max(1, modifiedTotalLines + 1));
|
|
2926
|
-
const originalStart = Math.max(1, originalAnchor - contextLineCount);
|
|
2927
|
-
const modifiedStart = Math.max(1, modifiedAnchor - contextLineCount);
|
|
2928
|
-
const originalEnd = originalChangedCount > 0 ? Math.min(originalTotalLines, change.originalEndLineNumber + contextLineCount) : Math.min(originalTotalLines, originalAnchor + contextLineCount - 1);
|
|
2929
|
-
const modifiedEnd = modifiedChangedCount > 0 ? Math.min(modifiedTotalLines, change.modifiedEndLineNumber + contextLineCount) : Math.min(modifiedTotalLines, modifiedAnchor + contextLineCount - 1);
|
|
2930
|
-
const originalDisplayCount = originalEnd >= originalStart ? originalEnd - originalStart + 1 : 0;
|
|
2931
|
-
const modifiedDisplayCount = modifiedEnd >= modifiedStart ? modifiedEnd - modifiedStart + 1 : 0;
|
|
2932
|
-
return {
|
|
2933
|
-
modifiedStart,
|
|
2934
|
-
originalStart,
|
|
2935
|
-
label: `@@ -${this.formatDiffMetadataRange(originalStart, originalDisplayCount)} +${this.formatDiffMetadataRange(modifiedStart, modifiedDisplayCount)} @@`
|
|
2936
|
-
};
|
|
2937
|
-
}
|
|
2938
|
-
resolveDiffMetadataLabel(primaryNode, pairIndex) {
|
|
2939
|
-
var _metadataEntries$Math;
|
|
2940
|
-
const lineChanges = this.getEffectiveLineChanges();
|
|
2941
|
-
if (lineChanges.length === 0) return null;
|
|
2942
|
-
const metadataEntries = lineChanges.map((change) => this.buildDiffHunkMetadataLabel(change));
|
|
2943
|
-
const { nextVisibleLine } = this.measureDiffUnchangedSurroundingLines(primaryNode);
|
|
2944
|
-
if (nextVisibleLine != null) {
|
|
2945
|
-
const candidateStarts = [nextVisibleLine, nextVisibleLine - 1].filter((value) => value >= 1);
|
|
2946
|
-
for (const candidateStart of candidateStarts) {
|
|
2947
|
-
const matching = metadataEntries.find((entry) => entry.modifiedStart === candidateStart);
|
|
2948
|
-
if (matching) return matching.label;
|
|
2949
|
-
}
|
|
2950
|
-
}
|
|
2951
|
-
return ((_metadataEntries$Math = metadataEntries[Math.min(pairIndex, metadataEntries.length - 1)]) === null || _metadataEntries$Math === void 0 ? void 0 : _metadataEntries$Math.label) ?? null;
|
|
2952
|
-
}
|
|
2953
3745
|
activateDiffUnchangedHandle(node) {
|
|
2954
3746
|
if (!(node instanceof HTMLElement)) return;
|
|
2955
|
-
|
|
3747
|
+
dispatchSyntheticPrimaryMouseTap(node);
|
|
2956
3748
|
this.scheduleCapturePersistedDiffUnchangedState(1);
|
|
2957
3749
|
}
|
|
2958
|
-
resolveDiffUnchangedRevealLayout(primaryNode, countText, pairIndex, pairCount) {
|
|
2959
|
-
var _this$diffEditorView17, _this$diffEditorView18;
|
|
2960
|
-
let showTopHandle = pairCount === 1 || pairIndex > 0;
|
|
2961
|
-
let showBottomHandle = pairCount === 1 || pairIndex < pairCount - 1;
|
|
2962
|
-
const countMatch = countText.match(/\d+/);
|
|
2963
|
-
const hiddenCount = countMatch ? Number.parseInt(countMatch[0], 10) : NaN;
|
|
2964
|
-
if (!Number.isFinite(hiddenCount)) return {
|
|
2965
|
-
showTopHandle,
|
|
2966
|
-
showBottomHandle
|
|
2967
|
-
};
|
|
2968
|
-
const { previousVisibleLine, nextVisibleLine } = this.measureDiffUnchangedSurroundingLines(primaryNode);
|
|
2969
|
-
if (previousVisibleLine == null && nextVisibleLine != null) {
|
|
2970
|
-
showTopHandle = false;
|
|
2971
|
-
showBottomHandle = true;
|
|
2972
|
-
return {
|
|
2973
|
-
showTopHandle,
|
|
2974
|
-
showBottomHandle
|
|
2975
|
-
};
|
|
2976
|
-
}
|
|
2977
|
-
if (nextVisibleLine == null && previousVisibleLine != null) {
|
|
2978
|
-
showTopHandle = true;
|
|
2979
|
-
showBottomHandle = false;
|
|
2980
|
-
return {
|
|
2981
|
-
showTopHandle,
|
|
2982
|
-
showBottomHandle
|
|
2983
|
-
};
|
|
2984
|
-
}
|
|
2985
|
-
if (nextVisibleLine != null && nextVisibleLine - hiddenCount === 1) {
|
|
2986
|
-
showTopHandle = false;
|
|
2987
|
-
showBottomHandle = true;
|
|
2988
|
-
}
|
|
2989
|
-
const modelLineCount = ((_this$diffEditorView17 = this.diffEditorView) === null || _this$diffEditorView17 === void 0 || (_this$diffEditorView17 = _this$diffEditorView17.getModifiedEditor().getModel()) === null || _this$diffEditorView17 === void 0 || (_this$diffEditorView18 = _this$diffEditorView17.getLineCount) === null || _this$diffEditorView18 === void 0 ? void 0 : _this$diffEditorView18.call(_this$diffEditorView17)) ?? null;
|
|
2990
|
-
if (previousVisibleLine != null && modelLineCount != null && previousVisibleLine + hiddenCount === modelLineCount) {
|
|
2991
|
-
showTopHandle = true;
|
|
2992
|
-
showBottomHandle = false;
|
|
2993
|
-
}
|
|
2994
|
-
return {
|
|
2995
|
-
showTopHandle,
|
|
2996
|
-
showBottomHandle
|
|
2997
|
-
};
|
|
2998
|
-
}
|
|
2999
|
-
resolveDiffUnchangedMergeRole(node) {
|
|
3000
|
-
var _this$diffEditorView19, _this$diffEditorView20, _this$diffEditorView21, _this$diffEditorView22, _this$diffEditorView23, _this$diffEditorView24;
|
|
3001
|
-
const diffRoot = node.closest(".monaco-diff-editor.side-by-side");
|
|
3002
|
-
if (!(diffRoot instanceof HTMLElement)) return "none";
|
|
3003
|
-
const nodeRect = node.getBoundingClientRect();
|
|
3004
|
-
const nodeCenter = nodeRect.left + nodeRect.width / 2;
|
|
3005
|
-
const originalHost = (_this$diffEditorView19 = this.diffEditorView) === null || _this$diffEditorView19 === void 0 || (_this$diffEditorView21 = (_this$diffEditorView20 = _this$diffEditorView19.getOriginalEditor()).getContainerDomNode) === null || _this$diffEditorView21 === void 0 ? void 0 : _this$diffEditorView21.call(_this$diffEditorView20);
|
|
3006
|
-
const modifiedHost = (_this$diffEditorView22 = this.diffEditorView) === null || _this$diffEditorView22 === void 0 || (_this$diffEditorView24 = (_this$diffEditorView23 = _this$diffEditorView22.getModifiedEditor()).getContainerDomNode) === null || _this$diffEditorView24 === void 0 ? void 0 : _this$diffEditorView24.call(_this$diffEditorView23);
|
|
3007
|
-
if (originalHost instanceof HTMLElement && modifiedHost instanceof HTMLElement) {
|
|
3008
|
-
const originalRect = originalHost.getBoundingClientRect();
|
|
3009
|
-
const modifiedRect = modifiedHost.getBoundingClientRect();
|
|
3010
|
-
const originalCenter = originalRect.left + originalRect.width / 2;
|
|
3011
|
-
const modifiedCenter = modifiedRect.left + modifiedRect.width / 2;
|
|
3012
|
-
return Math.abs(nodeCenter - originalCenter) <= Math.abs(nodeCenter - modifiedCenter) ? "secondary" : "primary";
|
|
3013
|
-
}
|
|
3014
|
-
const diffRect = diffRoot.getBoundingClientRect();
|
|
3015
|
-
return nodeCenter < diffRect.left + diffRect.width / 2 ? "secondary" : "primary";
|
|
3016
|
-
}
|
|
3017
3750
|
patchDiffUnchangedCenter(node, pairIndex = 0) {
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3751
|
+
var _this$diffEditorView8, _this$diffEditorView9, _this$diffEditorView10, _this$diffEditorView11, _this$diffEditorView12, _this$diffEditorView13;
|
|
3752
|
+
const mergeRole = resolveDiffUnchangedMergeRole({
|
|
3753
|
+
node,
|
|
3754
|
+
diffRoot: node.closest(".monaco-diff-editor.side-by-side"),
|
|
3755
|
+
originalHost: (_this$diffEditorView8 = this.diffEditorView) === null || _this$diffEditorView8 === void 0 || (_this$diffEditorView10 = (_this$diffEditorView9 = _this$diffEditorView8.getOriginalEditor()).getContainerDomNode) === null || _this$diffEditorView10 === void 0 ? void 0 : _this$diffEditorView10.call(_this$diffEditorView9),
|
|
3756
|
+
modifiedHost: (_this$diffEditorView11 = this.diffEditorView) === null || _this$diffEditorView11 === void 0 || (_this$diffEditorView13 = (_this$diffEditorView12 = _this$diffEditorView11.getModifiedEditor()).getContainerDomNode) === null || _this$diffEditorView13 === void 0 ? void 0 : _this$diffEditorView13.call(_this$diffEditorView12)
|
|
3757
|
+
});
|
|
3021
3758
|
const shouldUseMergedSecondary = mergeRole === "secondary";
|
|
3022
3759
|
const unchangedRegionStyle = this.resolveDiffUnchangedRegionStyleOption();
|
|
3023
|
-
node
|
|
3024
|
-
node.classList.toggle("stream-monaco-unchanged-merged-primary", mergeRole === "primary");
|
|
3760
|
+
syncDiffUnchangedCenterNode(node, mergeRole);
|
|
3025
3761
|
const primary = node.children.item(0);
|
|
3026
3762
|
const meta = node.children.item(1);
|
|
3027
3763
|
if (primary instanceof HTMLElement) primary.classList.add("stream-monaco-unchanged-primary");
|
|
3028
3764
|
if (meta instanceof HTMLElement) {
|
|
3029
|
-
var _countSource$textCont;
|
|
3765
|
+
var _countSource$textCont, _this$originalModel, _this$modifiedModel2;
|
|
3030
3766
|
meta.classList.add("stream-monaco-unchanged-meta");
|
|
3031
3767
|
const countSource = meta.querySelector(".count") ?? meta.firstElementChild;
|
|
3032
|
-
const countText =
|
|
3033
|
-
const
|
|
3034
|
-
|
|
3768
|
+
const countText = formatDiffUnchangedCountLabel((countSource === null || countSource === void 0 || (_countSource$textCont = countSource.textContent) === null || _countSource$textCont === void 0 ? void 0 : _countSource$textCont.trim()) || "Unmodified lines");
|
|
3769
|
+
const contextLineCount = this.resolveDiffHideUnchangedRegionsOption().contextLineCount ?? 3;
|
|
3770
|
+
const summaryLabel = resolveDiffUnchangedSummaryLabel({
|
|
3771
|
+
countText,
|
|
3772
|
+
unchangedRegionStyle,
|
|
3773
|
+
lineChanges: this.getEffectiveLineChanges(),
|
|
3774
|
+
pairIndex,
|
|
3775
|
+
primaryNode: node,
|
|
3776
|
+
contextLineCount,
|
|
3777
|
+
originalTotalLines: ((_this$originalModel = this.originalModel) === null || _this$originalModel === void 0 ? void 0 : _this$originalModel.getLineCount()) ?? 0,
|
|
3778
|
+
modifiedTotalLines: ((_this$modifiedModel2 = this.modifiedModel) === null || _this$modifiedModel2 === void 0 ? void 0 : _this$modifiedModel2.getLineCount()) ?? 0
|
|
3779
|
+
});
|
|
3780
|
+
syncDiffUnchangedMetaNode(meta, unchangedRegionStyle, summaryLabel);
|
|
3035
3781
|
}
|
|
3036
|
-
const action = node
|
|
3782
|
+
const action = findDiffUnchangedExpandAction(node);
|
|
3037
3783
|
if (action instanceof HTMLElement) {
|
|
3038
|
-
action
|
|
3039
|
-
action.dataset.streamMonacoLabel = "Expand all";
|
|
3040
|
-
action.title = "Expand all unmodified lines";
|
|
3041
|
-
action.setAttribute("aria-label", "Expand all unmodified lines");
|
|
3042
|
-
action.toggleAttribute("aria-hidden", shouldUseMergedSecondary);
|
|
3043
|
-
action.tabIndex = shouldUseMergedSecondary ? -1 : 0;
|
|
3784
|
+
syncDiffUnchangedExpandAction(action, shouldUseMergedSecondary);
|
|
3044
3785
|
if (action.dataset.streamMonacoExpandPatched !== "true") {
|
|
3045
3786
|
action.dataset.streamMonacoExpandPatched = "true";
|
|
3787
|
+
const handleCaptureExpand = () => {
|
|
3788
|
+
this.capturePreviousDiffUnchangedState();
|
|
3789
|
+
};
|
|
3790
|
+
action.addEventListener("click", handleCaptureExpand, { capture: true });
|
|
3791
|
+
this.diffUnchangedRegionDisposables.push({ dispose: () => action.removeEventListener("click", handleCaptureExpand, true) });
|
|
3046
3792
|
this.createDomDisposable(this.diffUnchangedRegionDisposables, action, "click", () => {
|
|
3047
3793
|
this.hideAllDiffUnchangedBridgeEntries();
|
|
3048
3794
|
this.scheduleCapturePersistedDiffUnchangedState(1);
|
|
@@ -3053,25 +3799,21 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3053
3799
|
if (node.dataset.streamMonacoCenterPatched !== "true") {
|
|
3054
3800
|
node.dataset.streamMonacoCenterPatched = "true";
|
|
3055
3801
|
this.bindFocusWithinClass(this.diffUnchangedRegionDisposables, node, "stream-monaco-focus-within");
|
|
3056
|
-
const activate = () => {
|
|
3057
|
-
const action$1 = node.querySelector("a");
|
|
3058
|
-
if (action$1 instanceof HTMLElement) action$1.click();
|
|
3059
|
-
};
|
|
3060
3802
|
this.createDomDisposable(this.diffUnchangedRegionDisposables, node, "click", (event) => {
|
|
3061
3803
|
const mouseEvent = event;
|
|
3062
|
-
if (mouseEvent
|
|
3063
|
-
const target = event.target instanceof HTMLElement ? event.target : null;
|
|
3064
|
-
if (target === null || target === void 0 ? void 0 : target.closest("a, .breadcrumb-item")) return;
|
|
3804
|
+
if (!shouldHandleDiffUnchangedCenterClick(mouseEvent)) return;
|
|
3065
3805
|
event.preventDefault();
|
|
3066
3806
|
this.hideAllDiffUnchangedBridgeEntries();
|
|
3067
|
-
|
|
3807
|
+
if (!activateDiffUnchangedExpandAction(node, () => {
|
|
3808
|
+
this.capturePreviousDiffUnchangedState();
|
|
3809
|
+
})) return;
|
|
3068
3810
|
this.scheduleCapturePersistedDiffUnchangedState(1);
|
|
3069
3811
|
this.schedulePatchDiffUnchangedRegionsAfterInteraction();
|
|
3070
3812
|
});
|
|
3071
3813
|
}
|
|
3072
3814
|
}
|
|
3073
3815
|
renderMergedDiffUnchangedBridge(secondaryNode, primaryNode, pairIndex, pairCount) {
|
|
3074
|
-
var _countSource$textCont2, _secondaryNode$closes;
|
|
3816
|
+
var _countSource$textCont2, _this$originalModel2, _this$modifiedModel3, _this$diffEditorView14, _this$diffEditorView15, _secondaryNode$closes;
|
|
3075
3817
|
if (!this.lastContainer) return null;
|
|
3076
3818
|
const overlay = this.ensureDiffUnchangedBridgeOverlay();
|
|
3077
3819
|
if (!overlay) return null;
|
|
@@ -3080,9 +3822,19 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3080
3822
|
const primaryRect = primaryNode.getBoundingClientRect();
|
|
3081
3823
|
const primaryStyle = globalThis.getComputedStyle(primaryNode);
|
|
3082
3824
|
const countSource = primaryNode.querySelector(".stream-monaco-unchanged-count") ?? secondaryNode.querySelector(".stream-monaco-unchanged-count");
|
|
3083
|
-
const countText =
|
|
3825
|
+
const countText = formatDiffUnchangedCountLabel((countSource === null || countSource === void 0 || (_countSource$textCont2 = countSource.textContent) === null || _countSource$textCont2 === void 0 ? void 0 : _countSource$textCont2.trim()) || "Unmodified lines");
|
|
3084
3826
|
const unchangedRegionStyle = this.resolveDiffUnchangedRegionStyleOption();
|
|
3085
|
-
const
|
|
3827
|
+
const contextLineCount = this.resolveDiffHideUnchangedRegionsOption().contextLineCount ?? 3;
|
|
3828
|
+
const summaryLabel = resolveDiffUnchangedSummaryLabel({
|
|
3829
|
+
countText,
|
|
3830
|
+
unchangedRegionStyle,
|
|
3831
|
+
lineChanges: this.getEffectiveLineChanges(),
|
|
3832
|
+
pairIndex,
|
|
3833
|
+
primaryNode,
|
|
3834
|
+
contextLineCount,
|
|
3835
|
+
originalTotalLines: ((_this$originalModel2 = this.originalModel) === null || _this$originalModel2 === void 0 ? void 0 : _this$originalModel2.getLineCount()) ?? 0,
|
|
3836
|
+
modifiedTotalLines: ((_this$modifiedModel3 = this.modifiedModel) === null || _this$modifiedModel3 === void 0 ? void 0 : _this$modifiedModel3.getLineCount()) ?? 0
|
|
3837
|
+
});
|
|
3086
3838
|
const editorSurface = primaryNode.closest(".monaco-editor") ?? primaryNode;
|
|
3087
3839
|
const editorSurfaceStyle = globalThis.getComputedStyle(editorSurface);
|
|
3088
3840
|
const primaryHidden = primaryNode.parentElement;
|
|
@@ -3091,7 +3843,13 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3091
3843
|
const secondaryWidget = secondaryHidden === null || secondaryHidden === void 0 ? void 0 : secondaryHidden.parentElement;
|
|
3092
3844
|
const topHandle = (primaryHidden === null || primaryHidden === void 0 ? void 0 : primaryHidden.querySelector(".top")) ?? (secondaryHidden === null || secondaryHidden === void 0 ? void 0 : secondaryHidden.querySelector(".top"));
|
|
3093
3845
|
const bottomHandle = (primaryHidden === null || primaryHidden === void 0 ? void 0 : primaryHidden.querySelector(".bottom")) ?? (secondaryHidden === null || secondaryHidden === void 0 ? void 0 : secondaryHidden.querySelector(".bottom"));
|
|
3094
|
-
const { showTopHandle, showBottomHandle } =
|
|
3846
|
+
const { showTopHandle, showBottomHandle } = resolveDiffUnchangedRevealLayout({
|
|
3847
|
+
primaryNode,
|
|
3848
|
+
countText,
|
|
3849
|
+
pairIndex,
|
|
3850
|
+
pairCount,
|
|
3851
|
+
modelLineCount: ((_this$diffEditorView14 = this.diffEditorView) === null || _this$diffEditorView14 === void 0 || (_this$diffEditorView14 = _this$diffEditorView14.getModifiedEditor().getModel()) === null || _this$diffEditorView14 === void 0 || (_this$diffEditorView15 = _this$diffEditorView14.getLineCount) === null || _this$diffEditorView15 === void 0 ? void 0 : _this$diffEditorView15.call(_this$diffEditorView14)) ?? null
|
|
3852
|
+
});
|
|
3095
3853
|
const key = this.getDiffUnchangedBridgeKey(secondaryNode, primaryNode);
|
|
3096
3854
|
secondaryNode.classList.add("stream-monaco-unchanged-bridge-source");
|
|
3097
3855
|
primaryNode.classList.add("stream-monaco-unchanged-bridge-source");
|
|
@@ -3103,42 +3861,24 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3103
3861
|
const primaryAnchorRect = (primaryWidget === null || primaryWidget === void 0 ? void 0 : primaryWidget.getBoundingClientRect()) ?? primaryRect;
|
|
3104
3862
|
const secondaryMargin = (_secondaryNode$closes = secondaryNode.closest(".monaco-editor")) === null || _secondaryNode$closes === void 0 ? void 0 : _secondaryNode$closes.querySelector(".margin");
|
|
3105
3863
|
const secondaryMarginRect = secondaryMargin === null || secondaryMargin === void 0 ? void 0 : secondaryMargin.getBoundingClientRect();
|
|
3106
|
-
const lineInfoRailMetrics = unchangedRegionStyle === "line-info" ?
|
|
3864
|
+
const lineInfoRailMetrics = unchangedRegionStyle === "line-info" ? resolveDiffUnchangedLineInfoRailMetrics(secondaryNode) : null;
|
|
3107
3865
|
const bridgeLeftInset = (lineInfoRailMetrics === null || lineInfoRailMetrics === void 0 ? void 0 : lineInfoRailMetrics.leftInset) ?? 0;
|
|
3108
3866
|
const bridgeRailWidth = (lineInfoRailMetrics === null || lineInfoRailMetrics === void 0 ? void 0 : lineInfoRailMetrics.width) ?? (secondaryMarginRect === null || secondaryMarginRect === void 0 ? void 0 : secondaryMarginRect.width) ?? null;
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
const summaryLabel = metadataLabel || countText;
|
|
3125
|
-
const summaryInteractive = unchangedRegionStyle === "line-info" || unchangedRegionStyle === "line-info-basic";
|
|
3126
|
-
summary.disabled = !summaryInteractive;
|
|
3127
|
-
summary.tabIndex = summaryInteractive ? 0 : -1;
|
|
3128
|
-
if (summaryInteractive) {
|
|
3129
|
-
summary.removeAttribute("aria-hidden");
|
|
3130
|
-
summary.setAttribute("aria-label", `${summaryLabel}. Expand all unmodified lines`);
|
|
3131
|
-
summary.title = "Expand all unmodified lines";
|
|
3132
|
-
} else if (unchangedRegionStyle === "simple") {
|
|
3133
|
-
summary.setAttribute("aria-hidden", "true");
|
|
3134
|
-
summary.removeAttribute("aria-label");
|
|
3135
|
-
summary.title = "";
|
|
3136
|
-
} else {
|
|
3137
|
-
summary.removeAttribute("aria-hidden");
|
|
3138
|
-
summary.removeAttribute("aria-label");
|
|
3139
|
-
summary.title = "";
|
|
3140
|
-
}
|
|
3141
|
-
this.updateDiffUnchangedBridgeMeta(entry, unchangedRegionStyle, summaryLabel);
|
|
3867
|
+
syncDiffUnchangedBridgeNode({
|
|
3868
|
+
bridge,
|
|
3869
|
+
unchangedRegionStyle,
|
|
3870
|
+
containerRect,
|
|
3871
|
+
containerScrollLeft: this.lastContainer.scrollLeft,
|
|
3872
|
+
containerScrollTop: this.lastContainer.scrollTop,
|
|
3873
|
+
secondaryAnchorRect,
|
|
3874
|
+
primaryAnchorRect,
|
|
3875
|
+
bridgeLeftInset,
|
|
3876
|
+
bridgeRailWidth,
|
|
3877
|
+
primaryStyle,
|
|
3878
|
+
editorBackgroundColor: editorSurfaceStyle.backgroundColor
|
|
3879
|
+
});
|
|
3880
|
+
syncDiffUnchangedSummaryButton(summary, unchangedRegionStyle, summaryLabel);
|
|
3881
|
+
syncDiffUnchangedMetaNode(entry.visualMeta, unchangedRegionStyle, summaryLabel);
|
|
3142
3882
|
if (unchangedRegionStyle === "line-info" || unchangedRegionStyle === "line-info-basic") {
|
|
3143
3883
|
this.syncDiffUnchangedBridgeRail(entry, showTopHandle, topHandle ?? null, showBottomHandle, bottomHandle ?? null);
|
|
3144
3884
|
if (entry.rail && entry.rail.parentElement !== bridge) bridge.prepend(entry.rail);
|
|
@@ -3147,8 +3887,9 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3147
3887
|
entry.rail.setAttribute("aria-hidden", "true");
|
|
3148
3888
|
}
|
|
3149
3889
|
entry.activate = () => {
|
|
3150
|
-
const action = primaryNode
|
|
3890
|
+
const action = findDiffUnchangedActivationAction(primaryNode, secondaryNode);
|
|
3151
3891
|
if (action instanceof HTMLElement) {
|
|
3892
|
+
this.capturePreviousDiffUnchangedState();
|
|
3152
3893
|
action.click();
|
|
3153
3894
|
this.scheduleCapturePersistedDiffUnchangedState(1);
|
|
3154
3895
|
}
|
|
@@ -3167,11 +3908,23 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3167
3908
|
node.title = node.title || "Collapse unchanged lines";
|
|
3168
3909
|
this.bindFocusVisibleClass(this.diffUnchangedRegionDisposables, node);
|
|
3169
3910
|
this.bindPersistOnMouseRelease(this.diffUnchangedRegionDisposables, node);
|
|
3911
|
+
this.createDomDisposable(this.diffUnchangedRegionDisposables, node, "mouseup", (event) => {
|
|
3912
|
+
const mouseEvent = event;
|
|
3913
|
+
if (mouseEvent.button !== 0) return;
|
|
3914
|
+
if (!this.restorePreviousDiffUnchangedState()) return;
|
|
3915
|
+
event.preventDefault();
|
|
3916
|
+
event.stopPropagation();
|
|
3917
|
+
this.schedulePatchDiffUnchangedRegionsAfterInteraction();
|
|
3918
|
+
});
|
|
3170
3919
|
this.createDomDisposable(this.diffUnchangedRegionDisposables, node, "keydown", (event) => {
|
|
3171
3920
|
const keyboardEvent = event;
|
|
3172
3921
|
if (keyboardEvent.key !== "Enter" && keyboardEvent.key !== " ") return;
|
|
3173
3922
|
keyboardEvent.preventDefault();
|
|
3174
|
-
this.
|
|
3923
|
+
if (this.restorePreviousDiffUnchangedState()) {
|
|
3924
|
+
this.schedulePatchDiffUnchangedRegionsAfterInteraction();
|
|
3925
|
+
return;
|
|
3926
|
+
}
|
|
3927
|
+
dispatchSyntheticPrimaryMouseDown(node);
|
|
3175
3928
|
this.scheduleCapturePersistedDiffUnchangedState(1);
|
|
3176
3929
|
});
|
|
3177
3930
|
}
|
|
@@ -3180,6 +3933,11 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3180
3933
|
this.applyDiffRootAppearanceClass();
|
|
3181
3934
|
const viewZoneHeightsChanged = this.syncDiffUnchangedViewZoneHeights();
|
|
3182
3935
|
const centers = this.lastContainer.querySelectorAll(".diff-hidden-lines .center");
|
|
3936
|
+
const modifiedHiddenSummaryMidpoints = Array.from(this.lastContainer.querySelectorAll(".editor.modified .diff-hidden-lines .center")).map((node) => {
|
|
3937
|
+
const rect = node.getBoundingClientRect();
|
|
3938
|
+
if (rect.width <= 0 || rect.height <= 0) return null;
|
|
3939
|
+
return rect.top + rect.height / 2;
|
|
3940
|
+
}).filter((value) => value !== null);
|
|
3183
3941
|
Array.from(centers).sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top).forEach((node, index) => this.patchDiffUnchangedCenter(node, index));
|
|
3184
3942
|
const partialRevealHandles = this.lastContainer.querySelectorAll(".diff-hidden-lines .top, .diff-hidden-lines .bottom");
|
|
3185
3943
|
partialRevealHandles.forEach((node) => {
|
|
@@ -3204,7 +3962,13 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3204
3962
|
this.pruneDiffUnchangedBridgeEntries(visibleKeys);
|
|
3205
3963
|
this.syncDiffUnchangedOverlayScrollBaseline();
|
|
3206
3964
|
const foldGlyphs = this.lastContainer.querySelectorAll(".fold-unchanged");
|
|
3207
|
-
foldGlyphs.forEach((node) =>
|
|
3965
|
+
foldGlyphs.forEach((node) => {
|
|
3966
|
+
const rect = node.getBoundingClientRect();
|
|
3967
|
+
const midpoint = rect.top + rect.height / 2;
|
|
3968
|
+
const overlapsHiddenSummary = modifiedHiddenSummaryMidpoints.some((summaryMidpoint) => Math.abs(summaryMidpoint - midpoint) <= 8);
|
|
3969
|
+
node.classList.toggle("stream-monaco-fold-unchanged-hidden", overlapsHiddenSummary);
|
|
3970
|
+
this.patchDiffUnchangedFoldGlyph(node);
|
|
3971
|
+
});
|
|
3208
3972
|
if (viewZoneHeightsChanged) this.schedulePatchDiffUnchangedRegions();
|
|
3209
3973
|
}
|
|
3210
3974
|
schedulePatchDiffUnchangedRegions() {
|
|
@@ -3217,12 +3981,12 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3217
3981
|
this.schedulePatchDiffUnchangedRegions();
|
|
3218
3982
|
}
|
|
3219
3983
|
setupDiffUnchangedRegionEnhancements() {
|
|
3220
|
-
var _globalThis$
|
|
3984
|
+
var _globalThis$getComput2, _globalThis2;
|
|
3221
3985
|
this.disposeDiffUnchangedRegionEnhancements();
|
|
3222
3986
|
if (!this.diffEditorView || !this.lastContainer) return;
|
|
3223
3987
|
if (typeof document === "undefined") return;
|
|
3224
3988
|
this.ensureDiffUiStyle();
|
|
3225
|
-
const containerStyle = (_globalThis$
|
|
3989
|
+
const containerStyle = (_globalThis$getComput2 = (_globalThis2 = globalThis).getComputedStyle) === null || _globalThis$getComput2 === void 0 ? void 0 : _globalThis$getComput2.call(_globalThis2, this.lastContainer);
|
|
3226
3990
|
if (!containerStyle || containerStyle.position === "static") this.lastContainer.style.position = "relative";
|
|
3227
3991
|
this.applyDiffRootAppearanceClass();
|
|
3228
3992
|
this.schedulePatchDiffUnchangedRegions();
|
|
@@ -3250,6 +4014,20 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3250
4014
|
this.applyDiffRootAppearanceClass();
|
|
3251
4015
|
this.schedulePatchDiffUnchangedRegions();
|
|
3252
4016
|
};
|
|
4017
|
+
const handleFoldMouseUp = (event) => {
|
|
4018
|
+
var _event$event, _event$target, _event$event2, _event$event2$prevent, _event$event3, _event$event3$stopPro;
|
|
4019
|
+
if (event === null || event === void 0 || (_event$event = event.event) === null || _event$event === void 0 ? void 0 : _event$event.rightButton) return;
|
|
4020
|
+
const targetElement = event === null || event === void 0 || (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.element;
|
|
4021
|
+
const className = typeof (targetElement === null || targetElement === void 0 ? void 0 : targetElement.className) === "string" ? targetElement.className : "";
|
|
4022
|
+
if (!className.includes("fold-unchanged")) return;
|
|
4023
|
+
if (!this.diffPreviousUnchangedModelState) return;
|
|
4024
|
+
event === null || event === void 0 || (_event$event2 = event.event) === null || _event$event2 === void 0 || (_event$event2$prevent = _event$event2.preventDefault) === null || _event$event2$prevent === void 0 || _event$event2$prevent.call(_event$event2);
|
|
4025
|
+
event === null || event === void 0 || (_event$event3 = event.event) === null || _event$event3 === void 0 || (_event$event3$stopPro = _event$event3.stopPropagation) === null || _event$event3$stopPro === void 0 || _event$event3$stopPro.call(_event$event3);
|
|
4026
|
+
requestAnimationFrame(() => {
|
|
4027
|
+
if (!this.restorePreviousDiffUnchangedState()) return;
|
|
4028
|
+
this.schedulePatchDiffUnchangedRegionsAfterInteraction();
|
|
4029
|
+
});
|
|
4030
|
+
};
|
|
3253
4031
|
this.diffUnchangedRegionDisposables.push(this.diffEditorView.onDidUpdateDiff(() => {
|
|
3254
4032
|
repatch();
|
|
3255
4033
|
this.scheduleRestorePersistedDiffUnchangedState();
|
|
@@ -3258,23 +4036,29 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3258
4036
|
this.diffUnchangedRegionDisposables.push(modifiedEditor.onDidLayoutChange(repatch));
|
|
3259
4037
|
this.diffUnchangedRegionDisposables.push(originalEditor.onDidScrollChange(() => this.schedulePatchDiffUnchangedRegionsAfterScroll()));
|
|
3260
4038
|
this.diffUnchangedRegionDisposables.push(modifiedEditor.onDidScrollChange(() => this.schedulePatchDiffUnchangedRegionsAfterScroll()));
|
|
4039
|
+
this.diffUnchangedRegionDisposables.push(originalEditor.onMouseUp(handleFoldMouseUp));
|
|
4040
|
+
this.diffUnchangedRegionDisposables.push(modifiedEditor.onMouseUp(handleFoldMouseUp));
|
|
3261
4041
|
this.createDomDisposable(this.diffUnchangedRegionDisposables, this.lastContainer, "scroll", () => this.schedulePatchDiffUnchangedRegionsAfterScroll());
|
|
3262
4042
|
}
|
|
3263
4043
|
setupDiffHunkInteractions() {
|
|
3264
|
-
var _globalThis$
|
|
4044
|
+
var _globalThis$getComput3, _globalThis3;
|
|
3265
4045
|
this.disposeDiffHunkInteractions();
|
|
3266
4046
|
if (!this.diffEditorView || !this.lastContainer) return;
|
|
3267
4047
|
if (this.options.diffHunkActionsOnHover !== true) return;
|
|
3268
4048
|
if (typeof document === "undefined") return;
|
|
3269
4049
|
this.ensureDiffUiStyle();
|
|
3270
|
-
const containerStyle = (_globalThis$
|
|
4050
|
+
const containerStyle = (_globalThis$getComput3 = (_globalThis3 = globalThis).getComputedStyle) === null || _globalThis$getComput3 === void 0 ? void 0 : _globalThis$getComput3.call(_globalThis3, this.lastContainer);
|
|
3271
4051
|
if (!containerStyle || containerStyle.position === "static") this.lastContainer.style.position = "relative";
|
|
3272
4052
|
const overlay = document.createElement("div");
|
|
3273
4053
|
overlay.className = "stream-monaco-diff-hunk-overlay";
|
|
3274
4054
|
this.diffHunkOverlay = overlay;
|
|
3275
4055
|
this.lastContainer.append(overlay);
|
|
3276
|
-
this.diffHunkUpperNode =
|
|
3277
|
-
this.diffHunkLowerNode =
|
|
4056
|
+
this.diffHunkUpperNode = createDiffHunkActionNode("upper", (side, action) => this.applyDiffHunkAction(side, action));
|
|
4057
|
+
this.diffHunkLowerNode = createDiffHunkActionNode("lower", (side, action) => this.applyDiffHunkAction(side, action));
|
|
4058
|
+
this.createDomDisposable(this.diffHunkDisposables, this.diffHunkUpperNode, "mouseenter", () => this.cancelScheduledHideDiffHunkActions());
|
|
4059
|
+
this.createDomDisposable(this.diffHunkDisposables, this.diffHunkUpperNode, "mouseleave", () => this.scheduleHideDiffHunkActions());
|
|
4060
|
+
this.createDomDisposable(this.diffHunkDisposables, this.diffHunkLowerNode, "mouseenter", () => this.cancelScheduledHideDiffHunkActions());
|
|
4061
|
+
this.createDomDisposable(this.diffHunkDisposables, this.diffHunkLowerNode, "mouseleave", () => this.scheduleHideDiffHunkActions());
|
|
3278
4062
|
overlay.append(this.diffHunkUpperNode, this.diffHunkLowerNode);
|
|
3279
4063
|
const originalEditor = this.diffEditorView.getOriginalEditor();
|
|
3280
4064
|
const modifiedEditor = this.diffEditorView.getModifiedEditor();
|
|
@@ -3317,113 +4101,35 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3317
4101
|
if (this.diffHunkUpperNode) this.diffHunkUpperNode.style.display = "none";
|
|
3318
4102
|
if (this.diffHunkLowerNode) this.diffHunkLowerNode.style.display = "none";
|
|
3319
4103
|
}
|
|
3320
|
-
inferInlineDiffHunkHoverSide(change, event) {
|
|
3321
|
-
var _event$target$positio;
|
|
3322
|
-
const targetElement = event.target.element instanceof HTMLElement ? event.target.element : null;
|
|
3323
|
-
if (targetElement === null || targetElement === void 0 ? void 0 : targetElement.closest(".line-delete, .char-delete, .inline-deleted-text, .inline-deleted-margin-view-zone")) return "upper";
|
|
3324
|
-
if (targetElement === null || targetElement === void 0 ? void 0 : targetElement.closest(".line-insert, .char-insert, .gutter-insert, .view-line")) return "lower";
|
|
3325
|
-
if (!this.hasModifiedLines(change)) return "upper";
|
|
3326
|
-
if (!this.hasOriginalLines(change)) return "lower";
|
|
3327
|
-
const hoverLine = ((_event$target$positio = event.target.position) === null || _event$target$positio === void 0 ? void 0 : _event$target$positio.lineNumber) ?? 0;
|
|
3328
|
-
const modifiedAnchor = Math.max(1, change.modifiedStartLineNumber || change.modifiedEndLineNumber || 1);
|
|
3329
|
-
return hoverLine < modifiedAnchor ? "upper" : "lower";
|
|
3330
|
-
}
|
|
3331
|
-
hasOriginalLines(change) {
|
|
3332
|
-
return change.originalStartLineNumber > 0 && change.originalEndLineNumber >= change.originalStartLineNumber;
|
|
3333
|
-
}
|
|
3334
|
-
hasModifiedLines(change) {
|
|
3335
|
-
return change.modifiedStartLineNumber > 0 && change.modifiedEndLineNumber >= change.modifiedStartLineNumber;
|
|
3336
|
-
}
|
|
3337
|
-
distanceToLineChange(side, change, line) {
|
|
3338
|
-
const hasRange = side === "original" ? this.hasOriginalLines(change) : this.hasModifiedLines(change);
|
|
3339
|
-
const start = side === "original" ? change.originalStartLineNumber : change.modifiedStartLineNumber;
|
|
3340
|
-
const end = side === "original" ? change.originalEndLineNumber : change.modifiedEndLineNumber;
|
|
3341
|
-
if (hasRange) {
|
|
3342
|
-
if (line < start) return start - line;
|
|
3343
|
-
if (line > end) return line - end;
|
|
3344
|
-
return 0;
|
|
3345
|
-
}
|
|
3346
|
-
const fallbackAnchor = Math.max(1, start || end || 1);
|
|
3347
|
-
return Math.abs(line - fallbackAnchor);
|
|
3348
|
-
}
|
|
3349
|
-
findLineChangeByHoverLine(side, line) {
|
|
3350
|
-
if (this.diffHunkLineChanges.length === 0) return null;
|
|
3351
|
-
let best = null;
|
|
3352
|
-
let bestDistance = Number.POSITIVE_INFINITY;
|
|
3353
|
-
for (const change of this.diffHunkLineChanges) {
|
|
3354
|
-
const distance = this.distanceToLineChange(side, change, line);
|
|
3355
|
-
if (distance < bestDistance) {
|
|
3356
|
-
bestDistance = distance;
|
|
3357
|
-
best = change;
|
|
3358
|
-
if (distance === 0) break;
|
|
3359
|
-
}
|
|
3360
|
-
}
|
|
3361
|
-
if (bestDistance > 2) return null;
|
|
3362
|
-
return best;
|
|
3363
|
-
}
|
|
3364
4104
|
handleDiffHunkMouseMove(side, event) {
|
|
3365
|
-
var _event$target$positio2;
|
|
3366
|
-
const line = (_event$target$
|
|
4105
|
+
var _event$target$positio, _event$target$positio2;
|
|
4106
|
+
const line = (_event$target$positio = event.target.position) === null || _event$target$positio === void 0 ? void 0 : _event$target$positio.lineNumber;
|
|
3367
4107
|
if (!line) {
|
|
3368
4108
|
this.scheduleHideDiffHunkActions(120);
|
|
3369
4109
|
return;
|
|
3370
4110
|
}
|
|
3371
|
-
const change = this.
|
|
4111
|
+
const change = findLineChangeByHoverLine(this.diffHunkLineChanges, side, line);
|
|
3372
4112
|
if (!change) {
|
|
3373
4113
|
this.scheduleHideDiffHunkActions(120);
|
|
3374
4114
|
return;
|
|
3375
4115
|
}
|
|
3376
4116
|
this.cancelScheduledHideDiffHunkActions();
|
|
3377
4117
|
this.diffHunkActiveChange = change;
|
|
3378
|
-
this.diffHunkActiveHoverSide = this.isDiffInlineMode() ?
|
|
4118
|
+
this.diffHunkActiveHoverSide = this.isDiffInlineMode() ? inferInlineDiffHunkHoverSide(change, ((_event$target$positio2 = event.target.position) === null || _event$target$positio2 === void 0 ? void 0 : _event$target$positio2.lineNumber) ?? 0, event.target.element instanceof HTMLElement ? event.target.element : null) : null;
|
|
3379
4119
|
this.repositionDiffHunkNodes();
|
|
3380
4120
|
}
|
|
3381
4121
|
isOriginalEditorCollapsed() {
|
|
3382
|
-
var _this$diffEditorView$
|
|
4122
|
+
var _this$diffEditorView$2, _this$diffEditorView$3;
|
|
3383
4123
|
if (!this.diffEditorView) return true;
|
|
3384
|
-
const info = (_this$diffEditorView$
|
|
4124
|
+
const info = (_this$diffEditorView$2 = (_this$diffEditorView$3 = this.diffEditorView.getOriginalEditor()).getLayoutInfo) === null || _this$diffEditorView$2 === void 0 ? void 0 : _this$diffEditorView$2.call(_this$diffEditorView$3);
|
|
3385
4125
|
return !info || info.width < 24;
|
|
3386
4126
|
}
|
|
3387
4127
|
isDiffInlineMode() {
|
|
3388
|
-
var _this$
|
|
3389
|
-
const diffRoot = (_this$
|
|
3390
|
-
if (diffRoot instanceof HTMLElement) return !diffRoot.classList.contains("side-by-side");
|
|
4128
|
+
var _this$lastContainer8, _this$lastContainer9;
|
|
4129
|
+
const diffRoot = typeof ((_this$lastContainer8 = this.lastContainer) === null || _this$lastContainer8 === void 0 ? void 0 : _this$lastContainer8.querySelector) === "function" ? (_this$lastContainer9 = this.lastContainer) === null || _this$lastContainer9 === void 0 ? void 0 : _this$lastContainer9.querySelector(".monaco-diff-editor") : null;
|
|
4130
|
+
if (typeof HTMLElement !== "undefined" && diffRoot instanceof HTMLElement) return !diffRoot.classList.contains("side-by-side");
|
|
3391
4131
|
return this.isOriginalEditorCollapsed();
|
|
3392
4132
|
}
|
|
3393
|
-
getEditorBySide(side) {
|
|
3394
|
-
if (!this.diffEditorView) return null;
|
|
3395
|
-
return side === "original" ? this.diffEditorView.getOriginalEditor() : this.diffEditorView.getModifiedEditor();
|
|
3396
|
-
}
|
|
3397
|
-
getFullLineRange(model, startLine, endLine) {
|
|
3398
|
-
if (endLine < startLine) return null;
|
|
3399
|
-
const lineCount = model.getLineCount();
|
|
3400
|
-
if (lineCount < 1) return null;
|
|
3401
|
-
const start = Math.max(1, Math.min(startLine, lineCount));
|
|
3402
|
-
const end = Math.max(start, Math.min(endLine, lineCount));
|
|
3403
|
-
if (end < lineCount) return new monaco_shim_exports.Range(start, 1, end + 1, 1);
|
|
3404
|
-
return new monaco_shim_exports.Range(start, 1, end, model.getLineMaxColumn(end));
|
|
3405
|
-
}
|
|
3406
|
-
getLinesText(model, startLine, endLine) {
|
|
3407
|
-
const range = this.getFullLineRange(model, startLine, endLine);
|
|
3408
|
-
if (!range) return "";
|
|
3409
|
-
return model.getValueInRange(range);
|
|
3410
|
-
}
|
|
3411
|
-
getInsertRangeBeforeLine(model, lineNumber) {
|
|
3412
|
-
const lineCount = model.getLineCount();
|
|
3413
|
-
if (lineNumber <= 1) return new monaco_shim_exports.Range(1, 1, 1, 1);
|
|
3414
|
-
if (lineNumber <= lineCount) return new monaco_shim_exports.Range(lineNumber, 1, lineNumber, 1);
|
|
3415
|
-
const lastLine = lineCount;
|
|
3416
|
-
const lastColumn = model.getLineMaxColumn(lastLine);
|
|
3417
|
-
return new monaco_shim_exports.Range(lastLine, lastColumn, lastLine, lastColumn);
|
|
3418
|
-
}
|
|
3419
|
-
getInsertRangeAfterLine(model, lineNumber) {
|
|
3420
|
-
const lineCount = model.getLineCount();
|
|
3421
|
-
if (lineNumber < 1) return new monaco_shim_exports.Range(1, 1, 1, 1);
|
|
3422
|
-
if (lineNumber < lineCount) return new monaco_shim_exports.Range(lineNumber + 1, 1, lineNumber + 1, 1);
|
|
3423
|
-
const lastLine = lineCount;
|
|
3424
|
-
const lastColumn = model.getLineMaxColumn(lastLine);
|
|
3425
|
-
return new monaco_shim_exports.Range(lastLine, lastColumn, lastLine, lastColumn);
|
|
3426
|
-
}
|
|
3427
4133
|
applyDiffModelLanguage(models, codeLanguage) {
|
|
3428
4134
|
if (!codeLanguage) return;
|
|
3429
4135
|
const lang = processedLanguage(codeLanguage);
|
|
@@ -3435,8 +4141,8 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3435
4141
|
if (!this.diffEditorView || !viewState) return;
|
|
3436
4142
|
const restore = () => {
|
|
3437
4143
|
try {
|
|
3438
|
-
var _this$
|
|
3439
|
-
(_this$
|
|
4144
|
+
var _this$diffEditorView16;
|
|
4145
|
+
(_this$diffEditorView16 = this.diffEditorView) === null || _this$diffEditorView16 === void 0 || _this$diffEditorView16.restoreViewState(viewState);
|
|
3440
4146
|
} catch {}
|
|
3441
4147
|
};
|
|
3442
4148
|
restore();
|
|
@@ -3454,7 +4160,7 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3454
4160
|
this.pendingPreparedDiffViewModel = null;
|
|
3455
4161
|
}
|
|
3456
4162
|
syncDiffKnownValues() {
|
|
3457
|
-
var _this$
|
|
4163
|
+
var _this$diffEditorView17, _this$diffEditorView18, _this$diffEditorView19, _this$diffHeightManag4;
|
|
3458
4164
|
if (this.originalModel) this.lastKnownOriginalCode = this.originalModel.getValue();
|
|
3459
4165
|
if (this.modifiedModel) {
|
|
3460
4166
|
this.lastKnownModifiedCode = this.modifiedModel.getValue();
|
|
@@ -3463,67 +4169,15 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3463
4169
|
this.lastKnownModifiedDirty = false;
|
|
3464
4170
|
this._hasScrollBar = false;
|
|
3465
4171
|
this.cachedComputedHeightDiff = this.computedHeight();
|
|
3466
|
-
this.cachedScrollHeightDiff = ((_this$
|
|
3467
|
-
(_this$
|
|
3468
|
-
}
|
|
3469
|
-
applyDefaultDiffHunkAction(context) {
|
|
3470
|
-
const { action, side, lineChange } = context;
|
|
3471
|
-
if (!this.originalModel || !this.modifiedModel) return;
|
|
3472
|
-
const hasOriginal = this.hasOriginalLines(lineChange);
|
|
3473
|
-
const hasModified = this.hasModifiedLines(lineChange);
|
|
3474
|
-
if (action === "revert" && side === "upper") {
|
|
3475
|
-
if (!hasOriginal) return;
|
|
3476
|
-
const text = this.getLinesText(this.originalModel, lineChange.originalStartLineNumber, lineChange.originalEndLineNumber);
|
|
3477
|
-
if (!text) return;
|
|
3478
|
-
const range = hasModified ? this.getInsertRangeBeforeLine(this.modifiedModel, lineChange.modifiedStartLineNumber) : this.getInsertRangeAfterLine(this.modifiedModel, Math.max(0, lineChange.modifiedStartLineNumber || lineChange.modifiedEndLineNumber));
|
|
3479
|
-
this.modifiedModel.applyEdits([{
|
|
3480
|
-
range,
|
|
3481
|
-
text,
|
|
3482
|
-
forceMoveMarkers: true
|
|
3483
|
-
}]);
|
|
3484
|
-
return;
|
|
3485
|
-
}
|
|
3486
|
-
if (action === "revert" && side === "lower") {
|
|
3487
|
-
if (!hasModified) return;
|
|
3488
|
-
const range = this.getFullLineRange(this.modifiedModel, lineChange.modifiedStartLineNumber, lineChange.modifiedEndLineNumber);
|
|
3489
|
-
if (!range) return;
|
|
3490
|
-
this.modifiedModel.applyEdits([{
|
|
3491
|
-
range,
|
|
3492
|
-
text: "",
|
|
3493
|
-
forceMoveMarkers: true
|
|
3494
|
-
}]);
|
|
3495
|
-
return;
|
|
3496
|
-
}
|
|
3497
|
-
if (action === "stage" && side === "upper") {
|
|
3498
|
-
if (!hasOriginal) return;
|
|
3499
|
-
const range = this.getFullLineRange(this.originalModel, lineChange.originalStartLineNumber, lineChange.originalEndLineNumber);
|
|
3500
|
-
if (!range) return;
|
|
3501
|
-
this.originalModel.applyEdits([{
|
|
3502
|
-
range,
|
|
3503
|
-
text: "",
|
|
3504
|
-
forceMoveMarkers: true
|
|
3505
|
-
}]);
|
|
3506
|
-
return;
|
|
3507
|
-
}
|
|
3508
|
-
if (action === "stage" && side === "lower") {
|
|
3509
|
-
if (!hasModified) return;
|
|
3510
|
-
const text = this.getLinesText(this.modifiedModel, lineChange.modifiedStartLineNumber, lineChange.modifiedEndLineNumber);
|
|
3511
|
-
if (!text) return;
|
|
3512
|
-
const anchor = hasOriginal ? lineChange.originalEndLineNumber : Math.max(0, lineChange.originalStartLineNumber);
|
|
3513
|
-
const range = this.getInsertRangeAfterLine(this.originalModel, anchor);
|
|
3514
|
-
this.originalModel.applyEdits([{
|
|
3515
|
-
range,
|
|
3516
|
-
text,
|
|
3517
|
-
forceMoveMarkers: true
|
|
3518
|
-
}]);
|
|
3519
|
-
}
|
|
4172
|
+
this.cachedScrollHeightDiff = ((_this$diffEditorView17 = this.diffEditorView) === null || _this$diffEditorView17 === void 0 || (_this$diffEditorView19 = (_this$diffEditorView18 = _this$diffEditorView17.getModifiedEditor()).getScrollHeight) === null || _this$diffEditorView19 === void 0 ? void 0 : _this$diffEditorView19.call(_this$diffEditorView18)) ?? this.cachedScrollHeightDiff;
|
|
4173
|
+
(_this$diffHeightManag4 = this.diffHeightManager) === null || _this$diffHeightManag4 === void 0 || _this$diffHeightManag4.update();
|
|
3520
4174
|
}
|
|
3521
4175
|
async applyDiffHunkAction(side, action) {
|
|
3522
4176
|
if (!this.diffHunkActiveChange || !this.originalModel || !this.modifiedModel) return;
|
|
3523
4177
|
if (this.diffHunkActionInFlight) return;
|
|
3524
4178
|
this.diffHunkActionInFlight = true;
|
|
3525
|
-
|
|
3526
|
-
|
|
4179
|
+
setDiffHunkNodeEnabled(this.diffHunkUpperNode, false);
|
|
4180
|
+
setDiffHunkNodeEnabled(this.diffHunkLowerNode, false);
|
|
3527
4181
|
try {
|
|
3528
4182
|
this.flushOriginalAppendBufferSync();
|
|
3529
4183
|
this.flushModifiedAppendBufferSync();
|
|
@@ -3540,39 +4194,13 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3540
4194
|
} catch (error$1) {
|
|
3541
4195
|
console.warn("onDiffHunkAction callback threw an error:", error$1);
|
|
3542
4196
|
}
|
|
3543
|
-
if (allowDefault)
|
|
4197
|
+
if (allowDefault) applyDefaultDiffHunkAction(context);
|
|
3544
4198
|
this.syncDiffKnownValues();
|
|
3545
4199
|
this.hideDiffHunkActions();
|
|
3546
4200
|
} finally {
|
|
3547
4201
|
this.diffHunkActionInFlight = false;
|
|
3548
4202
|
}
|
|
3549
4203
|
}
|
|
3550
|
-
setDiffHunkNodeEnabled(node, enabled) {
|
|
3551
|
-
if (!node) return;
|
|
3552
|
-
const buttons = node.querySelectorAll("button");
|
|
3553
|
-
buttons.forEach((button) => {
|
|
3554
|
-
button.disabled = !enabled;
|
|
3555
|
-
});
|
|
3556
|
-
}
|
|
3557
|
-
positionDiffHunkNode(node, side, anchorLine, extraOffsetY = 0) {
|
|
3558
|
-
var _editor$getScrollTop2;
|
|
3559
|
-
if (!this.diffHunkOverlay) return;
|
|
3560
|
-
const editor = this.getEditorBySide(side);
|
|
3561
|
-
if (!editor) return;
|
|
3562
|
-
const host = editor.getContainerDomNode();
|
|
3563
|
-
const line = Math.max(1, anchorLine);
|
|
3564
|
-
const rawTop = editor.getTopForLineNumber(line) - (((_editor$getScrollTop2 = editor.getScrollTop) === null || _editor$getScrollTop2 === void 0 ? void 0 : _editor$getScrollTop2.call(editor)) ?? 0);
|
|
3565
|
-
const lineHeight = editor.getOption(monaco_shim_exports.editor.EditorOption.lineHeight);
|
|
3566
|
-
const nodeWidth = node.offsetWidth || 130;
|
|
3567
|
-
const nodeHeight = node.offsetHeight || 30;
|
|
3568
|
-
const left = host.offsetLeft + Math.max(6, host.clientWidth - nodeWidth - 10);
|
|
3569
|
-
const hostTop = host.offsetTop;
|
|
3570
|
-
const minTop = hostTop + 4;
|
|
3571
|
-
const maxTop = hostTop + Math.max(4, host.clientHeight - nodeHeight - 4);
|
|
3572
|
-
const top = Math.min(maxTop, Math.max(minTop, hostTop + rawTop + Math.round(lineHeight * .2) + extraOffsetY));
|
|
3573
|
-
node.style.transform = `translate(${Math.round(left)}px, ${Math.round(top)}px)`;
|
|
3574
|
-
node.style.display = "flex";
|
|
3575
|
-
}
|
|
3576
4204
|
repositionDiffHunkNodes() {
|
|
3577
4205
|
if (!this.diffHunkActiveChange) {
|
|
3578
4206
|
this.hideDiffHunkActions();
|
|
@@ -3581,22 +4209,22 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3581
4209
|
if (!this.diffHunkUpperNode || !this.diffHunkLowerNode) return;
|
|
3582
4210
|
if (!this.diffEditorView) return;
|
|
3583
4211
|
const change = this.diffHunkActiveChange;
|
|
3584
|
-
const hasOriginal =
|
|
3585
|
-
const hasModified =
|
|
3586
|
-
|
|
3587
|
-
|
|
4212
|
+
const hasOriginal = hasOriginalLines(change);
|
|
4213
|
+
const hasModified = hasModifiedLines(change);
|
|
4214
|
+
setDiffHunkNodeEnabled(this.diffHunkUpperNode, hasOriginal);
|
|
4215
|
+
setDiffHunkNodeEnabled(this.diffHunkLowerNode, hasModified);
|
|
3588
4216
|
const inlineMode = this.isDiffInlineMode();
|
|
3589
4217
|
if (inlineMode) {
|
|
3590
4218
|
const inlineHoverSide = this.diffHunkActiveHoverSide ?? (hasOriginal && !hasModified ? "upper" : "lower");
|
|
3591
4219
|
if (inlineHoverSide === "upper" && hasOriginal) {
|
|
3592
4220
|
const upperAnchor = Math.max(1, change.modifiedStartLineNumber - 1 || change.modifiedEndLineNumber || 1);
|
|
3593
|
-
|
|
4221
|
+
positionDiffHunkNode(this.diffHunkUpperNode, this.diffEditorView.getModifiedEditor(), upperAnchor);
|
|
3594
4222
|
this.diffHunkLowerNode.style.display = "none";
|
|
3595
4223
|
return;
|
|
3596
4224
|
}
|
|
3597
4225
|
if (hasModified) {
|
|
3598
4226
|
const lowerAnchor = Math.max(1, change.modifiedStartLineNumber || change.modifiedEndLineNumber || 1);
|
|
3599
|
-
|
|
4227
|
+
positionDiffHunkNode(this.diffHunkLowerNode, this.diffEditorView.getModifiedEditor(), lowerAnchor);
|
|
3600
4228
|
this.diffHunkUpperNode.style.display = "none";
|
|
3601
4229
|
return;
|
|
3602
4230
|
}
|
|
@@ -3604,13 +4232,12 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3604
4232
|
return;
|
|
3605
4233
|
}
|
|
3606
4234
|
if (hasOriginal) {
|
|
3607
|
-
const upperSide = "original";
|
|
3608
4235
|
const upperAnchor = change.originalStartLineNumber;
|
|
3609
|
-
|
|
4236
|
+
positionDiffHunkNode(this.diffHunkUpperNode, this.diffEditorView.getOriginalEditor(), upperAnchor);
|
|
3610
4237
|
} else this.diffHunkUpperNode.style.display = "none";
|
|
3611
4238
|
if (hasModified) {
|
|
3612
4239
|
const lowerAnchor = change.modifiedStartLineNumber;
|
|
3613
|
-
|
|
4240
|
+
positionDiffHunkNode(this.diffHunkLowerNode, this.diffEditorView.getModifiedEditor(), lowerAnchor);
|
|
3614
4241
|
} else this.diffHunkLowerNode.style.display = "none";
|
|
3615
4242
|
}
|
|
3616
4243
|
scheduleFlushAppendBufferDiff() {
|
|
@@ -3648,24 +4275,43 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3648
4275
|
this.preserveNativeDiffDecorationsOnStaleAppend = true;
|
|
3649
4276
|
this.appendToModel(this.originalModel, text);
|
|
3650
4277
|
}
|
|
4278
|
+
computeRawHeight() {
|
|
4279
|
+
return computeDiffRawHeight({
|
|
4280
|
+
diffEditorView: this.diffEditorView,
|
|
4281
|
+
maxHeightValue: this.maxHeightValue
|
|
4282
|
+
});
|
|
4283
|
+
}
|
|
3651
4284
|
computedHeight() {
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
4285
|
+
const { height, nextInlineDiffStreamingHeightFloor } = computeDiffHeight({
|
|
4286
|
+
rawHeight: this.computeRawHeight(),
|
|
4287
|
+
isInlineMode: this.isDiffInlineMode(),
|
|
4288
|
+
inlineDiffStreamingPresentationActive: this.inlineDiffStreamingPresentationActive,
|
|
4289
|
+
inlineDiffStreamingHeightFloor: this.inlineDiffStreamingHeightFloor
|
|
4290
|
+
});
|
|
4291
|
+
this.inlineDiffStreamingHeightFloor = nextInlineDiffStreamingHeightFloor;
|
|
4292
|
+
return height;
|
|
4293
|
+
}
|
|
4294
|
+
eagerlyGrowDiffContainerHeight() {
|
|
4295
|
+
var _this$lastContainer$g, _this$lastContainer10;
|
|
4296
|
+
if (!this.lastContainer) return;
|
|
4297
|
+
const next = this.computedHeight();
|
|
4298
|
+
if (!Number.isFinite(next) || next <= 0) return;
|
|
4299
|
+
const applied = Number.parseFloat(this.lastContainer.style.height || "0") || 0;
|
|
4300
|
+
const measured = ((_this$lastContainer$g = (_this$lastContainer10 = this.lastContainer).getBoundingClientRect) === null || _this$lastContainer$g === void 0 ? void 0 : _this$lastContainer$g.call(_this$lastContainer10).height) ?? this.lastContainer.clientHeight ?? 0;
|
|
4301
|
+
const baseline = Math.max(applied, measured);
|
|
4302
|
+
if (next <= baseline + 1) return;
|
|
4303
|
+
this.lastContainer.style.height = `${next}px`;
|
|
4304
|
+
this.cachedComputedHeightDiff = next;
|
|
4305
|
+
this.scheduleSyncDiffEditorLayoutToContainer();
|
|
3664
4306
|
}
|
|
3665
4307
|
isOverflowAutoDiff() {
|
|
3666
4308
|
if (!this.lastContainer) return false;
|
|
3667
4309
|
return this.computedHeight() >= this.maxHeightValue - 1;
|
|
3668
4310
|
}
|
|
4311
|
+
shouldAvoidOptimisticMaxHeightWriteDiff() {
|
|
4312
|
+
const hideUnchangedRegions = this.diffHideUnchangedRegionsResolved;
|
|
4313
|
+
return this.isDiffInlineMode() && (hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled) === true && !this.diffHideUnchangedRegionsDeferred;
|
|
4314
|
+
}
|
|
3669
4315
|
shouldPerformImmediateRevealDiff() {
|
|
3670
4316
|
return this.autoScrollOnUpdate && this.shouldAutoScrollDiff && !this.diffHideUnchangedRegionsDeferred && this.hasVerticalScrollbarModified() && this.isOverflowAutoDiff();
|
|
3671
4317
|
}
|
|
@@ -3688,17 +4334,22 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3688
4334
|
if (this._hasScrollBar) return true;
|
|
3689
4335
|
const m = this.measureViewportDiff();
|
|
3690
4336
|
if (!m) return false;
|
|
3691
|
-
|
|
3692
|
-
return this._hasScrollBar = m.scrollHeight > m.computedHeight + Math.max(padding / 2, epsilon);
|
|
4337
|
+
return this._hasScrollBar = hasVerticalScrollbar(m);
|
|
3693
4338
|
}
|
|
3694
4339
|
userIsNearBottomDiff() {
|
|
3695
4340
|
if (!this.diffEditorView) return true;
|
|
3696
4341
|
const m = this.measureViewportDiff();
|
|
3697
4342
|
if (!m || !m.li) return true;
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
4343
|
+
return isUserNearBottom({
|
|
4344
|
+
computedHeight: m.computedHeight,
|
|
4345
|
+
lineHeight: m.lineHeight,
|
|
4346
|
+
scrollHeight: m.scrollHeight,
|
|
4347
|
+
scrollTop: m.scrollTop,
|
|
4348
|
+
viewportHeight: m.li.height
|
|
4349
|
+
}, {
|
|
4350
|
+
autoScrollThresholdLines: this.autoScrollThresholdLines ?? 0,
|
|
4351
|
+
autoScrollThresholdPx: this.autoScrollThresholdPx || 0
|
|
4352
|
+
});
|
|
3702
4353
|
}
|
|
3703
4354
|
maybeScrollDiffToBottom(targetLine, prevLineOverride) {
|
|
3704
4355
|
this.rafScheduler.schedule("maybe-scroll-diff", () => {
|
|
@@ -3774,7 +4425,7 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3774
4425
|
}
|
|
3775
4426
|
performRevealDiffTicketed(line, ticket) {
|
|
3776
4427
|
this.rafScheduler.schedule("revealDiff", () => {
|
|
3777
|
-
var _editor;
|
|
4428
|
+
var _editor$1;
|
|
3778
4429
|
if (this.diffScrollWatcher) {
|
|
3779
4430
|
log("diff", "performRevealDiffTicketed - suppressing watcher", {
|
|
3780
4431
|
ticket,
|
|
@@ -3789,16 +4440,11 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3789
4440
|
line
|
|
3790
4441
|
});
|
|
3791
4442
|
const strategy = this.diffHideUnchangedRegionsDeferred ? "bottom" : this.revealStrategyOption ?? this.options.revealStrategy ?? "centerIfOutside";
|
|
3792
|
-
const ScrollType =
|
|
3793
|
-
const smooth = !this.diffHideUnchangedRegionsDeferred && ScrollType && typeof ScrollType.Smooth !== "undefined" ? ScrollType.Smooth : void 0;
|
|
4443
|
+
const ScrollType$1 = ScrollType || ((_editor$1 = monaco_shim_exports.editor) === null || _editor$1 === void 0 ? void 0 : _editor$1.ScrollType);
|
|
4444
|
+
const smooth = !this.diffHideUnchangedRegionsDeferred && ScrollType$1 && typeof ScrollType$1.Smooth !== "undefined" ? ScrollType$1.Smooth : void 0;
|
|
3794
4445
|
try {
|
|
3795
4446
|
const me = this.diffEditorView.getModifiedEditor();
|
|
3796
|
-
|
|
3797
|
-
else me.revealLine(line);
|
|
3798
|
-
else if (strategy === "center") if (typeof smooth !== "undefined") me.revealLineInCenter(line, smooth);
|
|
3799
|
-
else me.revealLineInCenter(line);
|
|
3800
|
-
else if (typeof smooth !== "undefined") me.revealLineInCenterIfOutsideViewport(line, smooth);
|
|
3801
|
-
else me.revealLineInCenterIfOutsideViewport(line);
|
|
4447
|
+
revealEditorLine(me, line, strategy, smooth);
|
|
3802
4448
|
} catch {
|
|
3803
4449
|
try {
|
|
3804
4450
|
this.diffEditorView.getModifiedEditor().revealLine(line);
|
|
@@ -3810,8 +4456,8 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3810
4456
|
lastRevealLineDiff: this.lastRevealLineDiff
|
|
3811
4457
|
});
|
|
3812
4458
|
try {
|
|
3813
|
-
var _this$
|
|
3814
|
-
this.lastScrollTopDiff = ((_this$
|
|
4459
|
+
var _this$diffEditorView20, _this$diffEditorView21, _this$diffEditorView22;
|
|
4460
|
+
this.lastScrollTopDiff = ((_this$diffEditorView20 = this.diffEditorView) === null || _this$diffEditorView20 === void 0 || (_this$diffEditorView22 = (_this$diffEditorView21 = _this$diffEditorView20.getModifiedEditor()).getScrollTop) === null || _this$diffEditorView22 === void 0 ? void 0 : _this$diffEditorView22.call(_this$diffEditorView21)) ?? this.lastScrollTopDiff;
|
|
3815
4461
|
} catch {}
|
|
3816
4462
|
});
|
|
3817
4463
|
}
|
|
@@ -3819,11 +4465,10 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3819
4465
|
var _editor2;
|
|
3820
4466
|
if (!this.diffEditorView) return;
|
|
3821
4467
|
if (ticket !== this.revealTicketDiff) return;
|
|
3822
|
-
const ScrollType =
|
|
3823
|
-
const immediate = ScrollType && typeof ScrollType.Immediate !== "undefined" ? ScrollType.Immediate : void 0;
|
|
4468
|
+
const ScrollType$1 = ScrollType || ((_editor2 = monaco_shim_exports.editor) === null || _editor2 === void 0 ? void 0 : _editor2.ScrollType);
|
|
4469
|
+
const immediate = ScrollType$1 && typeof ScrollType$1.Immediate !== "undefined" ? ScrollType$1.Immediate : void 0;
|
|
3824
4470
|
const me = this.diffEditorView.getModifiedEditor();
|
|
3825
|
-
|
|
3826
|
-
else me.revealLine(line);
|
|
4471
|
+
revealEditorLine(me, line, "bottom", immediate);
|
|
3827
4472
|
this.measureViewportDiff();
|
|
3828
4473
|
log("diff", "performImmediateRevealDiff", {
|
|
3829
4474
|
line,
|
|
@@ -3837,34 +4482,28 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3837
4482
|
if (target !== -1 && this.diffHeightManager) {
|
|
3838
4483
|
if (this.lastContainer) this.lastContainer.style.height = `${target}px`;
|
|
3839
4484
|
await this.waitForHeightAppliedDiff(target);
|
|
4485
|
+
this.syncDiffEditorLayoutToContainer();
|
|
3840
4486
|
}
|
|
3841
4487
|
this.performImmediateRevealDiff(line, ticket);
|
|
3842
4488
|
});
|
|
3843
4489
|
}
|
|
3844
4490
|
waitForHeightAppliedDiff(target, timeoutMs = 500) {
|
|
3845
|
-
return
|
|
3846
|
-
const start = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
|
|
3847
|
-
const check = () => {
|
|
3848
|
-
const applied = this.lastContainer ? Number.parseFloat((this.lastContainer.style.height || "").replace("px", "")) || 0 : -1;
|
|
3849
|
-
if (applied >= target - 1) {
|
|
3850
|
-
resolve();
|
|
3851
|
-
return;
|
|
3852
|
-
}
|
|
3853
|
-
if ((typeof performance !== "undefined" && performance.now ? performance.now() : Date.now()) - start > timeoutMs) {
|
|
3854
|
-
resolve();
|
|
3855
|
-
return;
|
|
3856
|
-
}
|
|
3857
|
-
requestAnimationFrame(check);
|
|
3858
|
-
};
|
|
3859
|
-
check();
|
|
3860
|
-
});
|
|
4491
|
+
return waitForElementHeightApplied(this.lastContainer, target, timeoutMs);
|
|
3861
4492
|
}
|
|
3862
4493
|
async createDiffEditor(container, originalCode, modifiedCode, language, currentTheme) {
|
|
3863
|
-
var _me$getScrollHeight2, _me$getOption, _oEditor$onDidContent, _mEditor$onDidContent;
|
|
4494
|
+
var _me$getScrollHeight2, _me$getOption, _oEditor$onDidLayoutC, _mEditor$onDidLayoutC, _oEditor$onDidContent, _mEditor$onDidContent;
|
|
3864
4495
|
this.cleanup();
|
|
3865
4496
|
this.lastContainer = container;
|
|
3866
4497
|
container.style.overflow = "hidden";
|
|
3867
4498
|
container.style.maxHeight = this.maxHeightCSS;
|
|
4499
|
+
container.innerHTML = "";
|
|
4500
|
+
const editorMount = typeof document !== "undefined" ? document.createElement("div") : container;
|
|
4501
|
+
if (editorMount !== container) {
|
|
4502
|
+
editorMount.style.width = "100%";
|
|
4503
|
+
editorMount.style.height = "100%";
|
|
4504
|
+
editorMount.style.overflow = "hidden";
|
|
4505
|
+
container.append(editorMount);
|
|
4506
|
+
}
|
|
3868
4507
|
const lang = processedLanguage(language) || language;
|
|
3869
4508
|
this.originalModel = monaco_shim_exports.editor.createModel(originalCode, lang);
|
|
3870
4509
|
this.modifiedModel = monaco_shim_exports.editor.createModel(modifiedCode, lang);
|
|
@@ -3873,7 +4512,7 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3873
4512
|
const hideUnchangedRegions = this.resolveDiffHideUnchangedRegionsOption();
|
|
3874
4513
|
this.diffHideUnchangedRegionsResolved = hideUnchangedRegions;
|
|
3875
4514
|
this.diffHideUnchangedRegionsDeferred = false;
|
|
3876
|
-
this.diffEditorView = monaco_shim_exports.editor.createDiffEditor(
|
|
4515
|
+
this.diffEditorView = monaco_shim_exports.editor.createDiffEditor(editorMount, {
|
|
3877
4516
|
automaticLayout: true,
|
|
3878
4517
|
scrollBeyondLastLine: false,
|
|
3879
4518
|
renderSideBySide: true,
|
|
@@ -3887,6 +4526,7 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3887
4526
|
...this.options.scrollbar || {}
|
|
3888
4527
|
},
|
|
3889
4528
|
...this.options,
|
|
4529
|
+
glyphMargin: this.resolveDiffGlyphMarginOption(hideUnchangedRegions),
|
|
3890
4530
|
hideUnchangedRegions
|
|
3891
4531
|
});
|
|
3892
4532
|
monaco_shim_exports.editor.setTheme(currentTheme);
|
|
@@ -3923,8 +4563,10 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3923
4563
|
autoScrollInitial: this.autoScrollInitial,
|
|
3924
4564
|
diffAutoScroll: this.diffAutoScroll
|
|
3925
4565
|
});
|
|
3926
|
-
const
|
|
3927
|
-
container.style.minHeight = `${
|
|
4566
|
+
const minVisibleHeight = this.shouldDeferTailAppendForInlineStreaming() ? 0 : Math.min(120, this.maxHeightValue);
|
|
4567
|
+
if (minVisibleHeight > 0) container.style.minHeight = `${minVisibleHeight}px`;
|
|
4568
|
+
else if (typeof container.style.removeProperty === "function") container.style.removeProperty("min-height");
|
|
4569
|
+
else delete container.style.minHeight;
|
|
3928
4570
|
if (this.diffHeightManager) {
|
|
3929
4571
|
this.diffHeightManager.dispose();
|
|
3930
4572
|
this.diffHeightManager = null;
|
|
@@ -3943,6 +4585,7 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3943
4585
|
this.diffComputedVersions = null;
|
|
3944
4586
|
this.diffPresentationDisposables.push(this.diffEditorView.onDidUpdateDiff(() => {
|
|
3945
4587
|
this.diffComputedVersions = this.captureCurrentDiffVersions();
|
|
4588
|
+
this.syncDiffEditorLayoutToContainer();
|
|
3946
4589
|
this.scheduleSyncDiffPresentationDecorations();
|
|
3947
4590
|
}));
|
|
3948
4591
|
this.diffPresentationDisposables.push(oEditor.onDidChangeModelContent(() => {
|
|
@@ -3951,21 +4594,51 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3951
4594
|
this.diffPresentationDisposables.push(mEditor.onDidChangeModelContent(() => {
|
|
3952
4595
|
this.scheduleSyncDiffPresentationDecorations();
|
|
3953
4596
|
}));
|
|
4597
|
+
const originalLayoutDisposable = (_oEditor$onDidLayoutC = oEditor.onDidLayoutChange) === null || _oEditor$onDidLayoutC === void 0 ? void 0 : _oEditor$onDidLayoutC.call(oEditor, () => {
|
|
4598
|
+
this.scheduleSyncDiffPresentationDecorations();
|
|
4599
|
+
});
|
|
4600
|
+
if (originalLayoutDisposable) this.diffPresentationDisposables.push(originalLayoutDisposable);
|
|
4601
|
+
const modifiedLayoutDisposable = (_mEditor$onDidLayoutC = mEditor.onDidLayoutChange) === null || _mEditor$onDidLayoutC === void 0 ? void 0 : _mEditor$onDidLayoutC.call(mEditor, () => {
|
|
4602
|
+
this.scheduleSyncDiffPresentationDecorations();
|
|
4603
|
+
});
|
|
4604
|
+
if (modifiedLayoutDisposable) this.diffPresentationDisposables.push(modifiedLayoutDisposable);
|
|
4605
|
+
if (typeof MutationObserver !== "undefined" && this.lastContainer) {
|
|
4606
|
+
this.diffPresentationObserver = new MutationObserver((mutations) => {
|
|
4607
|
+
const shouldSync = mutations.some((mutation) => {
|
|
4608
|
+
if (mutation.type !== "childList") return false;
|
|
4609
|
+
const nodes = Array.from(mutation.addedNodes).concat(Array.from(mutation.removedNodes));
|
|
4610
|
+
return nodes.some((node) => {
|
|
4611
|
+
if (!(node instanceof HTMLElement)) return false;
|
|
4612
|
+
return node.matches(".line-delete, .inline-deleted-text, .inline-deleted-margin-view-zone") || !!node.querySelector(".line-delete, .inline-deleted-text, .inline-deleted-margin-view-zone") || !!node.closest(".editor.modified .view-zones, .editor.modified .margin-view-zones");
|
|
4613
|
+
});
|
|
4614
|
+
});
|
|
4615
|
+
if (shouldSync) this.scheduleSyncDiffPresentationDecorations();
|
|
4616
|
+
});
|
|
4617
|
+
this.diffPresentationObserver.observe(this.lastContainer, {
|
|
4618
|
+
childList: true,
|
|
4619
|
+
subtree: true
|
|
4620
|
+
});
|
|
4621
|
+
}
|
|
3954
4622
|
(_oEditor$onDidContent = oEditor.onDidContentSizeChange) === null || _oEditor$onDidContent === void 0 || _oEditor$onDidContent.call(oEditor, () => {
|
|
3955
4623
|
this._hasScrollBar = false;
|
|
3956
4624
|
this.rafScheduler.schedule("content-size-change-diff", () => {
|
|
3957
|
-
var _oEditor$getScrollHei, _oEditor$getOption, _this$
|
|
4625
|
+
var _oEditor$getScrollHei, _oEditor$getOption, _this$diffHeightManag5, _this$diffHeightManag6;
|
|
3958
4626
|
this.cachedScrollHeightDiff = ((_oEditor$getScrollHei = oEditor.getScrollHeight) === null || _oEditor$getScrollHei === void 0 ? void 0 : _oEditor$getScrollHei.call(oEditor)) ?? this.cachedScrollHeightDiff;
|
|
3959
4627
|
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;
|
|
3960
4628
|
this.cachedComputedHeightDiff = this.computedHeight();
|
|
3961
|
-
if (
|
|
3962
|
-
|
|
3963
|
-
|
|
4629
|
+
if (this.lastContainer) {
|
|
4630
|
+
const applied = Number.parseFloat(this.lastContainer.style.height || "0") || 0;
|
|
4631
|
+
if (this.cachedComputedHeightDiff > applied + 1 && (this.cachedComputedHeightDiff < this.maxHeightValue - 1 || !this.shouldAvoidOptimisticMaxHeightWriteDiff())) this.lastContainer.style.height = `${this.cachedComputedHeightDiff}px`;
|
|
4632
|
+
}
|
|
4633
|
+
if ((_this$diffHeightManag5 = this.diffHeightManager) === null || _this$diffHeightManag5 === void 0 ? void 0 : _this$diffHeightManag5.isSuppressed()) return;
|
|
4634
|
+
(_this$diffHeightManag6 = this.diffHeightManager) === null || _this$diffHeightManag6 === void 0 || _this$diffHeightManag6.update();
|
|
4635
|
+
this.scheduleSyncDiffEditorLayoutToContainer();
|
|
4636
|
+
const computed$2 = this.cachedComputedHeightDiff;
|
|
3964
4637
|
if (this.lastContainer) {
|
|
3965
4638
|
this.lastContainer.style.overflow = "hidden";
|
|
3966
4639
|
if (computed$2 >= this.maxHeightValue - 1 && this.shouldAutoScrollDiff && !this.diffHideUnchangedRegionsDeferred) {
|
|
3967
|
-
var _this$
|
|
3968
|
-
this.maybeScrollDiffToBottom((_this$
|
|
4640
|
+
var _this$modifiedModel4;
|
|
4641
|
+
this.maybeScrollDiffToBottom((_this$modifiedModel4 = this.modifiedModel) === null || _this$modifiedModel4 === void 0 ? void 0 : _this$modifiedModel4.getLineCount());
|
|
3969
4642
|
}
|
|
3970
4643
|
}
|
|
3971
4644
|
});
|
|
@@ -3973,23 +4646,29 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
3973
4646
|
(_mEditor$onDidContent = mEditor.onDidContentSizeChange) === null || _mEditor$onDidContent === void 0 || _mEditor$onDidContent.call(mEditor, () => {
|
|
3974
4647
|
this._hasScrollBar = false;
|
|
3975
4648
|
this.rafScheduler.schedule("content-size-change-diff", () => {
|
|
3976
|
-
var _mEditor$getScrollHei, _mEditor$getOption, _this$
|
|
4649
|
+
var _mEditor$getScrollHei, _mEditor$getOption, _this$diffHeightManag7, _this$diffHeightManag8;
|
|
3977
4650
|
this.cachedScrollHeightDiff = ((_mEditor$getScrollHei = mEditor.getScrollHeight) === null || _mEditor$getScrollHei === void 0 ? void 0 : _mEditor$getScrollHei.call(mEditor)) ?? this.cachedScrollHeightDiff;
|
|
3978
4651
|
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;
|
|
3979
4652
|
this.cachedComputedHeightDiff = this.computedHeight();
|
|
3980
|
-
if (
|
|
3981
|
-
|
|
3982
|
-
|
|
4653
|
+
if (this.lastContainer) {
|
|
4654
|
+
const applied = Number.parseFloat(this.lastContainer.style.height || "0") || 0;
|
|
4655
|
+
if (this.cachedComputedHeightDiff > applied + 1 && (this.cachedComputedHeightDiff < this.maxHeightValue - 1 || !this.shouldAvoidOptimisticMaxHeightWriteDiff())) this.lastContainer.style.height = `${this.cachedComputedHeightDiff}px`;
|
|
4656
|
+
}
|
|
4657
|
+
if ((_this$diffHeightManag7 = this.diffHeightManager) === null || _this$diffHeightManag7 === void 0 ? void 0 : _this$diffHeightManag7.isSuppressed()) return;
|
|
4658
|
+
(_this$diffHeightManag8 = this.diffHeightManager) === null || _this$diffHeightManag8 === void 0 || _this$diffHeightManag8.update();
|
|
4659
|
+
this.scheduleSyncDiffEditorLayoutToContainer();
|
|
4660
|
+
const computed$2 = this.cachedComputedHeightDiff;
|
|
3983
4661
|
if (this.lastContainer) {
|
|
3984
4662
|
this.lastContainer.style.overflow = "hidden";
|
|
3985
4663
|
if (computed$2 >= this.maxHeightValue - 1 && this.shouldAutoScrollDiff && !this.diffHideUnchangedRegionsDeferred) {
|
|
3986
|
-
var _this$
|
|
3987
|
-
this.maybeScrollDiffToBottom((_this$
|
|
4664
|
+
var _this$modifiedModel5;
|
|
4665
|
+
this.maybeScrollDiffToBottom((_this$modifiedModel5 = this.modifiedModel) === null || _this$modifiedModel5 === void 0 ? void 0 : _this$modifiedModel5.getLineCount());
|
|
3988
4666
|
}
|
|
3989
4667
|
}
|
|
3990
4668
|
});
|
|
3991
4669
|
});
|
|
3992
4670
|
mEditor.onDidChangeModelContent(() => {
|
|
4671
|
+
if (this.programmaticModifiedContentChangeDepth > 0) return;
|
|
3993
4672
|
this.lastKnownModifiedDirty = true;
|
|
3994
4673
|
this.rafScheduler.schedule("sync-last-known-modified", () => this.syncLastKnownModified());
|
|
3995
4674
|
});
|
|
@@ -4020,13 +4699,14 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4020
4699
|
const modifiedTailAppend = modifiedCode !== prevM && modifiedCode.startsWith(prevM) && prevM.length < modifiedCode.length;
|
|
4021
4700
|
const hasContentChange = originalCode !== prevO || modifiedCode !== prevM;
|
|
4022
4701
|
if (originalCode !== prevO || modifiedCode !== prevM) this.markDiffStreamingActivity();
|
|
4702
|
+
const deferTailAppendForInline = this.shouldDeferTailAppendForInlineStreaming();
|
|
4023
4703
|
let didImmediate = false;
|
|
4024
|
-
if (originalTailAppend) {
|
|
4704
|
+
if (originalTailAppend && !deferTailAppendForInline) {
|
|
4025
4705
|
this.appendOriginal(originalCode.slice(prevO.length));
|
|
4026
4706
|
this.lastKnownOriginalCode = originalCode;
|
|
4027
4707
|
didImmediate = true;
|
|
4028
4708
|
}
|
|
4029
|
-
if (modifiedTailAppend) {
|
|
4709
|
+
if (modifiedTailAppend && !deferTailAppendForInline) {
|
|
4030
4710
|
this.appendModified(modifiedCode.slice(prevM.length));
|
|
4031
4711
|
this.lastKnownModifiedCode = modifiedCode;
|
|
4032
4712
|
didImmediate = true;
|
|
@@ -4040,6 +4720,16 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4040
4720
|
this.rafScheduler.schedule("diff", () => this.flushPendingDiffUpdate());
|
|
4041
4721
|
} else if (didImmediate) {}
|
|
4042
4722
|
}
|
|
4723
|
+
shouldDeferTailAppendForInlineStreaming() {
|
|
4724
|
+
var _this$lastContainer11, _this$lastContainer12, _this$lastContainer13;
|
|
4725
|
+
const renderSideBySide = this.options.renderSideBySide ?? true;
|
|
4726
|
+
if (renderSideBySide === false) return true;
|
|
4727
|
+
const useInlineViewWhenSpaceIsLimited = this.options.useInlineViewWhenSpaceIsLimited ?? true;
|
|
4728
|
+
if (!useInlineViewWhenSpaceIsLimited) return false;
|
|
4729
|
+
const breakpoint = this.options.renderSideBySideInlineBreakpoint ?? 900;
|
|
4730
|
+
const width = ((_this$lastContainer11 = this.lastContainer) === null || _this$lastContainer11 === void 0 || (_this$lastContainer12 = _this$lastContainer11.getBoundingClientRect) === null || _this$lastContainer12 === void 0 ? void 0 : _this$lastContainer12.call(_this$lastContainer11).width) ?? ((_this$lastContainer13 = this.lastContainer) === null || _this$lastContainer13 === void 0 ? void 0 : _this$lastContainer13.clientWidth) ?? 0;
|
|
4731
|
+
return width > 0 && width <= breakpoint;
|
|
4732
|
+
}
|
|
4043
4733
|
updateOriginal(newCode, codeLanguage) {
|
|
4044
4734
|
if (!this.diffEditorView || !this.originalModel) return;
|
|
4045
4735
|
if (codeLanguage) {
|
|
@@ -4077,10 +4767,11 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4077
4767
|
this.applyMinimalEditToModel(this.modifiedModel, prevAfterFlush, newCode);
|
|
4078
4768
|
const newLine = this.modifiedModel.getLineCount();
|
|
4079
4769
|
if (newLine !== prevLine) {
|
|
4770
|
+
this.eagerlyGrowDiffContainerHeight();
|
|
4080
4771
|
const shouldImmediate = this.shouldPerformImmediateRevealDiff();
|
|
4081
4772
|
if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
|
|
4082
4773
|
const computed$2 = this.computedHeight();
|
|
4083
|
-
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) {
|
|
4774
|
+
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer && !this.shouldAvoidOptimisticMaxHeightWriteDiff()) {
|
|
4084
4775
|
this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
4085
4776
|
this.lastContainer.style.overflow = "hidden";
|
|
4086
4777
|
}
|
|
@@ -4121,7 +4812,7 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4121
4812
|
if (this.modifiedModel && this.modifiedModel.getLanguageId() !== language) monaco_shim_exports.editor.setModelLanguage(this.modifiedModel, language);
|
|
4122
4813
|
}
|
|
4123
4814
|
async setDiffModels(models, options = {}) {
|
|
4124
|
-
var _this$
|
|
4815
|
+
var _this$originalModel3, _this$modifiedModel6, _this$diffEditorView$4, _this$diffEditorView$5, _this$diffEditorView$6, _this$diffEditorView$7;
|
|
4125
4816
|
if (!this.diffEditorView) return;
|
|
4126
4817
|
const transitionRequestId = ++this.diffModelTransitionRequestId;
|
|
4127
4818
|
this.preserveNativeDiffDecorationsOnStaleAppend = false;
|
|
@@ -4129,8 +4820,8 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4129
4820
|
const nextOriginal = models.original;
|
|
4130
4821
|
const nextModified = models.modified;
|
|
4131
4822
|
this.applyDiffModelLanguage(models, options.codeLanguage);
|
|
4132
|
-
const currentOriginalValue = this.lastKnownOriginalCode ?? ((_this$
|
|
4133
|
-
const currentModifiedValue = this.lastKnownModifiedCode ?? ((_this$
|
|
4823
|
+
const currentOriginalValue = this.lastKnownOriginalCode ?? ((_this$originalModel3 = this.originalModel) === null || _this$originalModel3 === void 0 ? void 0 : _this$originalModel3.getValue()) ?? null;
|
|
4824
|
+
const currentModifiedValue = this.lastKnownModifiedCode ?? ((_this$modifiedModel6 = this.modifiedModel) === null || _this$modifiedModel6 === void 0 ? void 0 : _this$modifiedModel6.getValue()) ?? null;
|
|
4134
4825
|
const nextOriginalValue = nextOriginal.getValue();
|
|
4135
4826
|
const nextModifiedValue = nextModified.getValue();
|
|
4136
4827
|
const sameContent = currentOriginalValue === nextOriginalValue && currentModifiedValue === nextModifiedValue;
|
|
@@ -4179,14 +4870,15 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4179
4870
|
const currentOriginal = this.originalModel;
|
|
4180
4871
|
const currentModified = this.modifiedModel;
|
|
4181
4872
|
const shouldRestorePersistedUnchangedState = preserveViewState && !sameContent;
|
|
4873
|
+
const shouldRestoreSavedModelState = options.preserveModelState ?? true;
|
|
4182
4874
|
const preservedScrollPosition = preserveViewState ? this.captureDiffScrollPosition() : null;
|
|
4183
4875
|
const preservedViewportAnchor = preserveViewState && sameContent ? this.captureModifiedViewportAnchor() : null;
|
|
4184
|
-
const viewState = preserveViewState ? this.diffEditorView.saveViewState() : null;
|
|
4876
|
+
const viewState = preserveViewState && shouldRestoreSavedModelState ? this.diffEditorView.saveViewState() : null;
|
|
4185
4877
|
this.queuePendingDiffScrollRestore(preservedScrollPosition, shouldRestorePersistedUnchangedState ? 2 : 0);
|
|
4186
4878
|
if (shouldRestorePersistedUnchangedState) this.capturePersistedDiffUnchangedState();
|
|
4187
4879
|
const applyModelSwap = () => {
|
|
4188
|
-
var _this$
|
|
4189
|
-
(_this$
|
|
4880
|
+
var _this$diffEditorView23;
|
|
4881
|
+
(_this$diffEditorView23 = this.diffEditorView) === null || _this$diffEditorView23 === void 0 || _this$diffEditorView23.setModel(nextModelTarget);
|
|
4190
4882
|
};
|
|
4191
4883
|
if (preserveViewState) this.withLockedDiffScrollPosition(applyModelSwap);
|
|
4192
4884
|
else applyModelSwap();
|
|
@@ -4201,8 +4893,8 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4201
4893
|
this.lastKnownModifiedLineCount = nextModified.getLineCount();
|
|
4202
4894
|
this.lastKnownModifiedDirty = false;
|
|
4203
4895
|
this._hasScrollBar = false;
|
|
4204
|
-
this.cachedScrollHeightDiff = ((_this$diffEditorView$
|
|
4205
|
-
this.cachedLineHeightDiff = ((_this$diffEditorView$
|
|
4896
|
+
this.cachedScrollHeightDiff = ((_this$diffEditorView$4 = (_this$diffEditorView$5 = this.diffEditorView.getModifiedEditor()).getScrollHeight) === null || _this$diffEditorView$4 === void 0 ? void 0 : _this$diffEditorView$4.call(_this$diffEditorView$5)) ?? null;
|
|
4897
|
+
this.cachedLineHeightDiff = ((_this$diffEditorView$6 = (_this$diffEditorView$7 = this.diffEditorView.getModifiedEditor()).getOption) === null || _this$diffEditorView$6 === void 0 ? void 0 : _this$diffEditorView$6.call(_this$diffEditorView$7, monaco_shim_exports.editor.EditorOption.lineHeight)) ?? null;
|
|
4206
4898
|
this.cachedComputedHeightDiff = this.computedHeight();
|
|
4207
4899
|
this.diffHunkLineChanges = this.getEffectiveLineChanges();
|
|
4208
4900
|
this.hideDiffHunkActions();
|
|
@@ -4265,6 +4957,7 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4265
4957
|
this.revealTicketDiff = 0;
|
|
4266
4958
|
this.lastRevealLineDiff = null;
|
|
4267
4959
|
this.diffPersistedUnchangedModelState = null;
|
|
4960
|
+
this.diffPreviousUnchangedModelState = null;
|
|
4268
4961
|
this.pendingDiffScrollRestorePosition = null;
|
|
4269
4962
|
this.pendingDiffScrollRestoreBudget = 0;
|
|
4270
4963
|
this.diffHideUnchangedRegionsResolved = null;
|
|
@@ -4292,7 +4985,11 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4292
4985
|
this.revealTicketDiff = 0;
|
|
4293
4986
|
this.lastRevealLineDiff = null;
|
|
4294
4987
|
this.diffPersistedUnchangedModelState = null;
|
|
4988
|
+
this.diffPreviousUnchangedModelState = null;
|
|
4295
4989
|
this.diffHideUnchangedRegionsDeferred = false;
|
|
4990
|
+
this.clearInlineDiffStreamingPresentationIdleTimer();
|
|
4991
|
+
this.inlineDiffStreamingPresentationActive = false;
|
|
4992
|
+
this.resetInlineDiffStreamingHeightFloor();
|
|
4296
4993
|
}
|
|
4297
4994
|
syncLastKnownModified() {
|
|
4298
4995
|
if (!this.diffEditorView || !this.lastKnownModifiedDirty) return;
|
|
@@ -4348,10 +5045,11 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4348
5045
|
this.lastKnownModifiedCode = modified;
|
|
4349
5046
|
const newMLineCount = m.getLineCount();
|
|
4350
5047
|
if (newMLineCount !== prevMLineCount) {
|
|
5048
|
+
this.eagerlyGrowDiffContainerHeight();
|
|
4351
5049
|
const shouldImmediate = this.shouldPerformImmediateRevealDiff();
|
|
4352
5050
|
if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
|
|
4353
5051
|
const computed$2 = this.computedHeight();
|
|
4354
|
-
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) {
|
|
5052
|
+
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer && !this.shouldAvoidOptimisticMaxHeightWriteDiff()) {
|
|
4355
5053
|
this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
4356
5054
|
this.lastContainer.style.overflow = "hidden";
|
|
4357
5055
|
}
|
|
@@ -4432,15 +5130,18 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4432
5130
|
const lastColumn$1 = model.getLineMaxColumn(prevLine);
|
|
4433
5131
|
const range$1 = new monaco_shim_exports.Range(prevLine, lastColumn$1, prevLine, lastColumn$1);
|
|
4434
5132
|
this.preserveNativeDiffDecorationsOnStaleAppend = true;
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
5133
|
+
this.runAsProgrammaticModifiedContentChange(() => {
|
|
5134
|
+
model.applyEdits([{
|
|
5135
|
+
range: range$1,
|
|
5136
|
+
text: part,
|
|
5137
|
+
forceMoveMarkers: true
|
|
5138
|
+
}]);
|
|
5139
|
+
});
|
|
4440
5140
|
this.lastKnownModifiedCode = model.getValue();
|
|
4441
5141
|
const newLine$1 = model.getLineCount();
|
|
4442
5142
|
this.lastKnownModifiedLineCount = newLine$1;
|
|
4443
5143
|
await new Promise((resolve) => typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame(resolve) : setTimeout(resolve, 0));
|
|
5144
|
+
this.eagerlyGrowDiffContainerHeight();
|
|
4444
5145
|
const shouldImmediate$1 = this.shouldPerformImmediateRevealDiff();
|
|
4445
5146
|
log("diff", "flushAppendBufferDiff chunk metrics", {
|
|
4446
5147
|
idx,
|
|
@@ -4450,7 +5151,7 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4450
5151
|
});
|
|
4451
5152
|
if (shouldImmediate$1) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
|
|
4452
5153
|
const computed$3 = this.computedHeight();
|
|
4453
|
-
if (computed$3 >= this.maxHeightValue - 1 && this.lastContainer) {
|
|
5154
|
+
if (computed$3 >= this.maxHeightValue - 1 && this.lastContainer && !this.shouldAvoidOptimisticMaxHeightWriteDiff()) {
|
|
4454
5155
|
this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
4455
5156
|
this.lastContainer.style.overflow = "hidden";
|
|
4456
5157
|
}
|
|
@@ -4471,33 +5172,38 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4471
5172
|
const lastColumn = model.getLineMaxColumn(prevLine);
|
|
4472
5173
|
const range = new monaco_shim_exports.Range(prevLine, lastColumn, prevLine, lastColumn);
|
|
4473
5174
|
this.preserveNativeDiffDecorationsOnStaleAppend = true;
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
5175
|
+
this.runAsProgrammaticModifiedContentChange(() => {
|
|
5176
|
+
model.applyEdits([{
|
|
5177
|
+
range,
|
|
5178
|
+
text,
|
|
5179
|
+
forceMoveMarkers: true
|
|
5180
|
+
}]);
|
|
5181
|
+
});
|
|
4479
5182
|
this.lastKnownModifiedCode = model.getValue();
|
|
4480
5183
|
const newLine = model.getLineCount();
|
|
4481
5184
|
this.lastKnownModifiedLineCount = newLine;
|
|
5185
|
+
this.eagerlyGrowDiffContainerHeight();
|
|
4482
5186
|
const shouldImmediate = this.shouldPerformImmediateRevealDiff();
|
|
4483
5187
|
if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
|
|
4484
5188
|
const computed$2 = this.computedHeight();
|
|
4485
|
-
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
5189
|
+
if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer && !this.shouldAvoidOptimisticMaxHeightWriteDiff()) this.lastContainer.style.height = `${this.maxHeightValue}px`;
|
|
4486
5190
|
if (shouldImmediate) this.scheduleImmediateRevealAfterLayoutDiff(newLine);
|
|
4487
5191
|
else this.maybeScrollDiffToBottom(newLine, prevLine);
|
|
4488
5192
|
if (suppressedByFlush) watcherApi.setSuppressed(false);
|
|
4489
5193
|
try {
|
|
4490
|
-
var _this$
|
|
4491
|
-
this.lastScrollTopDiff = ((_this$
|
|
5194
|
+
var _this$diffEditorView24, _this$diffEditorView25, _this$diffEditorView26;
|
|
5195
|
+
this.lastScrollTopDiff = ((_this$diffEditorView24 = this.diffEditorView) === null || _this$diffEditorView24 === void 0 || (_this$diffEditorView26 = (_this$diffEditorView25 = _this$diffEditorView24.getModifiedEditor()).getScrollTop) === null || _this$diffEditorView26 === void 0 ? void 0 : _this$diffEditorView26.call(_this$diffEditorView25)) ?? this.lastScrollTopDiff;
|
|
4492
5196
|
} catch {}
|
|
4493
5197
|
}
|
|
4494
5198
|
applyMinimalEditToModel(model, prev, next) {
|
|
4495
|
-
const maxChars =
|
|
4496
|
-
const ratio =
|
|
5199
|
+
const maxChars = this.minimalEditMaxCharsValue;
|
|
5200
|
+
const ratio = this.minimalEditMaxChangeRatioValue;
|
|
4497
5201
|
const maxLen = Math.max(prev.length, next.length);
|
|
4498
5202
|
const changeRatio = maxLen > 0 ? Math.abs(next.length - prev.length) / maxLen : 0;
|
|
4499
5203
|
if (prev.length + next.length > maxChars || changeRatio > ratio) {
|
|
4500
|
-
|
|
5204
|
+
this.applyModelEdit(model, () => {
|
|
5205
|
+
model.setValue(next);
|
|
5206
|
+
});
|
|
4501
5207
|
if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
|
|
4502
5208
|
return;
|
|
4503
5209
|
}
|
|
@@ -4507,11 +5213,13 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4507
5213
|
const rangeStart = model.getPositionAt(start);
|
|
4508
5214
|
const rangeEnd = model.getPositionAt(endPrevIncl + 1);
|
|
4509
5215
|
const range = new monaco_shim_exports.Range(rangeStart.lineNumber, rangeStart.column, rangeEnd.lineNumber, rangeEnd.column);
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
5216
|
+
this.applyModelEdit(model, () => {
|
|
5217
|
+
model.applyEdits([{
|
|
5218
|
+
range,
|
|
5219
|
+
text: replaceText,
|
|
5220
|
+
forceMoveMarkers: true
|
|
5221
|
+
}]);
|
|
5222
|
+
});
|
|
4515
5223
|
if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
|
|
4516
5224
|
}
|
|
4517
5225
|
appendToModel(model, appendText) {
|
|
@@ -4519,13 +5227,30 @@ var DiffEditorManager = class DiffEditorManager {
|
|
|
4519
5227
|
const lastLine = model.getLineCount();
|
|
4520
5228
|
const lastColumn = model.getLineMaxColumn(lastLine);
|
|
4521
5229
|
const range = new monaco_shim_exports.Range(lastLine, lastColumn, lastLine, lastColumn);
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
5230
|
+
this.applyModelEdit(model, () => {
|
|
5231
|
+
model.applyEdits([{
|
|
5232
|
+
range,
|
|
5233
|
+
text: appendText,
|
|
5234
|
+
forceMoveMarkers: true
|
|
5235
|
+
}]);
|
|
5236
|
+
});
|
|
4527
5237
|
if (model === this.modifiedModel) this.lastKnownModifiedLineCount = model.getLineCount();
|
|
4528
5238
|
}
|
|
5239
|
+
applyModelEdit(model, fn) {
|
|
5240
|
+
if (model === this.modifiedModel) {
|
|
5241
|
+
this.runAsProgrammaticModifiedContentChange(fn);
|
|
5242
|
+
return;
|
|
5243
|
+
}
|
|
5244
|
+
fn();
|
|
5245
|
+
}
|
|
5246
|
+
runAsProgrammaticModifiedContentChange(fn) {
|
|
5247
|
+
this.programmaticModifiedContentChangeDepth += 1;
|
|
5248
|
+
try {
|
|
5249
|
+
fn();
|
|
5250
|
+
} finally {
|
|
5251
|
+
this.programmaticModifiedContentChangeDepth -= 1;
|
|
5252
|
+
}
|
|
5253
|
+
}
|
|
4529
5254
|
};
|
|
4530
5255
|
|
|
4531
5256
|
//#endregion
|
|
@@ -4537,6 +5262,8 @@ var EditorManager = class {
|
|
|
4537
5262
|
pendingUpdate = null;
|
|
4538
5263
|
_hasScrollBar = false;
|
|
4539
5264
|
updateThrottleMs = 50;
|
|
5265
|
+
minimalEditMaxCharsValue = minimalEditMaxChars;
|
|
5266
|
+
minimalEditMaxChangeRatioValue = minimalEditMaxChangeRatio;
|
|
4540
5267
|
lastUpdateFlushTime = 0;
|
|
4541
5268
|
updateThrottleTimer = null;
|
|
4542
5269
|
shouldAutoScroll = true;
|
|
@@ -4592,6 +5319,8 @@ var EditorManager = class {
|
|
|
4592
5319
|
this.revealDebounceMsOption = revealDebounceMsOption;
|
|
4593
5320
|
this.updateThrottleMsOption = updateThrottleMsOption;
|
|
4594
5321
|
this.updateThrottleMs = this.updateThrottleMsOption ?? this.options.updateThrottleMs ?? 50;
|
|
5322
|
+
this.minimalEditMaxCharsValue = this.options.minimalEditMaxChars ?? minimalEditMaxChars;
|
|
5323
|
+
this.minimalEditMaxChangeRatioValue = this.options.minimalEditMaxChangeRatio ?? minimalEditMaxChangeRatio;
|
|
4595
5324
|
}
|
|
4596
5325
|
cancelRafs() {
|
|
4597
5326
|
this.rafScheduler.cancel("update");
|
|
@@ -4726,7 +5455,7 @@ var EditorManager = class {
|
|
|
4726
5455
|
}
|
|
4727
5456
|
performReveal(line, ticket) {
|
|
4728
5457
|
this.rafScheduler.schedule("reveal", () => {
|
|
4729
|
-
var _editor;
|
|
5458
|
+
var _editor$1;
|
|
4730
5459
|
if (ticket !== this.revealTicket) {
|
|
4731
5460
|
this.dlog("performReveal skipped, stale ticket", ticket, "current", this.revealTicket);
|
|
4732
5461
|
return;
|
|
@@ -4734,8 +5463,8 @@ var EditorManager = class {
|
|
|
4734
5463
|
this.dlog("performReveal executing, ticket=", ticket, "line=", line);
|
|
4735
5464
|
const strategy = this.revealStrategyOption ?? this.options.revealStrategy ?? "centerIfOutside";
|
|
4736
5465
|
this.dlog("performReveal strategy=", strategy);
|
|
4737
|
-
const ScrollType =
|
|
4738
|
-
const smooth = ScrollType && typeof ScrollType.Smooth !== "undefined" ? ScrollType.Smooth : void 0;
|
|
5466
|
+
const ScrollType$1 = ScrollType || ((_editor$1 = monaco_shim_exports.editor) === null || _editor$1 === void 0 ? void 0 : _editor$1.ScrollType);
|
|
5467
|
+
const smooth = ScrollType$1 && typeof ScrollType$1.Smooth !== "undefined" ? ScrollType$1.Smooth : void 0;
|
|
4739
5468
|
try {
|
|
4740
5469
|
if (strategy === "bottom") if (typeof smooth !== "undefined") this.editorView.revealLine(line, smooth);
|
|
4741
5470
|
else this.editorView.revealLine(line);
|
|
@@ -4759,8 +5488,8 @@ var EditorManager = class {
|
|
|
4759
5488
|
this.dlog("performImmediateReveal skipped, stale ticket", ticket, "current", this.revealTicket);
|
|
4760
5489
|
return;
|
|
4761
5490
|
}
|
|
4762
|
-
const ScrollType =
|
|
4763
|
-
const immediate = ScrollType && typeof ScrollType.Immediate !== "undefined" ? ScrollType.Immediate : void 0;
|
|
5491
|
+
const ScrollType$1 = ScrollType || ((_editor2 = monaco_shim_exports.editor) === null || _editor2 === void 0 ? void 0 : _editor2.ScrollType);
|
|
5492
|
+
const immediate = ScrollType$1 && typeof ScrollType$1.Immediate !== "undefined" ? ScrollType$1.Immediate : void 0;
|
|
4764
5493
|
if (typeof immediate !== "undefined") this.editorView.revealLine(line, immediate);
|
|
4765
5494
|
else this.editorView.revealLine(line);
|
|
4766
5495
|
} catch {}
|
|
@@ -4772,8 +5501,8 @@ var EditorManager = class {
|
|
|
4772
5501
|
try {
|
|
4773
5502
|
var _editor3;
|
|
4774
5503
|
if (!this.editorView) return;
|
|
4775
|
-
const ScrollType =
|
|
4776
|
-
const immediate = ScrollType && typeof ScrollType.Immediate !== "undefined" ? ScrollType.Immediate : void 0;
|
|
5504
|
+
const ScrollType$1 = ScrollType || ((_editor3 = monaco_shim_exports.editor) === null || _editor3 === void 0 ? void 0 : _editor3.ScrollType);
|
|
5505
|
+
const immediate = ScrollType$1 && typeof ScrollType$1.Immediate !== "undefined" ? ScrollType$1.Immediate : void 0;
|
|
4777
5506
|
if (typeof immediate !== "undefined") this.editorView.revealLine(line, immediate);
|
|
4778
5507
|
else this.editorView.revealLine(line);
|
|
4779
5508
|
} catch {}
|
|
@@ -5041,7 +5770,6 @@ var EditorManager = class {
|
|
|
5041
5770
|
if (newCode.startsWith(prevCode) && prevCode.length < newCode.length) {
|
|
5042
5771
|
const suffix = newCode.slice(prevCode.length);
|
|
5043
5772
|
if (suffix) this.appendCode(suffix, codeLanguage);
|
|
5044
|
-
this.lastKnownCode = newCode;
|
|
5045
5773
|
return;
|
|
5046
5774
|
}
|
|
5047
5775
|
const prevLineCount = model.getLineCount();
|
|
@@ -5074,8 +5802,8 @@ var EditorManager = class {
|
|
|
5074
5802
|
if (!this.editorView) return;
|
|
5075
5803
|
const model = this.editorView.getModel();
|
|
5076
5804
|
if (!model) return;
|
|
5077
|
-
const maxChars =
|
|
5078
|
-
const ratio =
|
|
5805
|
+
const maxChars = this.minimalEditMaxCharsValue;
|
|
5806
|
+
const ratio = this.minimalEditMaxChangeRatioValue;
|
|
5079
5807
|
const maxLen = Math.max(prev.length, next.length);
|
|
5080
5808
|
const changeRatio = maxLen > 0 ? Math.abs(next.length - prev.length) / maxLen : 0;
|
|
5081
5809
|
if (prev.length + next.length > maxChars || changeRatio > ratio) {
|
|
@@ -5159,6 +5887,10 @@ var EditorManager = class {
|
|
|
5159
5887
|
getEditorView() {
|
|
5160
5888
|
return this.editorView;
|
|
5161
5889
|
}
|
|
5890
|
+
getCode() {
|
|
5891
|
+
var _this$editorView9;
|
|
5892
|
+
return ((_this$editorView9 = this.editorView) === null || _this$editorView9 === void 0 || (_this$editorView9 = _this$editorView9.getModel()) === null || _this$editorView9 === void 0 ? void 0 : _this$editorView9.getValue()) ?? null;
|
|
5893
|
+
}
|
|
5162
5894
|
setUpdateThrottleMs(ms) {
|
|
5163
5895
|
this.updateThrottleMs = ms;
|
|
5164
5896
|
if (!this.updateThrottleMs && this.updateThrottleTimer != null) {
|
|
@@ -5341,6 +6073,14 @@ async function ensureMonacoHighlighter(themes, languages$1) {
|
|
|
5341
6073
|
*/
|
|
5342
6074
|
function clearHighlighterCache() {
|
|
5343
6075
|
highlighterCache.clear();
|
|
6076
|
+
monacoHighlighterPromise = null;
|
|
6077
|
+
lastPatchedHighlighter = null;
|
|
6078
|
+
lastPatchedLanguages = /* @__PURE__ */ new Set();
|
|
6079
|
+
monacoThemeByKey.clear();
|
|
6080
|
+
monacoLanguageSet.clear();
|
|
6081
|
+
themeRegisterPromise = null;
|
|
6082
|
+
languagesRegistered = false;
|
|
6083
|
+
currentLanguages = [];
|
|
5344
6084
|
}
|
|
5345
6085
|
function serializeThemes(themes) {
|
|
5346
6086
|
return JSON.stringify(themes.map((t) => typeof t === "string" ? t : t.name ?? JSON.stringify(t)).sort());
|
|
@@ -5580,15 +6320,13 @@ let globalAppliedThemeName = null;
|
|
|
5580
6320
|
function useMonaco(monacoOptions = {}) {
|
|
5581
6321
|
var _monacoOptions$themes;
|
|
5582
6322
|
const disposals = [];
|
|
5583
|
-
|
|
5584
|
-
if (monacoOptions.isCleanOnBeforeCreate ?? true) disposals.length = 0;
|
|
6323
|
+
const pendingCreateDisposables = /* @__PURE__ */ new Map();
|
|
5585
6324
|
let editorView = null;
|
|
5586
6325
|
let editorMgr = null;
|
|
5587
6326
|
let diffEditorView = null;
|
|
5588
6327
|
let diffMgr = null;
|
|
5589
6328
|
let originalModel = null;
|
|
5590
6329
|
let modifiedModel = null;
|
|
5591
|
-
let _hasScrollBar = false;
|
|
5592
6330
|
const themes = monacoOptions.themes && ((_monacoOptions$themes = monacoOptions.themes) === null || _monacoOptions$themes === void 0 ? void 0 : _monacoOptions$themes.length) ? monacoOptions.themes : defaultThemes;
|
|
5593
6331
|
if (!Array.isArray(themes) || themes.length < 2) throw new Error("Monaco themes must be an array with at least two themes: [darkTheme, lightTheme]");
|
|
5594
6332
|
const languages$1 = monacoOptions.languages ?? defaultLanguages;
|
|
@@ -5609,22 +6347,12 @@ function useMonaco(monacoOptions = {}) {
|
|
|
5609
6347
|
};
|
|
5610
6348
|
const maxHeightValue = getMaxHeightValue();
|
|
5611
6349
|
const maxHeightCSS = getMaxHeightCSS();
|
|
5612
|
-
let
|
|
5613
|
-
let
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
let updateThrottleMs = monacoOptions.updateThrottleMs ?? 50;
|
|
5617
|
-
let lastFlushTime = 0;
|
|
5618
|
-
let updateThrottleTimer = null;
|
|
5619
|
-
let pendingUpdate = null;
|
|
5620
|
-
let shouldAutoScroll = true;
|
|
5621
|
-
const cachedComputedHeight = null;
|
|
5622
|
-
const appendBuffer = [];
|
|
5623
|
-
let appendBufferScheduled = false;
|
|
6350
|
+
let createRequestSeq = 0;
|
|
6351
|
+
let activeCreateRequestId = null;
|
|
6352
|
+
let activeCreateKind = null;
|
|
6353
|
+
let queuedEditorUpdateDuringCreate = null;
|
|
5624
6354
|
const currentTheme = computed$1(() => monacoOptions.theme ?? (typeof themes[0] === "string" ? themes[0] : themes[0].name));
|
|
5625
6355
|
let requestedThemeName = monacoOptions.theme ?? globalRequestedThemeName ?? currentTheme.value;
|
|
5626
|
-
let themeWatcher = null;
|
|
5627
|
-
const rafScheduler = createRafScheduler();
|
|
5628
6356
|
async function tryLoadAndSetShikiTheme(highlighter, themeName) {
|
|
5629
6357
|
if (!highlighter || typeof highlighter.setTheme !== "function") return;
|
|
5630
6358
|
try {
|
|
@@ -5695,326 +6423,206 @@ function useMonaco(monacoOptions = {}) {
|
|
|
5695
6423
|
const list = availableNames.includes(themeName) ? themes : themes.concat(themeName);
|
|
5696
6424
|
await registerMonacoThemes(list, languages$1);
|
|
5697
6425
|
}
|
|
5698
|
-
function
|
|
5699
|
-
|
|
5700
|
-
if (_hasScrollBar) return true;
|
|
5701
|
-
const ch = cachedComputedHeight ?? computedHeight(editorView);
|
|
5702
|
-
return _hasScrollBar = editorView.getScrollHeight() > ch + padding / 2;
|
|
5703
|
-
}
|
|
5704
|
-
let revealDebounceId = null;
|
|
5705
|
-
const revealDebounceMs = 75;
|
|
5706
|
-
function maybeScrollToBottom(targetLine) {
|
|
5707
|
-
if (autoScrollOnUpdate && shouldAutoScroll && hasVerticalScrollbar()) {
|
|
5708
|
-
const model = editorView.getModel();
|
|
5709
|
-
const line = targetLine ?? (model === null || model === void 0 ? void 0 : model.getLineCount()) ?? 1;
|
|
5710
|
-
if (revealDebounceId != null) {
|
|
5711
|
-
clearTimeout(revealDebounceId);
|
|
5712
|
-
revealDebounceId = null;
|
|
5713
|
-
}
|
|
5714
|
-
revealDebounceId = setTimeout(() => {
|
|
5715
|
-
revealDebounceId = null;
|
|
5716
|
-
rafScheduler.schedule("reveal", () => {
|
|
5717
|
-
try {
|
|
5718
|
-
var _editor;
|
|
5719
|
-
const ScrollType = monaco_shim_exports.ScrollType || ((_editor = monaco_shim_exports.editor) === null || _editor === void 0 ? void 0 : _editor.ScrollType);
|
|
5720
|
-
if (ScrollType && typeof ScrollType.Smooth !== "undefined") editorView.revealLineInCenterIfOutsideViewport(line, ScrollType.Smooth);
|
|
5721
|
-
else editorView.revealLineInCenterIfOutsideViewport(line);
|
|
5722
|
-
} catch {}
|
|
5723
|
-
});
|
|
5724
|
-
}, revealDebounceMs);
|
|
5725
|
-
}
|
|
6426
|
+
function resolveRequestedThemeName() {
|
|
6427
|
+
return requestedThemeName ?? globalRequestedThemeName ?? monacoOptions.theme ?? currentTheme.value;
|
|
5726
6428
|
}
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
disposals.length = 0;
|
|
5733
|
-
}
|
|
5734
|
-
if (monacoOptions.onBeforeCreate) {
|
|
5735
|
-
const ds = monacoOptions.onBeforeCreate(monaco_shim_exports);
|
|
5736
|
-
if (ds) disposals.push(...ds);
|
|
5737
|
-
}
|
|
5738
|
-
const initialThemeName = monacoOptions.theme ?? requestedThemeName ?? globalRequestedThemeName ?? currentTheme.value;
|
|
5739
|
-
await ensureThemeRegistered(initialThemeName);
|
|
5740
|
-
editorMgr = new EditorManager(monacoOptions, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, monacoOptions.revealDebounceMs, updateThrottleMs);
|
|
5741
|
-
editorView = await editorMgr.createEditor(container, code, language, initialThemeName);
|
|
5742
|
-
if (pendingUpdate && editorMgr) {
|
|
5743
|
-
const { code: queuedCode, lang: queuedLang } = pendingUpdate;
|
|
5744
|
-
pendingUpdate = null;
|
|
5745
|
-
editorMgr.updateCode(queuedCode, queuedLang);
|
|
5746
|
-
}
|
|
5747
|
-
if (typeof monacoOptions.onThemeChange === "function") monacoOptions.onThemeChange(initialThemeName);
|
|
5748
|
-
if (editorView) lastKnownCode = editorView.getValue();
|
|
5749
|
-
return editorView;
|
|
5750
|
-
}
|
|
5751
|
-
function computedHeight(editorView$1) {
|
|
5752
|
-
var _getModel;
|
|
5753
|
-
const lineCount = ((_getModel = editorView$1.getModel()) === null || _getModel === void 0 ? void 0 : _getModel.getLineCount()) ?? 1;
|
|
5754
|
-
const lineHeight = editorView$1.getOption(monaco_shim_exports.editor.EditorOption.lineHeight);
|
|
5755
|
-
const height = Math.min(lineCount * lineHeight + padding, maxHeightValue);
|
|
5756
|
-
return height;
|
|
6429
|
+
function commitAppliedTheme(themeName) {
|
|
6430
|
+
requestedThemeName = themeName;
|
|
6431
|
+
globalRequestedThemeName = themeName;
|
|
6432
|
+
globalAppliedThemeName = themeName;
|
|
6433
|
+
monacoOptions.theme = themeName;
|
|
5757
6434
|
}
|
|
5758
|
-
async function
|
|
5759
|
-
|
|
5760
|
-
lastContainer = container;
|
|
5761
|
-
if (monacoOptions.isCleanOnBeforeCreate ?? true) {
|
|
5762
|
-
disposals.forEach((d) => d.dispose());
|
|
5763
|
-
disposals.length = 0;
|
|
5764
|
-
}
|
|
5765
|
-
if (monacoOptions.onBeforeCreate) {
|
|
5766
|
-
const ds = monacoOptions.onBeforeCreate(monaco_shim_exports);
|
|
5767
|
-
if (ds) disposals.push(...ds);
|
|
5768
|
-
}
|
|
5769
|
-
const initialThemeName = monacoOptions.theme ?? requestedThemeName ?? globalRequestedThemeName ?? currentTheme.value;
|
|
5770
|
-
await ensureThemeRegistered(initialThemeName);
|
|
6435
|
+
async function notifyThemeApplied(themeName) {
|
|
6436
|
+
if (typeof monacoOptions.onThemeChange !== "function") return;
|
|
5771
6437
|
try {
|
|
5772
|
-
|
|
6438
|
+
await monacoOptions.onThemeChange(themeName);
|
|
6439
|
+
} catch (err) {
|
|
6440
|
+
console.warn("onThemeChange callback threw an error:", err);
|
|
6441
|
+
}
|
|
6442
|
+
}
|
|
6443
|
+
function disposeDisposables(items) {
|
|
6444
|
+
if (!(items === null || items === void 0 ? void 0 : items.length)) return;
|
|
6445
|
+
for (const item of items) try {
|
|
6446
|
+
item.dispose();
|
|
5773
6447
|
} catch {}
|
|
5774
|
-
diffMgr = new DiffEditorManager(monacoOptions, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, diffAutoScroll, monacoOptions.revealDebounceMs, monacoOptions.diffUpdateThrottleMs);
|
|
5775
|
-
diffEditorView = await diffMgr.createDiffEditor(container, originalCode, modifiedCode, language, initialThemeName);
|
|
5776
|
-
if (typeof monacoOptions.onThemeChange === "function") monacoOptions.onThemeChange(initialThemeName);
|
|
5777
|
-
const models = diffMgr.getDiffModels();
|
|
5778
|
-
originalModel = models.original;
|
|
5779
|
-
modifiedModel = models.modified;
|
|
5780
|
-
return diffEditorView;
|
|
5781
|
-
}
|
|
5782
|
-
function clearFallbackAsyncWork() {
|
|
5783
|
-
rafScheduler.cancel("update");
|
|
5784
|
-
rafScheduler.cancel("append");
|
|
5785
|
-
rafScheduler.cancel("reveal");
|
|
5786
|
-
pendingUpdate = null;
|
|
5787
|
-
appendBufferScheduled = false;
|
|
5788
|
-
appendBuffer.length = 0;
|
|
5789
|
-
if (revealDebounceId != null) {
|
|
5790
|
-
clearTimeout(revealDebounceId);
|
|
5791
|
-
revealDebounceId = null;
|
|
5792
|
-
}
|
|
5793
|
-
if (updateThrottleTimer != null) {
|
|
5794
|
-
clearTimeout(updateThrottleTimer);
|
|
5795
|
-
updateThrottleTimer = null;
|
|
5796
|
-
}
|
|
5797
|
-
lastFlushTime = 0;
|
|
5798
6448
|
}
|
|
5799
|
-
function
|
|
6449
|
+
function takePendingCreateDisposables(requestId) {
|
|
6450
|
+
const items = pendingCreateDisposables.get(requestId) ?? [];
|
|
6451
|
+
pendingCreateDisposables.delete(requestId);
|
|
6452
|
+
return items;
|
|
6453
|
+
}
|
|
6454
|
+
function disposeAllPendingCreateDisposables() {
|
|
6455
|
+
for (const requestId of Array.from(pendingCreateDisposables.keys())) disposeDisposables(takePendingCreateDisposables(requestId));
|
|
6456
|
+
}
|
|
6457
|
+
function cleanupInstances() {
|
|
5800
6458
|
if (editorMgr) {
|
|
5801
6459
|
editorMgr.cleanup();
|
|
5802
6460
|
editorMgr = null;
|
|
5803
|
-
}
|
|
6461
|
+
} else if (editorView) try {
|
|
6462
|
+
editorView.dispose();
|
|
6463
|
+
} catch {}
|
|
5804
6464
|
if (diffMgr) {
|
|
5805
6465
|
diffMgr.cleanup();
|
|
5806
6466
|
diffMgr = null;
|
|
6467
|
+
} else {
|
|
6468
|
+
try {
|
|
6469
|
+
diffEditorView === null || diffEditorView === void 0 || diffEditorView.dispose();
|
|
6470
|
+
} catch {}
|
|
6471
|
+
try {
|
|
6472
|
+
originalModel === null || originalModel === void 0 || originalModel.dispose();
|
|
6473
|
+
} catch {}
|
|
6474
|
+
try {
|
|
6475
|
+
modifiedModel === null || modifiedModel === void 0 || modifiedModel.dispose();
|
|
6476
|
+
} catch {}
|
|
5807
6477
|
}
|
|
5808
|
-
|
|
5809
|
-
if (!editorMgr && editorView) {
|
|
5810
|
-
editorView.dispose();
|
|
5811
|
-
editorView = null;
|
|
5812
|
-
}
|
|
5813
|
-
lastKnownCode = null;
|
|
5814
|
-
if (lastContainer) {
|
|
5815
|
-
lastContainer.innerHTML = "";
|
|
5816
|
-
lastContainer = null;
|
|
5817
|
-
}
|
|
5818
|
-
if (themeWatcher) {
|
|
5819
|
-
themeWatcher();
|
|
5820
|
-
themeWatcher = null;
|
|
5821
|
-
}
|
|
6478
|
+
editorView = null;
|
|
5822
6479
|
diffEditorView = null;
|
|
5823
6480
|
originalModel = null;
|
|
5824
6481
|
modifiedModel = null;
|
|
5825
6482
|
}
|
|
5826
|
-
function
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
6483
|
+
function createSupersededError() {
|
|
6484
|
+
const err = new Error("Editor creation was superseded");
|
|
6485
|
+
err.name = "AbortError";
|
|
6486
|
+
err.code = "STREAM_MONACO_CREATE_SUPERSEDED";
|
|
6487
|
+
return err;
|
|
6488
|
+
}
|
|
6489
|
+
function isCreateActive(requestId, kind) {
|
|
6490
|
+
return activeCreateRequestId === requestId && activeCreateKind === kind;
|
|
6491
|
+
}
|
|
6492
|
+
function assertCreateStillActive(requestId, kind) {
|
|
6493
|
+
if (!isCreateActive(requestId, kind)) throw createSupersededError();
|
|
6494
|
+
}
|
|
6495
|
+
function cancelPendingCreates() {
|
|
6496
|
+
activeCreateRequestId = null;
|
|
6497
|
+
activeCreateKind = null;
|
|
6498
|
+
queuedEditorUpdateDuringCreate = null;
|
|
6499
|
+
disposeAllPendingCreateDisposables();
|
|
6500
|
+
}
|
|
6501
|
+
async function resolveCreateThemeName(requestId, kind) {
|
|
6502
|
+
let themeName = resolveRequestedThemeName();
|
|
6503
|
+
while (true) {
|
|
6504
|
+
assertCreateStillActive(requestId, kind);
|
|
6505
|
+
await ensureThemeRegistered(themeName);
|
|
6506
|
+
assertCreateStillActive(requestId, kind);
|
|
6507
|
+
const latestThemeName = resolveRequestedThemeName();
|
|
6508
|
+
if (latestThemeName === themeName) return themeName;
|
|
6509
|
+
themeName = latestThemeName;
|
|
5842
6510
|
}
|
|
5843
6511
|
}
|
|
5844
|
-
function
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
6512
|
+
async function createEditor(container, code, language) {
|
|
6513
|
+
var _monacoOptions$onBefo;
|
|
6514
|
+
cancelPendingCreates();
|
|
6515
|
+
cleanupInstances();
|
|
6516
|
+
const requestId = ++createRequestSeq;
|
|
6517
|
+
activeCreateRequestId = requestId;
|
|
6518
|
+
activeCreateKind = "editor";
|
|
6519
|
+
if (monacoOptions.isCleanOnBeforeCreate ?? true) disposeDisposables(disposals.splice(0));
|
|
6520
|
+
const requestDisposables = ((_monacoOptions$onBefo = monacoOptions.onBeforeCreate) === null || _monacoOptions$onBefo === void 0 ? void 0 : _monacoOptions$onBefo.call(monacoOptions, monaco_shim_exports)) ?? [];
|
|
6521
|
+
if (requestDisposables.length) pendingCreateDisposables.set(requestId, requestDisposables);
|
|
6522
|
+
let nextEditorMgr = null;
|
|
5848
6523
|
try {
|
|
5849
|
-
const
|
|
5850
|
-
|
|
5851
|
-
const
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
const isReadOnly = editorView.getOption(monaco_shim_exports.editor.EditorOption.readOnly);
|
|
5869
|
-
const edit = [{
|
|
5870
|
-
range,
|
|
5871
|
-
text: replaceText,
|
|
5872
|
-
forceMoveMarkers: true
|
|
5873
|
-
}];
|
|
5874
|
-
if (isReadOnly) model.applyEdits(edit);
|
|
5875
|
-
else editorView.executeEdits("minimal-replace", edit);
|
|
5876
|
-
}
|
|
5877
|
-
function flushPendingUpdate() {
|
|
5878
|
-
if (!pendingUpdate) return;
|
|
5879
|
-
lastFlushTime = Date.now();
|
|
5880
|
-
if (!editorView) return;
|
|
5881
|
-
const model = editorView.getModel();
|
|
5882
|
-
if (!model) return;
|
|
5883
|
-
const { code: newCode, lang: codeLanguage } = pendingUpdate;
|
|
5884
|
-
pendingUpdate = null;
|
|
5885
|
-
const processedCodeLanguage = processedLanguage(codeLanguage);
|
|
5886
|
-
let prevCode = null;
|
|
5887
|
-
if (appendBuffer.length > 0) {
|
|
5888
|
-
appendBuffer.length = 0;
|
|
5889
|
-
appendBufferScheduled = false;
|
|
5890
|
-
rafScheduler.cancel("append");
|
|
5891
|
-
try {
|
|
5892
|
-
prevCode = model.getValue();
|
|
5893
|
-
lastKnownCode = prevCode;
|
|
5894
|
-
} catch {
|
|
5895
|
-
prevCode = lastKnownCode ?? "";
|
|
6524
|
+
const initialThemeName = await resolveCreateThemeName(requestId, "editor");
|
|
6525
|
+
nextEditorMgr = new EditorManager(monacoOptions, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, monacoOptions.revealDebounceMs, monacoOptions.updateThrottleMs);
|
|
6526
|
+
const nextEditorView = await nextEditorMgr.createEditor(container, code, language, initialThemeName);
|
|
6527
|
+
assertCreateStillActive(requestId, "editor");
|
|
6528
|
+
editorMgr = nextEditorMgr;
|
|
6529
|
+
editorView = nextEditorView;
|
|
6530
|
+
diffMgr = null;
|
|
6531
|
+
diffEditorView = null;
|
|
6532
|
+
originalModel = null;
|
|
6533
|
+
modifiedModel = null;
|
|
6534
|
+
commitAppliedTheme(initialThemeName);
|
|
6535
|
+
const committedDisposables = takePendingCreateDisposables(requestId);
|
|
6536
|
+
if (committedDisposables.length) disposals.push(...committedDisposables);
|
|
6537
|
+
activeCreateRequestId = null;
|
|
6538
|
+
activeCreateKind = null;
|
|
6539
|
+
const queuedUpdate = queuedEditorUpdateDuringCreate;
|
|
6540
|
+
if ((queuedUpdate === null || queuedUpdate === void 0 ? void 0 : queuedUpdate.requestId) === requestId) {
|
|
6541
|
+
queuedEditorUpdateDuringCreate = null;
|
|
6542
|
+
editorMgr.updateCode(queuedUpdate.code, queuedUpdate.lang);
|
|
5896
6543
|
}
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
} catch {
|
|
5903
|
-
|
|
6544
|
+
await notifyThemeApplied(initialThemeName);
|
|
6545
|
+
return nextEditorView;
|
|
6546
|
+
} catch (error$1) {
|
|
6547
|
+
if (nextEditorMgr) try {
|
|
6548
|
+
nextEditorMgr.cleanup();
|
|
6549
|
+
} catch {}
|
|
6550
|
+
disposeDisposables(takePendingCreateDisposables(requestId));
|
|
6551
|
+
if (activeCreateRequestId === requestId) {
|
|
6552
|
+
activeCreateRequestId = null;
|
|
6553
|
+
activeCreateKind = null;
|
|
6554
|
+
queuedEditorUpdateDuringCreate = null;
|
|
5904
6555
|
}
|
|
6556
|
+
throw error$1;
|
|
5905
6557
|
}
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
const suffix = newCode.slice(prevCode.length);
|
|
5919
|
-
if (suffix) appendCode(suffix, codeLanguage);
|
|
5920
|
-
lastKnownCode = newCode;
|
|
5921
|
-
return;
|
|
5922
|
-
}
|
|
5923
|
-
try {
|
|
5924
|
-
const maxChars = minimalEditMaxCharsLocal;
|
|
5925
|
-
const ratio = minimalEditMaxChangeRatioLocal;
|
|
5926
|
-
const maxLen = Math.max(prevCode.length, newCode.length);
|
|
5927
|
-
const changeRatio = maxLen > 0 ? Math.abs(newCode.length - prevCode.length) / maxLen : 0;
|
|
5928
|
-
if (prevCode.length + newCode.length > maxChars || changeRatio > ratio) {
|
|
5929
|
-
const prevLineCount = model.getLineCount();
|
|
5930
|
-
model.setValue(newCode);
|
|
5931
|
-
lastKnownCode = newCode;
|
|
5932
|
-
const newLineCount = model.getLineCount();
|
|
5933
|
-
if (newLineCount !== prevLineCount) maybeScrollToBottom(newLineCount);
|
|
5934
|
-
return;
|
|
5935
|
-
}
|
|
5936
|
-
} catch {}
|
|
6558
|
+
}
|
|
6559
|
+
async function createDiffEditor(container, originalCode, modifiedCode, language) {
|
|
6560
|
+
var _monacoOptions$onBefo2;
|
|
6561
|
+
cancelPendingCreates();
|
|
6562
|
+
cleanupInstances();
|
|
6563
|
+
const requestId = ++createRequestSeq;
|
|
6564
|
+
activeCreateRequestId = requestId;
|
|
6565
|
+
activeCreateKind = "diff";
|
|
6566
|
+
if (monacoOptions.isCleanOnBeforeCreate ?? true) disposeDisposables(disposals.splice(0));
|
|
6567
|
+
const requestDisposables = ((_monacoOptions$onBefo2 = monacoOptions.onBeforeCreate) === null || _monacoOptions$onBefo2 === void 0 ? void 0 : _monacoOptions$onBefo2.call(monacoOptions, monaco_shim_exports)) ?? [];
|
|
6568
|
+
if (requestDisposables.length) pendingCreateDisposables.set(requestId, requestDisposables);
|
|
6569
|
+
let nextDiffMgr = null;
|
|
5937
6570
|
try {
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
const
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
6571
|
+
const initialThemeName = await resolveCreateThemeName(requestId, "diff");
|
|
6572
|
+
nextDiffMgr = new DiffEditorManager(monacoOptions, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, diffAutoScroll, monacoOptions.revealDebounceMs, monacoOptions.diffUpdateThrottleMs);
|
|
6573
|
+
const nextDiffEditorView = await nextDiffMgr.createDiffEditor(container, originalCode, modifiedCode, language, initialThemeName);
|
|
6574
|
+
assertCreateStillActive(requestId, "diff");
|
|
6575
|
+
diffMgr = nextDiffMgr;
|
|
6576
|
+
diffEditorView = nextDiffEditorView;
|
|
6577
|
+
editorMgr = null;
|
|
6578
|
+
editorView = null;
|
|
6579
|
+
const models = diffMgr.getDiffModels();
|
|
6580
|
+
originalModel = models.original;
|
|
6581
|
+
modifiedModel = models.modified;
|
|
6582
|
+
commitAppliedTheme(initialThemeName);
|
|
6583
|
+
const committedDisposables = takePendingCreateDisposables(requestId);
|
|
6584
|
+
if (committedDisposables.length) disposals.push(...committedDisposables);
|
|
6585
|
+
activeCreateRequestId = null;
|
|
6586
|
+
activeCreateKind = null;
|
|
6587
|
+
await notifyThemeApplied(initialThemeName);
|
|
6588
|
+
return nextDiffEditorView;
|
|
6589
|
+
} catch (error$1) {
|
|
6590
|
+
if (nextDiffMgr) try {
|
|
6591
|
+
nextDiffMgr.cleanup();
|
|
5950
6592
|
} catch {}
|
|
6593
|
+
disposeDisposables(takePendingCreateDisposables(requestId));
|
|
6594
|
+
if (activeCreateRequestId === requestId) {
|
|
6595
|
+
activeCreateRequestId = null;
|
|
6596
|
+
activeCreateKind = null;
|
|
6597
|
+
}
|
|
6598
|
+
throw error$1;
|
|
5951
6599
|
}
|
|
5952
6600
|
}
|
|
5953
|
-
function
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
return;
|
|
5961
|
-
}
|
|
5962
|
-
const text = appendBuffer.join("");
|
|
5963
|
-
appendBuffer.length = 0;
|
|
5964
|
-
try {
|
|
5965
|
-
const lastLine = model.getLineCount();
|
|
5966
|
-
const lastColumn = model.getLineMaxColumn(lastLine);
|
|
5967
|
-
const range = new monaco_shim_exports.Range(lastLine, lastColumn, lastLine, lastColumn);
|
|
5968
|
-
const isReadOnly = editorView.getOption(monaco_shim_exports.editor.EditorOption.readOnly);
|
|
5969
|
-
if (isReadOnly) model.applyEdits([{
|
|
5970
|
-
range,
|
|
5971
|
-
text,
|
|
5972
|
-
forceMoveMarkers: true
|
|
5973
|
-
}]);
|
|
5974
|
-
else editorView.executeEdits("append", [{
|
|
5975
|
-
range,
|
|
5976
|
-
text,
|
|
5977
|
-
forceMoveMarkers: true
|
|
5978
|
-
}]);
|
|
5979
|
-
if (lastKnownCode != null) lastKnownCode = lastKnownCode + text;
|
|
5980
|
-
try {
|
|
5981
|
-
if (lastLine !== model.getLineCount()) maybeScrollToBottom(model.getLineCount());
|
|
5982
|
-
} catch {}
|
|
5983
|
-
} catch {}
|
|
6601
|
+
function cleanupEditor() {
|
|
6602
|
+
cancelPendingCreates();
|
|
6603
|
+
cleanupInstances();
|
|
6604
|
+
disposeDisposables(disposals.splice(0));
|
|
6605
|
+
}
|
|
6606
|
+
function appendCode(appendText, codeLanguage) {
|
|
6607
|
+
if (editorMgr) editorMgr.appendCode(appendText, codeLanguage);
|
|
5984
6608
|
}
|
|
5985
6609
|
function updateCode(newCode, codeLanguage) {
|
|
5986
|
-
if (editorMgr)
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
code: newCode,
|
|
5990
|
-
lang: codeLanguage
|
|
5991
|
-
};
|
|
5992
|
-
rafScheduler.schedule("update", () => {
|
|
5993
|
-
if (!updateThrottleMs) {
|
|
5994
|
-
flushPendingUpdate();
|
|
5995
|
-
return;
|
|
5996
|
-
}
|
|
5997
|
-
const now = Date.now();
|
|
5998
|
-
const since = now - lastFlushTime;
|
|
5999
|
-
if (since >= updateThrottleMs) {
|
|
6000
|
-
flushPendingUpdate();
|
|
6001
|
-
return;
|
|
6002
|
-
}
|
|
6003
|
-
if (updateThrottleTimer != null) return;
|
|
6004
|
-
const wait = updateThrottleMs - since;
|
|
6005
|
-
updateThrottleTimer = setTimeout(() => {
|
|
6006
|
-
updateThrottleTimer = null;
|
|
6007
|
-
rafScheduler.schedule("update", () => flushPendingUpdate());
|
|
6008
|
-
}, wait);
|
|
6009
|
-
});
|
|
6610
|
+
if (editorMgr) {
|
|
6611
|
+
editorMgr.updateCode(newCode, codeLanguage);
|
|
6612
|
+
return;
|
|
6010
6613
|
}
|
|
6614
|
+
if (activeCreateRequestId != null && activeCreateKind === "editor") queuedEditorUpdateDuringCreate = {
|
|
6615
|
+
requestId: activeCreateRequestId,
|
|
6616
|
+
code: newCode,
|
|
6617
|
+
lang: codeLanguage
|
|
6618
|
+
};
|
|
6011
6619
|
}
|
|
6012
6620
|
function setUpdateThrottleMs(ms) {
|
|
6013
|
-
updateThrottleMs = ms;
|
|
6621
|
+
monacoOptions.updateThrottleMs = ms;
|
|
6014
6622
|
editorMgr === null || editorMgr === void 0 || editorMgr.setUpdateThrottleMs(ms);
|
|
6015
6623
|
}
|
|
6016
6624
|
function getUpdateThrottleMs() {
|
|
6017
|
-
return (editorMgr === null || editorMgr === void 0 ? void 0 : editorMgr.getUpdateThrottleMs()) ?? updateThrottleMs;
|
|
6625
|
+
return (editorMgr === null || editorMgr === void 0 ? void 0 : editorMgr.getUpdateThrottleMs()) ?? monacoOptions.updateThrottleMs ?? 50;
|
|
6018
6626
|
}
|
|
6019
6627
|
function updateDiff(originalCode, modifiedCode, codeLanguage) {
|
|
6020
6628
|
if (diffMgr) diffMgr.updateDiff(originalCode, modifiedCode, codeLanguage);
|
|
@@ -6046,15 +6654,12 @@ function useMonaco(monacoOptions = {}) {
|
|
|
6046
6654
|
createDiffEditor,
|
|
6047
6655
|
cleanupEditor,
|
|
6048
6656
|
safeClean() {
|
|
6049
|
-
clearFallbackAsyncWork();
|
|
6050
6657
|
if (editorMgr) try {
|
|
6051
6658
|
editorMgr.safeClean();
|
|
6052
6659
|
} catch {}
|
|
6053
6660
|
if (diffMgr) try {
|
|
6054
6661
|
diffMgr.safeClean();
|
|
6055
6662
|
} catch {}
|
|
6056
|
-
_hasScrollBar = false;
|
|
6057
|
-
shouldAutoScroll = !!autoScrollInitial;
|
|
6058
6663
|
},
|
|
6059
6664
|
updateCode,
|
|
6060
6665
|
appendCode,
|
|
@@ -6091,10 +6696,10 @@ function useMonaco(monacoOptions = {}) {
|
|
|
6091
6696
|
return monaco_shim_exports.editor;
|
|
6092
6697
|
},
|
|
6093
6698
|
getEditorView() {
|
|
6094
|
-
return editorView;
|
|
6699
|
+
return (editorMgr === null || editorMgr === void 0 ? void 0 : editorMgr.getEditorView()) ?? editorView;
|
|
6095
6700
|
},
|
|
6096
6701
|
getDiffEditorView() {
|
|
6097
|
-
return diffEditorView;
|
|
6702
|
+
return (diffMgr === null || diffMgr === void 0 ? void 0 : diffMgr.getDiffEditorView()) ?? diffEditorView;
|
|
6098
6703
|
},
|
|
6099
6704
|
getDiffModels() {
|
|
6100
6705
|
if (diffMgr) return diffMgr.getDiffModels();
|
|
@@ -6109,18 +6714,22 @@ function useMonaco(monacoOptions = {}) {
|
|
|
6109
6714
|
setUpdateThrottleMs,
|
|
6110
6715
|
getUpdateThrottleMs,
|
|
6111
6716
|
getCode() {
|
|
6717
|
+
if (editorMgr) return editorMgr.getCode();
|
|
6112
6718
|
if (editorView) try {
|
|
6113
6719
|
var _editorView$getModel;
|
|
6114
6720
|
return ((_editorView$getModel = editorView.getModel()) === null || _editorView$getModel === void 0 ? void 0 : _editorView$getModel.getValue()) ?? null;
|
|
6115
6721
|
} catch {
|
|
6116
6722
|
return null;
|
|
6117
6723
|
}
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6724
|
+
const diffModels = (diffMgr === null || diffMgr === void 0 ? void 0 : diffMgr.getDiffModels()) ?? {
|
|
6725
|
+
original: originalModel,
|
|
6726
|
+
modified: modifiedModel
|
|
6727
|
+
};
|
|
6728
|
+
if (diffEditorView || diffModels.original && diffModels.modified) try {
|
|
6729
|
+
var _diffModels$original, _diffModels$modified;
|
|
6121
6730
|
return {
|
|
6122
|
-
original,
|
|
6123
|
-
modified
|
|
6731
|
+
original: ((_diffModels$original = diffModels.original) === null || _diffModels$original === void 0 ? void 0 : _diffModels$original.getValue()) ?? "",
|
|
6732
|
+
modified: ((_diffModels$modified = diffModels.modified) === null || _diffModels$modified === void 0 ? void 0 : _diffModels$modified.getValue()) ?? ""
|
|
6124
6733
|
};
|
|
6125
6734
|
} catch {
|
|
6126
6735
|
return null;
|