stream-monaco 0.0.17 → 0.0.19
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 +62 -1
- package/README.zh-CN.md +67 -1
- package/dist/{index.base-D0jPJkA_.d.cts → index.base-9QTN8hPV.d.cts} +38 -4
- package/dist/{index.base-BaAqAXUs.d.ts → index.base-D0lzInae.d.ts} +39 -5
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/index.legacy.cjs +142 -3
- package/dist/index.legacy.d.cts +5 -5
- package/dist/index.legacy.d.ts +15 -5
- package/dist/index.legacy.js +142 -3
- package/dist/{preloadMonacoWorkers.shared-gUKedCzF.cjs → preloadMonacoWorkers.shared-DMvZ1HUs.cjs} +1261 -31
- package/dist/{preloadMonacoWorkers.shared-C62vOlc9.js → preloadMonacoWorkers.shared-DQ17-Bwz.js} +1245 -33
- package/package.json +7 -2
package/dist/{preloadMonacoWorkers.shared-gUKedCzF.cjs → preloadMonacoWorkers.shared-DMvZ1HUs.cjs}
RENAMED
|
@@ -28,7 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
}) : target, mod));
|
|
29
29
|
|
|
30
30
|
//#endregion
|
|
31
|
-
const
|
|
31
|
+
const monaco_editor_esm_vs_editor_editor_api = __toESM(require("monaco-editor/esm/vs/editor/editor.api"));
|
|
32
32
|
const alien_signals = __toESM(require("alien-signals"));
|
|
33
33
|
const __shikijs_monaco = __toESM(require("@shikijs/monaco"));
|
|
34
34
|
const shiki = __toESM(require("shiki"));
|
|
@@ -110,7 +110,11 @@ function detectLanguage(code, additionalLanguages) {
|
|
|
110
110
|
return ((_allLanguages$map$fil = allLanguages.map(([lang, ...features]) => [lang, features.reduce((acc, [match, score]) => acc + [...code.matchAll(match)].length * score, 0)]).filter(([, score]) => score > 20).sort((a, b) => b[1] - a[1])[0]) === null || _allLanguages$map$fil === void 0 ? void 0 : _allLanguages$map$fil[0]) || "plain";
|
|
111
111
|
}
|
|
112
112
|
function processedLanguage(language) {
|
|
113
|
-
|
|
113
|
+
try {
|
|
114
|
+
var _globalThis;
|
|
115
|
+
if (((_globalThis = globalThis) === null || _globalThis === void 0 ? void 0 : _globalThis.__streamMonacoLegacy__) && /^vue$/i.test(language)) return "html";
|
|
116
|
+
} catch {}
|
|
117
|
+
if (/^(?:shellscript|bash|sh|shell|zsh)/i.test(language)) return "shellscript";
|
|
114
118
|
if (/^(?:powershell|ps1?)/i.test(language)) return "powershell";
|
|
115
119
|
return language.split(":")[0];
|
|
116
120
|
}
|
|
@@ -140,6 +144,13 @@ function processedLanguage(language) {
|
|
|
140
144
|
* `, customLanguages) // 'kotlin'
|
|
141
145
|
*/
|
|
142
146
|
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/monaco-shim.ts
|
|
149
|
+
var monaco_shim_exports = {};
|
|
150
|
+
__export(monaco_shim_exports, { default: () => monaco });
|
|
151
|
+
__reExport(monaco_shim_exports, require("monaco-editor/esm/vs/editor/editor.api"));
|
|
152
|
+
const monaco = monaco_editor_esm_vs_editor_editor_api;
|
|
153
|
+
|
|
143
154
|
//#endregion
|
|
144
155
|
//#region src/constant.ts
|
|
145
156
|
const defaultLanguages = [
|
|
@@ -153,6 +164,8 @@ const defaultLanguages = [
|
|
|
153
164
|
"cpp",
|
|
154
165
|
"rust",
|
|
155
166
|
"go",
|
|
167
|
+
"shell",
|
|
168
|
+
"shellscript",
|
|
156
169
|
"powershell",
|
|
157
170
|
"sql",
|
|
158
171
|
"json",
|
|
@@ -220,13 +233,6 @@ function computeMinimalEdit(prev, next) {
|
|
|
220
233
|
};
|
|
221
234
|
}
|
|
222
235
|
|
|
223
|
-
//#endregion
|
|
224
|
-
//#region src/monaco-shim.ts
|
|
225
|
-
var monaco_shim_exports = {};
|
|
226
|
-
__export(monaco_shim_exports, { default: () => monaco });
|
|
227
|
-
__reExport(monaco_shim_exports, require("monaco-editor"));
|
|
228
|
-
const monaco = monaco_editor;
|
|
229
|
-
|
|
230
236
|
//#endregion
|
|
231
237
|
//#region src/utils/logger.ts
|
|
232
238
|
let seq = 0;
|
|
@@ -468,7 +474,8 @@ function createScrollWatcherForEditor(ed, opts) {
|
|
|
468
474
|
|
|
469
475
|
//#endregion
|
|
470
476
|
//#region src/core/DiffEditorManager.ts
|
|
471
|
-
var DiffEditorManager = class {
|
|
477
|
+
var DiffEditorManager = class DiffEditorManager {
|
|
478
|
+
static diffUiStyleId = "stream-monaco-diff-ui-style";
|
|
472
479
|
diffEditorView = null;
|
|
473
480
|
originalModel = null;
|
|
474
481
|
modifiedModel = null;
|
|
@@ -524,7 +531,21 @@ var DiffEditorManager = class {
|
|
|
524
531
|
appendFlushThrottleTimerDiff = null;
|
|
525
532
|
rafScheduler = createRafScheduler();
|
|
526
533
|
diffHeightManager = null;
|
|
527
|
-
|
|
534
|
+
diffHunkDisposables = [];
|
|
535
|
+
diffHunkOverlay = null;
|
|
536
|
+
diffHunkUpperNode = null;
|
|
537
|
+
diffHunkLowerNode = null;
|
|
538
|
+
diffHunkActiveChange = null;
|
|
539
|
+
diffHunkLineChanges = [];
|
|
540
|
+
diffHunkFallbackLineChanges = [];
|
|
541
|
+
diffHunkFallbackVersions = null;
|
|
542
|
+
diffHunkHideTimer = null;
|
|
543
|
+
diffUnchangedRegionDisposables = [];
|
|
544
|
+
diffUnchangedRegionObserver = null;
|
|
545
|
+
diffUnchangedBridgeOverlay = null;
|
|
546
|
+
diffUnchangedBridgeDisposables = [];
|
|
547
|
+
diffPersistedUnchangedModelState = null;
|
|
548
|
+
constructor(options, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, diffAutoScroll, revealDebounceMsOption, diffUpdateThrottleMsOption) {
|
|
528
549
|
this.options = options;
|
|
529
550
|
this.maxHeightValue = maxHeightValue;
|
|
530
551
|
this.maxHeightCSS = maxHeightCSS;
|
|
@@ -534,6 +555,1111 @@ var DiffEditorManager = class {
|
|
|
534
555
|
this.autoScrollThresholdLines = autoScrollThresholdLines;
|
|
535
556
|
this.diffAutoScroll = diffAutoScroll;
|
|
536
557
|
this.revealDebounceMsOption = revealDebounceMsOption;
|
|
558
|
+
this.diffUpdateThrottleMsOption = diffUpdateThrottleMsOption;
|
|
559
|
+
}
|
|
560
|
+
resolveDiffHideUnchangedRegionsOption() {
|
|
561
|
+
const normalize = (value) => {
|
|
562
|
+
if (typeof value === "boolean") return { enabled: value };
|
|
563
|
+
if (value && typeof value === "object") {
|
|
564
|
+
const raw = value;
|
|
565
|
+
return {
|
|
566
|
+
enabled: raw.enabled ?? true,
|
|
567
|
+
...raw
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
return { enabled: false };
|
|
571
|
+
};
|
|
572
|
+
const direct = this.options.hideUnchangedRegions;
|
|
573
|
+
if (typeof direct !== "undefined") return normalize(direct);
|
|
574
|
+
const viaOption = this.options.diffHideUnchangedRegions;
|
|
575
|
+
if (typeof viaOption !== "undefined") return normalize(viaOption);
|
|
576
|
+
return {
|
|
577
|
+
enabled: true,
|
|
578
|
+
contextLineCount: 3,
|
|
579
|
+
minimumLineCount: 3,
|
|
580
|
+
revealLineCount: 3
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
disposeDiffHunkInteractions() {
|
|
584
|
+
if (this.diffHunkHideTimer != null) {
|
|
585
|
+
clearTimeout(this.diffHunkHideTimer);
|
|
586
|
+
this.diffHunkHideTimer = null;
|
|
587
|
+
}
|
|
588
|
+
this.diffHunkActiveChange = null;
|
|
589
|
+
this.diffHunkLineChanges = [];
|
|
590
|
+
this.diffHunkFallbackLineChanges = [];
|
|
591
|
+
this.diffHunkFallbackVersions = null;
|
|
592
|
+
if (this.diffHunkDisposables.length > 0) {
|
|
593
|
+
for (const d of this.diffHunkDisposables) try {
|
|
594
|
+
d.dispose();
|
|
595
|
+
} catch {}
|
|
596
|
+
this.diffHunkDisposables.length = 0;
|
|
597
|
+
}
|
|
598
|
+
if (this.diffHunkOverlay) {
|
|
599
|
+
this.diffHunkOverlay.remove();
|
|
600
|
+
this.diffHunkOverlay = null;
|
|
601
|
+
}
|
|
602
|
+
this.diffHunkUpperNode = null;
|
|
603
|
+
this.diffHunkLowerNode = null;
|
|
604
|
+
}
|
|
605
|
+
computeLineChangesFallback(originalModel, modifiedModel) {
|
|
606
|
+
const original = originalModel.getValue().split(/\r?\n/);
|
|
607
|
+
const modified = modifiedModel.getValue().split(/\r?\n/);
|
|
608
|
+
const n = original.length;
|
|
609
|
+
const m = modified.length;
|
|
610
|
+
if (n === 0 && m === 0) return [];
|
|
611
|
+
const maxCells = 15e5;
|
|
612
|
+
if ((n + 1) * (m + 1) > maxCells) return originalModel.getValue() === modifiedModel.getValue() ? [] : [{
|
|
613
|
+
originalStartLineNumber: 1,
|
|
614
|
+
originalEndLineNumber: n,
|
|
615
|
+
modifiedStartLineNumber: 1,
|
|
616
|
+
modifiedEndLineNumber: m,
|
|
617
|
+
charChanges: []
|
|
618
|
+
}];
|
|
619
|
+
const cols = m + 1;
|
|
620
|
+
const dp = new Uint32Array((n + 1) * (m + 1));
|
|
621
|
+
for (let i$1 = 1; i$1 <= n; i$1++) for (let j$1 = 1; j$1 <= m; j$1++) {
|
|
622
|
+
const idx = i$1 * cols + j$1;
|
|
623
|
+
if (original[i$1 - 1] === modified[j$1 - 1]) dp[idx] = dp[(i$1 - 1) * cols + (j$1 - 1)] + 1;
|
|
624
|
+
else {
|
|
625
|
+
const top = dp[(i$1 - 1) * cols + j$1];
|
|
626
|
+
const left = dp[i$1 * cols + (j$1 - 1)];
|
|
627
|
+
dp[idx] = top >= left ? top : left;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
const matches = [];
|
|
631
|
+
let i = n;
|
|
632
|
+
let j = m;
|
|
633
|
+
while (i > 0 && j > 0) if (original[i - 1] === modified[j - 1]) {
|
|
634
|
+
matches.push({
|
|
635
|
+
o: i,
|
|
636
|
+
m: j
|
|
637
|
+
});
|
|
638
|
+
i--;
|
|
639
|
+
j--;
|
|
640
|
+
} else {
|
|
641
|
+
const top = dp[(i - 1) * cols + j];
|
|
642
|
+
const left = dp[i * cols + (j - 1)];
|
|
643
|
+
if (top >= left) i--;
|
|
644
|
+
else j--;
|
|
645
|
+
}
|
|
646
|
+
matches.reverse();
|
|
647
|
+
matches.push({
|
|
648
|
+
o: n + 1,
|
|
649
|
+
m: m + 1
|
|
650
|
+
});
|
|
651
|
+
const lineChanges = [];
|
|
652
|
+
let prevO = 1;
|
|
653
|
+
let prevM = 1;
|
|
654
|
+
for (const match of matches) {
|
|
655
|
+
const oStart = prevO;
|
|
656
|
+
const oEnd = match.o - 1;
|
|
657
|
+
const mStart = prevM;
|
|
658
|
+
const mEnd = match.m - 1;
|
|
659
|
+
const hasOriginal = oStart <= oEnd;
|
|
660
|
+
const hasModified = mStart <= mEnd;
|
|
661
|
+
if (hasOriginal || hasModified) lineChanges.push({
|
|
662
|
+
originalStartLineNumber: hasOriginal ? oStart : oStart,
|
|
663
|
+
originalEndLineNumber: hasOriginal ? oEnd : oStart - 1,
|
|
664
|
+
modifiedStartLineNumber: hasModified ? mStart : mStart,
|
|
665
|
+
modifiedEndLineNumber: hasModified ? mEnd : mStart - 1,
|
|
666
|
+
charChanges: []
|
|
667
|
+
});
|
|
668
|
+
prevO = match.o + 1;
|
|
669
|
+
prevM = match.m + 1;
|
|
670
|
+
}
|
|
671
|
+
return lineChanges;
|
|
672
|
+
}
|
|
673
|
+
getEffectiveLineChanges() {
|
|
674
|
+
if (!this.diffEditorView) return [];
|
|
675
|
+
const nativeLineChanges = this.diffEditorView.getLineChanges();
|
|
676
|
+
if (nativeLineChanges) {
|
|
677
|
+
this.diffHunkFallbackLineChanges = [];
|
|
678
|
+
this.diffHunkFallbackVersions = null;
|
|
679
|
+
return nativeLineChanges;
|
|
680
|
+
}
|
|
681
|
+
if (!this.originalModel || !this.modifiedModel) return [];
|
|
682
|
+
const versions = {
|
|
683
|
+
original: this.originalModel.getAlternativeVersionId(),
|
|
684
|
+
modified: this.modifiedModel.getAlternativeVersionId()
|
|
685
|
+
};
|
|
686
|
+
if (this.diffHunkFallbackVersions && this.diffHunkFallbackVersions.original === versions.original && this.diffHunkFallbackVersions.modified === versions.modified) return this.diffHunkFallbackLineChanges;
|
|
687
|
+
this.diffHunkFallbackLineChanges = this.computeLineChangesFallback(this.originalModel, this.modifiedModel);
|
|
688
|
+
this.diffHunkFallbackVersions = versions;
|
|
689
|
+
return this.diffHunkFallbackLineChanges;
|
|
690
|
+
}
|
|
691
|
+
ensureDiffUiStyle() {
|
|
692
|
+
if (typeof document === "undefined") return;
|
|
693
|
+
if (document.getElementById(DiffEditorManager.diffUiStyleId)) return;
|
|
694
|
+
const style = document.createElement("style");
|
|
695
|
+
style.id = DiffEditorManager.diffUiStyleId;
|
|
696
|
+
style.textContent = `
|
|
697
|
+
.stream-monaco-diff-root {
|
|
698
|
+
--stream-monaco-unchanged-fg: var(--vscode-diffEditor-unchangedRegionForeground, var(--vscode-editor-foreground, currentColor));
|
|
699
|
+
--stream-monaco-unchanged-bg: var(--vscode-diffEditor-unchangedRegionBackground, transparent);
|
|
700
|
+
--stream-monaco-editor-bg: var(--vscode-editor-background, #fff);
|
|
701
|
+
--stream-monaco-widget-shadow: var(--vscode-widget-shadow, rgb(0 0 0 / 30%));
|
|
702
|
+
--stream-monaco-focus: var(--vscode-focusBorder, var(--stream-monaco-unchanged-fg));
|
|
703
|
+
--stream-monaco-surface: color-mix(in srgb, var(--stream-monaco-unchanged-bg) 82%, var(--stream-monaco-editor-bg) 18%);
|
|
704
|
+
--stream-monaco-surface-hover: color-mix(in srgb, var(--stream-monaco-unchanged-bg) 72%, var(--stream-monaco-editor-bg) 28%);
|
|
705
|
+
--stream-monaco-surface-soft: color-mix(in srgb, var(--stream-monaco-unchanged-bg) 55%, transparent);
|
|
706
|
+
--stream-monaco-border: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 20%, transparent);
|
|
707
|
+
--stream-monaco-border-strong: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 34%, transparent);
|
|
708
|
+
--stream-monaco-muted: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 72%, transparent);
|
|
709
|
+
--stream-monaco-accent-soft: color-mix(in srgb, var(--stream-monaco-focus) 18%, transparent);
|
|
710
|
+
}
|
|
711
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines-widget {
|
|
712
|
+
pointer-events: auto;
|
|
713
|
+
box-sizing: border-box;
|
|
714
|
+
}
|
|
715
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines {
|
|
716
|
+
height: auto;
|
|
717
|
+
width: 100%;
|
|
718
|
+
transform: translateY(-10px);
|
|
719
|
+
padding: 4px 4px 6px;
|
|
720
|
+
box-sizing: border-box;
|
|
721
|
+
}
|
|
722
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .top,
|
|
723
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .bottom {
|
|
724
|
+
display: none !important;
|
|
725
|
+
pointer-events: none !important;
|
|
726
|
+
}
|
|
727
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center {
|
|
728
|
+
align-items: center;
|
|
729
|
+
gap: 10px;
|
|
730
|
+
max-width: calc(100% - 6px);
|
|
731
|
+
min-height: 32px;
|
|
732
|
+
margin: 0 auto;
|
|
733
|
+
padding: 4px 10px 4px 8px;
|
|
734
|
+
border-radius: 14px;
|
|
735
|
+
border: 1px solid var(--stream-monaco-border);
|
|
736
|
+
background: linear-gradient(180deg, var(--stream-monaco-surface) 0%, color-mix(in srgb, var(--stream-monaco-surface) 92%, var(--stream-monaco-editor-bg) 8%) 100%);
|
|
737
|
+
box-shadow: 0 14px 26px -22px var(--stream-monaco-widget-shadow);
|
|
738
|
+
box-sizing: border-box;
|
|
739
|
+
overflow: hidden;
|
|
740
|
+
transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
|
|
741
|
+
}
|
|
742
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-clickable {
|
|
743
|
+
cursor: pointer;
|
|
744
|
+
}
|
|
745
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-unchanged-bridge-source {
|
|
746
|
+
opacity: 0;
|
|
747
|
+
pointer-events: none;
|
|
748
|
+
border-color: transparent;
|
|
749
|
+
background: transparent;
|
|
750
|
+
box-shadow: none;
|
|
751
|
+
transform: none !important;
|
|
752
|
+
}
|
|
753
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-unchanged-bridge-source > * {
|
|
754
|
+
visibility: hidden;
|
|
755
|
+
}
|
|
756
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-unchanged-merged-secondary {
|
|
757
|
+
padding-left: 10px;
|
|
758
|
+
}
|
|
759
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center:hover,
|
|
760
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-focus-within {
|
|
761
|
+
background: linear-gradient(180deg, var(--stream-monaco-surface-hover) 0%, color-mix(in srgb, var(--stream-monaco-surface-hover) 92%, var(--stream-monaco-editor-bg) 8%) 100%);
|
|
762
|
+
border-color: var(--stream-monaco-border-strong);
|
|
763
|
+
box-shadow: 0 18px 30px -24px var(--stream-monaco-widget-shadow);
|
|
764
|
+
transform: translateY(-1px);
|
|
765
|
+
}
|
|
766
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-unchanged-merged-secondary .stream-monaco-unchanged-primary {
|
|
767
|
+
display: none !important;
|
|
768
|
+
}
|
|
769
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-primary,
|
|
770
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-primary {
|
|
771
|
+
display: flex;
|
|
772
|
+
align-items: center;
|
|
773
|
+
flex: 0 0 auto;
|
|
774
|
+
width: auto !important;
|
|
775
|
+
min-width: max-content;
|
|
776
|
+
overflow: visible;
|
|
777
|
+
justify-content: flex-start !important;
|
|
778
|
+
}
|
|
779
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-primary {
|
|
780
|
+
width: 100% !important;
|
|
781
|
+
justify-content: center !important;
|
|
782
|
+
}
|
|
783
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-expand,
|
|
784
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-expand {
|
|
785
|
+
appearance: none;
|
|
786
|
+
display: inline-flex;
|
|
787
|
+
align-items: center;
|
|
788
|
+
justify-content: center;
|
|
789
|
+
gap: 6px;
|
|
790
|
+
min-height: 24px;
|
|
791
|
+
padding: 0 10px;
|
|
792
|
+
border-radius: 999px;
|
|
793
|
+
text-decoration: none;
|
|
794
|
+
color: inherit;
|
|
795
|
+
background: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 12%, transparent);
|
|
796
|
+
border: 1px solid color-mix(in srgb, var(--stream-monaco-unchanged-fg) 10%, transparent);
|
|
797
|
+
font-size: 11px;
|
|
798
|
+
font-weight: 700;
|
|
799
|
+
letter-spacing: 0.01em;
|
|
800
|
+
white-space: nowrap;
|
|
801
|
+
transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
|
|
802
|
+
}
|
|
803
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-expand {
|
|
804
|
+
min-height: 0;
|
|
805
|
+
padding: 0;
|
|
806
|
+
border: 0;
|
|
807
|
+
border-radius: 0;
|
|
808
|
+
background: transparent;
|
|
809
|
+
box-shadow: none;
|
|
810
|
+
}
|
|
811
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-expand::after,
|
|
812
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-expand::after {
|
|
813
|
+
content: attr(data-stream-monaco-label);
|
|
814
|
+
}
|
|
815
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-expand:hover,
|
|
816
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-expand:focus-visible,
|
|
817
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-expand:hover {
|
|
818
|
+
background: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 18%, transparent);
|
|
819
|
+
border-color: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 22%, transparent);
|
|
820
|
+
transform: translateY(-1px);
|
|
821
|
+
}
|
|
822
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-expand:hover {
|
|
823
|
+
background: transparent;
|
|
824
|
+
border-color: transparent;
|
|
825
|
+
transform: none;
|
|
826
|
+
}
|
|
827
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-meta,
|
|
828
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-meta {
|
|
829
|
+
display: flex;
|
|
830
|
+
align-items: center;
|
|
831
|
+
gap: 8px;
|
|
832
|
+
min-width: 0;
|
|
833
|
+
flex: 1 1 auto;
|
|
834
|
+
overflow: hidden;
|
|
835
|
+
color: var(--stream-monaco-muted);
|
|
836
|
+
white-space: nowrap;
|
|
837
|
+
}
|
|
838
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-unchanged-merged-secondary .stream-monaco-unchanged-meta {
|
|
839
|
+
justify-content: center;
|
|
840
|
+
}
|
|
841
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-count,
|
|
842
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-count {
|
|
843
|
+
display: inline-flex;
|
|
844
|
+
align-items: center;
|
|
845
|
+
flex: 0 0 auto;
|
|
846
|
+
padding: 2px 8px;
|
|
847
|
+
border-radius: 999px;
|
|
848
|
+
background: var(--stream-monaco-surface-soft);
|
|
849
|
+
color: var(--stream-monaco-unchanged-fg);
|
|
850
|
+
font-size: 11px;
|
|
851
|
+
font-weight: 700;
|
|
852
|
+
letter-spacing: 0.01em;
|
|
853
|
+
}
|
|
854
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-separator {
|
|
855
|
+
flex: 0 0 auto;
|
|
856
|
+
opacity: 0.35;
|
|
857
|
+
}
|
|
858
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-breadcrumb,
|
|
859
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .breadcrumb-item {
|
|
860
|
+
min-width: 0;
|
|
861
|
+
max-width: 100%;
|
|
862
|
+
}
|
|
863
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-breadcrumb {
|
|
864
|
+
display: inline-flex;
|
|
865
|
+
align-items: center;
|
|
866
|
+
gap: 4px;
|
|
867
|
+
overflow: hidden;
|
|
868
|
+
text-overflow: ellipsis;
|
|
869
|
+
white-space: nowrap;
|
|
870
|
+
border-radius: 6px;
|
|
871
|
+
padding: 2px 6px;
|
|
872
|
+
transition: background-color 0.14s ease, color 0.14s ease;
|
|
873
|
+
}
|
|
874
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-breadcrumb:hover {
|
|
875
|
+
background: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 10%, transparent);
|
|
876
|
+
color: var(--stream-monaco-unchanged-fg);
|
|
877
|
+
}
|
|
878
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-unchanged-merged-secondary .stream-monaco-unchanged-separator,
|
|
879
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-unchanged-merged-secondary .stream-monaco-unchanged-breadcrumb {
|
|
880
|
+
display: none;
|
|
881
|
+
}
|
|
882
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-overlay {
|
|
883
|
+
position: absolute;
|
|
884
|
+
inset: 0;
|
|
885
|
+
pointer-events: none;
|
|
886
|
+
z-index: 12;
|
|
887
|
+
}
|
|
888
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge {
|
|
889
|
+
position: absolute;
|
|
890
|
+
display: grid;
|
|
891
|
+
grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
|
|
892
|
+
align-items: center;
|
|
893
|
+
column-gap: 12px;
|
|
894
|
+
min-height: 32px;
|
|
895
|
+
padding: 4px 12px 4px 10px;
|
|
896
|
+
border-radius: 14px;
|
|
897
|
+
border: 1px solid color-mix(in srgb, var(--stream-monaco-unchanged-fg) 24%, transparent);
|
|
898
|
+
background: linear-gradient(180deg, color-mix(in srgb, var(--stream-monaco-editor-bg) 88%, var(--stream-monaco-unchanged-fg) 12%) 0%, color-mix(in srgb, var(--stream-monaco-editor-bg) 94%, var(--stream-monaco-unchanged-fg) 6%) 100%);
|
|
899
|
+
box-shadow: 0 14px 26px -22px var(--stream-monaco-widget-shadow);
|
|
900
|
+
box-sizing: border-box;
|
|
901
|
+
overflow: hidden;
|
|
902
|
+
pointer-events: auto;
|
|
903
|
+
transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
|
|
904
|
+
}
|
|
905
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge:hover,
|
|
906
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge.stream-monaco-focus-visible {
|
|
907
|
+
background: linear-gradient(180deg, color-mix(in srgb, var(--stream-monaco-editor-bg) 84%, var(--stream-monaco-unchanged-fg) 16%) 0%, color-mix(in srgb, var(--stream-monaco-editor-bg) 92%, var(--stream-monaco-unchanged-fg) 8%) 100%);
|
|
908
|
+
border-color: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 32%, transparent);
|
|
909
|
+
box-shadow: 0 18px 30px -24px var(--stream-monaco-widget-shadow);
|
|
910
|
+
transform: translateY(-1px);
|
|
911
|
+
}
|
|
912
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge:focus {
|
|
913
|
+
outline: none;
|
|
914
|
+
}
|
|
915
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-meta {
|
|
916
|
+
justify-self: center;
|
|
917
|
+
justify-content: center;
|
|
918
|
+
}
|
|
919
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-spacer {
|
|
920
|
+
display: block;
|
|
921
|
+
visibility: hidden;
|
|
922
|
+
width: 100%;
|
|
923
|
+
height: 1px;
|
|
924
|
+
flex: 0 0 auto;
|
|
925
|
+
}
|
|
926
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines-compact {
|
|
927
|
+
align-items: center;
|
|
928
|
+
gap: 6px;
|
|
929
|
+
height: 16px;
|
|
930
|
+
}
|
|
931
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines-compact .text {
|
|
932
|
+
padding: 0 6px;
|
|
933
|
+
border-radius: 999px;
|
|
934
|
+
background: var(--stream-monaco-surface-soft);
|
|
935
|
+
color: var(--stream-monaco-unchanged-fg);
|
|
936
|
+
}
|
|
937
|
+
.stream-monaco-diff-root .monaco-editor .fold-unchanged {
|
|
938
|
+
display: flex !important;
|
|
939
|
+
align-items: center;
|
|
940
|
+
justify-content: center;
|
|
941
|
+
width: 18px !important;
|
|
942
|
+
height: 18px !important;
|
|
943
|
+
margin-left: 4px;
|
|
944
|
+
border-radius: 999px;
|
|
945
|
+
color: var(--stream-monaco-unchanged-fg);
|
|
946
|
+
background: var(--stream-monaco-surface);
|
|
947
|
+
border: 1px solid var(--stream-monaco-border);
|
|
948
|
+
box-shadow: 0 10px 18px -18px var(--stream-monaco-widget-shadow);
|
|
949
|
+
opacity: 0.88 !important;
|
|
950
|
+
transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.14s ease, opacity 0.14s ease, box-shadow 0.14s ease;
|
|
951
|
+
}
|
|
952
|
+
.stream-monaco-diff-root .monaco-editor .fold-unchanged:hover,
|
|
953
|
+
.stream-monaco-diff-root .monaco-editor .fold-unchanged.stream-monaco-focus-visible {
|
|
954
|
+
opacity: 1 !important;
|
|
955
|
+
transform: translateY(-1px);
|
|
956
|
+
background: var(--stream-monaco-surface-hover);
|
|
957
|
+
border-color: var(--stream-monaco-border-strong);
|
|
958
|
+
box-shadow: 0 14px 24px -18px var(--stream-monaco-widget-shadow);
|
|
959
|
+
}
|
|
960
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center:focus,
|
|
961
|
+
.stream-monaco-diff-root .monaco-editor .fold-unchanged:focus {
|
|
962
|
+
outline: none;
|
|
963
|
+
}
|
|
964
|
+
.stream-monaco-diff-hunk-overlay {
|
|
965
|
+
position: absolute;
|
|
966
|
+
inset: 0;
|
|
967
|
+
pointer-events: none;
|
|
968
|
+
z-index: 20;
|
|
969
|
+
}
|
|
970
|
+
.stream-monaco-diff-hunk-actions {
|
|
971
|
+
position: absolute;
|
|
972
|
+
left: 0;
|
|
973
|
+
top: 0;
|
|
974
|
+
display: none;
|
|
975
|
+
gap: 6px;
|
|
976
|
+
pointer-events: auto;
|
|
977
|
+
padding: 4px;
|
|
978
|
+
border-radius: 999px;
|
|
979
|
+
background: color-mix(in srgb, #f8f8f8 92%, #000 8%);
|
|
980
|
+
border: 1px solid color-mix(in srgb, #ddd 88%, #000 12%);
|
|
981
|
+
box-shadow: 0 2px 12px rgb(0 0 0 / 10%);
|
|
982
|
+
}
|
|
983
|
+
.stream-monaco-diff-hunk-actions button {
|
|
984
|
+
appearance: none;
|
|
985
|
+
border: 0;
|
|
986
|
+
border-radius: 999px;
|
|
987
|
+
padding: 3px 9px;
|
|
988
|
+
font-size: 11px;
|
|
989
|
+
line-height: 1.35;
|
|
990
|
+
background: white;
|
|
991
|
+
color: #222;
|
|
992
|
+
cursor: pointer;
|
|
993
|
+
}
|
|
994
|
+
.stream-monaco-diff-hunk-actions button:hover {
|
|
995
|
+
background: #f1f1f1;
|
|
996
|
+
}
|
|
997
|
+
.stream-monaco-diff-hunk-actions button:disabled {
|
|
998
|
+
opacity: 0.45;
|
|
999
|
+
cursor: default;
|
|
1000
|
+
}
|
|
1001
|
+
`;
|
|
1002
|
+
document.head.append(style);
|
|
1003
|
+
}
|
|
1004
|
+
createDomDisposable(bucket, el, eventName, listener) {
|
|
1005
|
+
el.addEventListener(eventName, listener);
|
|
1006
|
+
bucket.push({ dispose: () => el.removeEventListener(eventName, listener) });
|
|
1007
|
+
}
|
|
1008
|
+
createDiffHunkActionNode(side) {
|
|
1009
|
+
const node = document.createElement("div");
|
|
1010
|
+
node.className = "stream-monaco-diff-hunk-actions";
|
|
1011
|
+
node.dataset.side = side;
|
|
1012
|
+
const createButton = (action, label) => {
|
|
1013
|
+
const button = document.createElement("button");
|
|
1014
|
+
button.type = "button";
|
|
1015
|
+
button.textContent = label;
|
|
1016
|
+
button.dataset.action = action;
|
|
1017
|
+
button.addEventListener("click", (event) => {
|
|
1018
|
+
event.preventDefault();
|
|
1019
|
+
event.stopPropagation();
|
|
1020
|
+
this.applyDiffHunkAction(side, action);
|
|
1021
|
+
});
|
|
1022
|
+
return button;
|
|
1023
|
+
};
|
|
1024
|
+
node.append(createButton("revert", "Revert"), createButton("stage", "Stage"));
|
|
1025
|
+
this.createDomDisposable(this.diffHunkDisposables, node, "mouseenter", () => this.cancelScheduledHideDiffHunkActions());
|
|
1026
|
+
this.createDomDisposable(this.diffHunkDisposables, node, "mouseleave", () => this.scheduleHideDiffHunkActions());
|
|
1027
|
+
return node;
|
|
1028
|
+
}
|
|
1029
|
+
cloneSerializableValue(value) {
|
|
1030
|
+
if (typeof structuredClone === "function") return structuredClone(value);
|
|
1031
|
+
return JSON.parse(JSON.stringify(value));
|
|
1032
|
+
}
|
|
1033
|
+
capturePersistedDiffUnchangedState() {
|
|
1034
|
+
if (!this.diffEditorView) return;
|
|
1035
|
+
const state = this.diffEditorView.saveViewState();
|
|
1036
|
+
if (!(state === null || state === void 0 ? void 0 : state.modelState)) {
|
|
1037
|
+
this.diffPersistedUnchangedModelState = null;
|
|
1038
|
+
return;
|
|
1039
|
+
}
|
|
1040
|
+
this.diffPersistedUnchangedModelState = this.cloneSerializableValue(state.modelState);
|
|
1041
|
+
}
|
|
1042
|
+
scheduleCapturePersistedDiffUnchangedState(frames = 1) {
|
|
1043
|
+
this.rafScheduler.schedule("capture-diff-unchanged-state", () => {
|
|
1044
|
+
let remaining = Math.max(0, frames);
|
|
1045
|
+
const step = () => {
|
|
1046
|
+
if (remaining > 0) {
|
|
1047
|
+
remaining--;
|
|
1048
|
+
requestAnimationFrame(step);
|
|
1049
|
+
return;
|
|
1050
|
+
}
|
|
1051
|
+
this.capturePersistedDiffUnchangedState();
|
|
1052
|
+
};
|
|
1053
|
+
step();
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
restorePersistedDiffUnchangedState() {
|
|
1057
|
+
if (!this.diffEditorView || !this.diffPersistedUnchangedModelState) return;
|
|
1058
|
+
const current = this.diffEditorView.saveViewState();
|
|
1059
|
+
if (!current) return;
|
|
1060
|
+
this.diffEditorView.restoreViewState({
|
|
1061
|
+
original: current.original,
|
|
1062
|
+
modified: current.modified,
|
|
1063
|
+
modelState: this.cloneSerializableValue(this.diffPersistedUnchangedModelState)
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
scheduleRestorePersistedDiffUnchangedState() {
|
|
1067
|
+
if (!this.diffPersistedUnchangedModelState) return;
|
|
1068
|
+
this.rafScheduler.schedule("restore-diff-unchanged-state", () => {
|
|
1069
|
+
requestAnimationFrame(() => {
|
|
1070
|
+
this.restorePersistedDiffUnchangedState();
|
|
1071
|
+
});
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
bindPersistOnMouseRelease(bucket, node) {
|
|
1075
|
+
this.createDomDisposable(bucket, node, "mousedown", (event) => {
|
|
1076
|
+
const mouseEvent = event;
|
|
1077
|
+
if (mouseEvent.button !== 0) return;
|
|
1078
|
+
const view = node.ownerDocument.defaultView;
|
|
1079
|
+
if (!view) return;
|
|
1080
|
+
const handleMouseUp = () => {
|
|
1081
|
+
view.removeEventListener("mouseup", handleMouseUp);
|
|
1082
|
+
this.scheduleCapturePersistedDiffUnchangedState(1);
|
|
1083
|
+
};
|
|
1084
|
+
view.addEventListener("mouseup", handleMouseUp, { once: true });
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
disposeDiffUnchangedRegionEnhancements() {
|
|
1088
|
+
if (this.diffUnchangedRegionObserver) {
|
|
1089
|
+
this.diffUnchangedRegionObserver.disconnect();
|
|
1090
|
+
this.diffUnchangedRegionObserver = null;
|
|
1091
|
+
}
|
|
1092
|
+
this.clearDiffUnchangedBridgeOverlay();
|
|
1093
|
+
if (this.diffUnchangedRegionDisposables.length > 0) {
|
|
1094
|
+
for (const d of this.diffUnchangedRegionDisposables) try {
|
|
1095
|
+
d.dispose();
|
|
1096
|
+
} catch {}
|
|
1097
|
+
this.diffUnchangedRegionDisposables.length = 0;
|
|
1098
|
+
}
|
|
1099
|
+
this.rafScheduler.cancel("patch-diff-unchanged-regions");
|
|
1100
|
+
this.rafScheduler.cancel("capture-diff-unchanged-state");
|
|
1101
|
+
this.rafScheduler.cancel("restore-diff-unchanged-state");
|
|
1102
|
+
}
|
|
1103
|
+
bindFocusVisibleClass(bucket, node) {
|
|
1104
|
+
this.createDomDisposable(bucket, node, "focus", () => node.classList.add("stream-monaco-focus-visible"));
|
|
1105
|
+
this.createDomDisposable(bucket, node, "blur", () => node.classList.remove("stream-monaco-focus-visible"));
|
|
1106
|
+
}
|
|
1107
|
+
bindFocusWithinClass(bucket, node, className) {
|
|
1108
|
+
this.createDomDisposable(bucket, node, "focusin", () => node.classList.add(className));
|
|
1109
|
+
this.createDomDisposable(bucket, node, "focusout", () => {
|
|
1110
|
+
requestAnimationFrame(() => {
|
|
1111
|
+
if (node.matches(":focus-within")) return;
|
|
1112
|
+
node.classList.remove(className);
|
|
1113
|
+
});
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
clearDiffUnchangedBridgeOverlay(removeContainer = true) {
|
|
1117
|
+
var _this$diffUnchangedBr;
|
|
1118
|
+
if (this.lastContainer) {
|
|
1119
|
+
const bridgedCenters = this.lastContainer.querySelectorAll(".stream-monaco-unchanged-bridge-source");
|
|
1120
|
+
bridgedCenters.forEach((node) => node.classList.remove("stream-monaco-unchanged-bridge-source"));
|
|
1121
|
+
}
|
|
1122
|
+
if (this.diffUnchangedBridgeOverlay) this.diffUnchangedBridgeOverlay.replaceChildren();
|
|
1123
|
+
if (this.diffUnchangedBridgeDisposables.length > 0) {
|
|
1124
|
+
for (const d of this.diffUnchangedBridgeDisposables) try {
|
|
1125
|
+
d.dispose();
|
|
1126
|
+
} catch {}
|
|
1127
|
+
this.diffUnchangedBridgeDisposables.length = 0;
|
|
1128
|
+
}
|
|
1129
|
+
if (removeContainer && ((_this$diffUnchangedBr = this.diffUnchangedBridgeOverlay) === null || _this$diffUnchangedBr === void 0 ? void 0 : _this$diffUnchangedBr.parentElement)) this.diffUnchangedBridgeOverlay.remove();
|
|
1130
|
+
if (removeContainer) this.diffUnchangedBridgeOverlay = null;
|
|
1131
|
+
}
|
|
1132
|
+
ensureDiffUnchangedBridgeOverlay() {
|
|
1133
|
+
if (!this.lastContainer) return null;
|
|
1134
|
+
if (!this.diffUnchangedBridgeOverlay) {
|
|
1135
|
+
const overlay = document.createElement("div");
|
|
1136
|
+
overlay.className = "stream-monaco-diff-unchanged-overlay";
|
|
1137
|
+
this.lastContainer.append(overlay);
|
|
1138
|
+
this.diffUnchangedBridgeOverlay = overlay;
|
|
1139
|
+
}
|
|
1140
|
+
return this.diffUnchangedBridgeOverlay;
|
|
1141
|
+
}
|
|
1142
|
+
dispatchSyntheticMouseDown(node) {
|
|
1143
|
+
const view = node.ownerDocument.defaultView;
|
|
1144
|
+
if (!view) return;
|
|
1145
|
+
const rect = node.getBoundingClientRect();
|
|
1146
|
+
node.dispatchEvent(new view.MouseEvent("mousedown", {
|
|
1147
|
+
bubbles: true,
|
|
1148
|
+
cancelable: true,
|
|
1149
|
+
button: 0,
|
|
1150
|
+
clientX: rect.left + rect.width / 2,
|
|
1151
|
+
clientY: rect.top + rect.height / 2
|
|
1152
|
+
}));
|
|
1153
|
+
}
|
|
1154
|
+
resolveDiffUnchangedMergeRole(node) {
|
|
1155
|
+
var _this$diffEditorView, _this$diffEditorView$, _this$diffEditorView$2, _this$diffEditorView2, _this$diffEditorView3, _this$diffEditorView4;
|
|
1156
|
+
const diffRoot = node.closest(".monaco-diff-editor.side-by-side");
|
|
1157
|
+
if (!(diffRoot instanceof HTMLElement)) return "none";
|
|
1158
|
+
const nodeRect = node.getBoundingClientRect();
|
|
1159
|
+
const nodeCenter = nodeRect.left + nodeRect.width / 2;
|
|
1160
|
+
const originalHost = (_this$diffEditorView = this.diffEditorView) === null || _this$diffEditorView === void 0 || (_this$diffEditorView$2 = (_this$diffEditorView$ = _this$diffEditorView.getOriginalEditor()).getContainerDomNode) === null || _this$diffEditorView$2 === void 0 ? void 0 : _this$diffEditorView$2.call(_this$diffEditorView$);
|
|
1161
|
+
const modifiedHost = (_this$diffEditorView2 = this.diffEditorView) === null || _this$diffEditorView2 === void 0 || (_this$diffEditorView4 = (_this$diffEditorView3 = _this$diffEditorView2.getModifiedEditor()).getContainerDomNode) === null || _this$diffEditorView4 === void 0 ? void 0 : _this$diffEditorView4.call(_this$diffEditorView3);
|
|
1162
|
+
if (originalHost instanceof HTMLElement && modifiedHost instanceof HTMLElement) {
|
|
1163
|
+
const originalRect = originalHost.getBoundingClientRect();
|
|
1164
|
+
const modifiedRect = modifiedHost.getBoundingClientRect();
|
|
1165
|
+
const originalCenter = originalRect.left + originalRect.width / 2;
|
|
1166
|
+
const modifiedCenter = modifiedRect.left + modifiedRect.width / 2;
|
|
1167
|
+
return Math.abs(nodeCenter - originalCenter) <= Math.abs(nodeCenter - modifiedCenter) ? "secondary" : "primary";
|
|
1168
|
+
}
|
|
1169
|
+
const diffRect = diffRoot.getBoundingClientRect();
|
|
1170
|
+
return nodeCenter < diffRect.left + diffRect.width / 2 ? "secondary" : "primary";
|
|
1171
|
+
}
|
|
1172
|
+
patchDiffUnchangedCenter(node) {
|
|
1173
|
+
node.classList.add("stream-monaco-clickable");
|
|
1174
|
+
node.title = "Click to expand all hidden unchanged lines";
|
|
1175
|
+
const mergeRole = this.resolveDiffUnchangedMergeRole(node);
|
|
1176
|
+
const shouldUseMergedSecondary = mergeRole === "secondary";
|
|
1177
|
+
node.classList.toggle("stream-monaco-unchanged-merged-secondary", shouldUseMergedSecondary);
|
|
1178
|
+
node.classList.toggle("stream-monaco-unchanged-merged-primary", mergeRole === "primary");
|
|
1179
|
+
const primary = node.children.item(0);
|
|
1180
|
+
const meta = node.children.item(1);
|
|
1181
|
+
if (primary instanceof HTMLElement) primary.classList.add("stream-monaco-unchanged-primary");
|
|
1182
|
+
if (meta instanceof HTMLElement) {
|
|
1183
|
+
meta.classList.add("stream-monaco-unchanged-meta");
|
|
1184
|
+
const metaChildren = Array.from(meta.children);
|
|
1185
|
+
metaChildren.forEach((child, index) => {
|
|
1186
|
+
if (!(child instanceof HTMLElement)) return;
|
|
1187
|
+
child.classList.remove("stream-monaco-unchanged-count", "stream-monaco-unchanged-separator", "stream-monaco-unchanged-breadcrumb");
|
|
1188
|
+
if (index === 0) child.classList.add("stream-monaco-unchanged-count");
|
|
1189
|
+
else if (child.classList.contains("breadcrumb-item")) child.classList.add("stream-monaco-unchanged-breadcrumb");
|
|
1190
|
+
else child.classList.add("stream-monaco-unchanged-separator");
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
const action = node.querySelector("a");
|
|
1194
|
+
if (action instanceof HTMLElement) {
|
|
1195
|
+
action.classList.add("stream-monaco-unchanged-expand");
|
|
1196
|
+
action.dataset.streamMonacoLabel = "Expand all";
|
|
1197
|
+
action.title = "Expand all hidden lines";
|
|
1198
|
+
action.setAttribute("aria-label", "Expand all hidden lines");
|
|
1199
|
+
action.toggleAttribute("aria-hidden", shouldUseMergedSecondary);
|
|
1200
|
+
action.tabIndex = shouldUseMergedSecondary ? -1 : 0;
|
|
1201
|
+
if (action.dataset.streamMonacoExpandPatched !== "true") {
|
|
1202
|
+
action.dataset.streamMonacoExpandPatched = "true";
|
|
1203
|
+
this.createDomDisposable(this.diffUnchangedRegionDisposables, action, "click", () => {
|
|
1204
|
+
this.scheduleCapturePersistedDiffUnchangedState(1);
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
if (node.dataset.streamMonacoCenterPatched !== "true") {
|
|
1209
|
+
node.dataset.streamMonacoCenterPatched = "true";
|
|
1210
|
+
this.bindFocusWithinClass(this.diffUnchangedRegionDisposables, node, "stream-monaco-focus-within");
|
|
1211
|
+
const activate = () => {
|
|
1212
|
+
const action$1 = node.querySelector("a");
|
|
1213
|
+
if (action$1 instanceof HTMLElement) action$1.click();
|
|
1214
|
+
};
|
|
1215
|
+
this.createDomDisposable(this.diffUnchangedRegionDisposables, node, "click", (event) => {
|
|
1216
|
+
const mouseEvent = event;
|
|
1217
|
+
if (mouseEvent.button !== 0) return;
|
|
1218
|
+
const target = event.target instanceof HTMLElement ? event.target : null;
|
|
1219
|
+
if (target === null || target === void 0 ? void 0 : target.closest("a, .breadcrumb-item")) return;
|
|
1220
|
+
event.preventDefault();
|
|
1221
|
+
activate();
|
|
1222
|
+
this.scheduleCapturePersistedDiffUnchangedState(1);
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
renderMergedDiffUnchangedBridge(secondaryNode, primaryNode) {
|
|
1227
|
+
var _countSource$textCont;
|
|
1228
|
+
if (!this.lastContainer) return;
|
|
1229
|
+
const overlay = this.ensureDiffUnchangedBridgeOverlay();
|
|
1230
|
+
if (!overlay) return;
|
|
1231
|
+
const containerRect = this.lastContainer.getBoundingClientRect();
|
|
1232
|
+
const secondaryRect = secondaryNode.getBoundingClientRect();
|
|
1233
|
+
const primaryRect = primaryNode.getBoundingClientRect();
|
|
1234
|
+
const primaryStyle = globalThis.getComputedStyle(primaryNode);
|
|
1235
|
+
const primaryAction = primaryNode.querySelector(".stream-monaco-unchanged-expand");
|
|
1236
|
+
const primaryActionRect = primaryAction === null || primaryAction === void 0 ? void 0 : primaryAction.getBoundingClientRect();
|
|
1237
|
+
const countSource = primaryNode.querySelector(".stream-monaco-unchanged-count") ?? secondaryNode.querySelector(".stream-monaco-unchanged-count");
|
|
1238
|
+
const countText = (countSource === null || countSource === void 0 || (_countSource$textCont = countSource.textContent) === null || _countSource$textCont === void 0 ? void 0 : _countSource$textCont.trim()) || "Hidden lines";
|
|
1239
|
+
const editorSurface = primaryNode.closest(".monaco-editor") ?? primaryNode;
|
|
1240
|
+
const editorSurfaceStyle = globalThis.getComputedStyle(editorSurface);
|
|
1241
|
+
secondaryNode.classList.add("stream-monaco-unchanged-bridge-source");
|
|
1242
|
+
primaryNode.classList.add("stream-monaco-unchanged-bridge-source");
|
|
1243
|
+
const bridge = document.createElement("div");
|
|
1244
|
+
bridge.className = "stream-monaco-diff-unchanged-bridge";
|
|
1245
|
+
bridge.tabIndex = 0;
|
|
1246
|
+
bridge.setAttribute("role", "button");
|
|
1247
|
+
bridge.setAttribute("aria-label", `${countText}. Expand all hidden lines`);
|
|
1248
|
+
bridge.title = "Expand all hidden lines";
|
|
1249
|
+
bridge.style.left = `${secondaryRect.left - containerRect.left}px`;
|
|
1250
|
+
bridge.style.top = `${primaryRect.top - containerRect.top}px`;
|
|
1251
|
+
bridge.style.width = `${primaryRect.right - secondaryRect.left}px`;
|
|
1252
|
+
bridge.style.height = `${Math.max(secondaryRect.height, primaryRect.height)}px`;
|
|
1253
|
+
bridge.style.color = primaryStyle.color;
|
|
1254
|
+
bridge.style.fontFamily = primaryStyle.fontFamily;
|
|
1255
|
+
bridge.style.fontSize = primaryStyle.fontSize;
|
|
1256
|
+
bridge.style.lineHeight = primaryStyle.lineHeight;
|
|
1257
|
+
bridge.style.setProperty("--stream-monaco-unchanged-fg", primaryStyle.color);
|
|
1258
|
+
bridge.style.setProperty("--stream-monaco-editor-bg", editorSurfaceStyle.backgroundColor);
|
|
1259
|
+
const visualPrimary = document.createElement("span");
|
|
1260
|
+
visualPrimary.className = "stream-monaco-unchanged-primary";
|
|
1261
|
+
const visualAction = document.createElement("span");
|
|
1262
|
+
visualAction.className = "stream-monaco-unchanged-expand";
|
|
1263
|
+
visualAction.dataset.streamMonacoLabel = "Expand all";
|
|
1264
|
+
visualAction.setAttribute("aria-hidden", "true");
|
|
1265
|
+
visualAction.innerHTML = "<span class=\"codicon codicon-unfold\"></span>";
|
|
1266
|
+
visualPrimary.append(visualAction);
|
|
1267
|
+
const visualMeta = document.createElement("div");
|
|
1268
|
+
visualMeta.className = "stream-monaco-unchanged-meta";
|
|
1269
|
+
const visualCount = document.createElement("span");
|
|
1270
|
+
visualCount.className = "stream-monaco-unchanged-count";
|
|
1271
|
+
visualCount.textContent = countText;
|
|
1272
|
+
visualMeta.append(visualCount);
|
|
1273
|
+
const spacer = document.createElement("span");
|
|
1274
|
+
spacer.className = "stream-monaco-unchanged-spacer";
|
|
1275
|
+
spacer.style.width = `${(primaryActionRect === null || primaryActionRect === void 0 ? void 0 : primaryActionRect.width) ?? 102}px`;
|
|
1276
|
+
bridge.append(visualPrimary, visualMeta, spacer);
|
|
1277
|
+
overlay.append(bridge);
|
|
1278
|
+
this.bindFocusVisibleClass(this.diffUnchangedBridgeDisposables, bridge);
|
|
1279
|
+
const activate = () => {
|
|
1280
|
+
const action = primaryNode.querySelector("a, button") ?? secondaryNode.querySelector("a, button");
|
|
1281
|
+
if (action instanceof HTMLElement) {
|
|
1282
|
+
action.click();
|
|
1283
|
+
this.scheduleCapturePersistedDiffUnchangedState(1);
|
|
1284
|
+
}
|
|
1285
|
+
};
|
|
1286
|
+
this.createDomDisposable(this.diffUnchangedBridgeDisposables, bridge, "click", (event) => {
|
|
1287
|
+
const mouseEvent = event;
|
|
1288
|
+
if (mouseEvent.button !== 0) return;
|
|
1289
|
+
event.preventDefault();
|
|
1290
|
+
activate();
|
|
1291
|
+
});
|
|
1292
|
+
this.createDomDisposable(this.diffUnchangedBridgeDisposables, bridge, "keydown", (event) => {
|
|
1293
|
+
const keyboardEvent = event;
|
|
1294
|
+
if (keyboardEvent.key !== "Enter" && keyboardEvent.key !== " ") return;
|
|
1295
|
+
keyboardEvent.preventDefault();
|
|
1296
|
+
activate();
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
patchDiffUnchangedFoldGlyph(node) {
|
|
1300
|
+
if (node.dataset.streamMonacoFoldGlyphPatched === "true") return;
|
|
1301
|
+
node.dataset.streamMonacoFoldGlyphPatched = "true";
|
|
1302
|
+
node.tabIndex = 0;
|
|
1303
|
+
node.setAttribute("role", "button");
|
|
1304
|
+
node.setAttribute("aria-label", "Collapse unchanged lines");
|
|
1305
|
+
node.title = node.title || "Collapse unchanged lines";
|
|
1306
|
+
this.bindFocusVisibleClass(this.diffUnchangedRegionDisposables, node);
|
|
1307
|
+
this.bindPersistOnMouseRelease(this.diffUnchangedRegionDisposables, node);
|
|
1308
|
+
this.createDomDisposable(this.diffUnchangedRegionDisposables, node, "keydown", (event) => {
|
|
1309
|
+
const keyboardEvent = event;
|
|
1310
|
+
if (keyboardEvent.key !== "Enter" && keyboardEvent.key !== " ") return;
|
|
1311
|
+
keyboardEvent.preventDefault();
|
|
1312
|
+
this.dispatchSyntheticMouseDown(node);
|
|
1313
|
+
this.scheduleCapturePersistedDiffUnchangedState(1);
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
scanAndPatchDiffUnchangedRegions() {
|
|
1317
|
+
if (!this.lastContainer) return;
|
|
1318
|
+
const centers = this.lastContainer.querySelectorAll(".diff-hidden-lines .center");
|
|
1319
|
+
centers.forEach((node) => this.patchDiffUnchangedCenter(node));
|
|
1320
|
+
const partialRevealHandles = this.lastContainer.querySelectorAll(".diff-hidden-lines .top, .diff-hidden-lines .bottom");
|
|
1321
|
+
partialRevealHandles.forEach((node) => {
|
|
1322
|
+
node.removeAttribute("title");
|
|
1323
|
+
node.removeAttribute("aria-label");
|
|
1324
|
+
node.removeAttribute("role");
|
|
1325
|
+
node.removeAttribute("tabindex");
|
|
1326
|
+
});
|
|
1327
|
+
this.clearDiffUnchangedBridgeOverlay(false);
|
|
1328
|
+
const secondaryCenters = Array.from(centers).filter((node) => node.classList.contains("stream-monaco-unchanged-merged-secondary")).sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top);
|
|
1329
|
+
const primaryCenters = Array.from(centers).filter((node) => node.classList.contains("stream-monaco-unchanged-merged-primary")).sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top);
|
|
1330
|
+
const pairCount = Math.min(secondaryCenters.length, primaryCenters.length);
|
|
1331
|
+
for (let i = 0; i < pairCount; i++) {
|
|
1332
|
+
const secondaryNode = secondaryCenters[i];
|
|
1333
|
+
const primaryNode = primaryCenters[i];
|
|
1334
|
+
const topDelta = Math.abs(secondaryNode.getBoundingClientRect().top - primaryNode.getBoundingClientRect().top);
|
|
1335
|
+
if (topDelta > 6) continue;
|
|
1336
|
+
this.renderMergedDiffUnchangedBridge(secondaryNode, primaryNode);
|
|
1337
|
+
}
|
|
1338
|
+
const foldGlyphs = this.lastContainer.querySelectorAll(".fold-unchanged");
|
|
1339
|
+
foldGlyphs.forEach((node) => this.patchDiffUnchangedFoldGlyph(node));
|
|
1340
|
+
}
|
|
1341
|
+
schedulePatchDiffUnchangedRegions() {
|
|
1342
|
+
this.rafScheduler.schedule("patch-diff-unchanged-regions", () => {
|
|
1343
|
+
this.scanAndPatchDiffUnchangedRegions();
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
setupDiffUnchangedRegionEnhancements() {
|
|
1347
|
+
var _globalThis$getComput, _globalThis;
|
|
1348
|
+
this.disposeDiffUnchangedRegionEnhancements();
|
|
1349
|
+
if (!this.diffEditorView || !this.lastContainer) return;
|
|
1350
|
+
if (typeof document === "undefined") return;
|
|
1351
|
+
this.ensureDiffUiStyle();
|
|
1352
|
+
const containerStyle = (_globalThis$getComput = (_globalThis = globalThis).getComputedStyle) === null || _globalThis$getComput === void 0 ? void 0 : _globalThis$getComput.call(_globalThis, this.lastContainer);
|
|
1353
|
+
if (!containerStyle || containerStyle.position === "static") this.lastContainer.style.position = "relative";
|
|
1354
|
+
this.lastContainer.classList.add("stream-monaco-diff-root");
|
|
1355
|
+
this.schedulePatchDiffUnchangedRegions();
|
|
1356
|
+
if (typeof MutationObserver !== "undefined") {
|
|
1357
|
+
this.diffUnchangedRegionObserver = new MutationObserver((mutations) => {
|
|
1358
|
+
const shouldRepatch = mutations.some((mutation) => {
|
|
1359
|
+
const target = mutation.target instanceof HTMLElement ? mutation.target : null;
|
|
1360
|
+
if (target === null || target === void 0 ? void 0 : target.closest(".stream-monaco-diff-unchanged-overlay")) return false;
|
|
1361
|
+
const changedNodes = [...mutation.addedNodes, ...mutation.removedNodes];
|
|
1362
|
+
if (changedNodes.length > 0 && changedNodes.every((node) => {
|
|
1363
|
+
return node instanceof HTMLElement && node.classList.contains("stream-monaco-diff-unchanged-overlay");
|
|
1364
|
+
})) return false;
|
|
1365
|
+
return true;
|
|
1366
|
+
});
|
|
1367
|
+
if (shouldRepatch) this.schedulePatchDiffUnchangedRegions();
|
|
1368
|
+
});
|
|
1369
|
+
this.diffUnchangedRegionObserver.observe(this.lastContainer, {
|
|
1370
|
+
childList: true,
|
|
1371
|
+
subtree: true
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
const originalEditor = this.diffEditorView.getOriginalEditor();
|
|
1375
|
+
const modifiedEditor = this.diffEditorView.getModifiedEditor();
|
|
1376
|
+
const repatch = () => this.schedulePatchDiffUnchangedRegions();
|
|
1377
|
+
this.diffUnchangedRegionDisposables.push(this.diffEditorView.onDidUpdateDiff(() => {
|
|
1378
|
+
repatch();
|
|
1379
|
+
this.scheduleRestorePersistedDiffUnchangedState();
|
|
1380
|
+
}));
|
|
1381
|
+
this.diffUnchangedRegionDisposables.push(originalEditor.onDidLayoutChange(repatch));
|
|
1382
|
+
this.diffUnchangedRegionDisposables.push(modifiedEditor.onDidLayoutChange(repatch));
|
|
1383
|
+
this.diffUnchangedRegionDisposables.push(originalEditor.onDidScrollChange(repatch));
|
|
1384
|
+
this.diffUnchangedRegionDisposables.push(modifiedEditor.onDidScrollChange(repatch));
|
|
1385
|
+
}
|
|
1386
|
+
setupDiffHunkInteractions() {
|
|
1387
|
+
var _globalThis$getComput2, _globalThis2;
|
|
1388
|
+
this.disposeDiffHunkInteractions();
|
|
1389
|
+
if (!this.diffEditorView || !this.lastContainer) return;
|
|
1390
|
+
if (this.options.diffHunkActionsOnHover !== true) return;
|
|
1391
|
+
if (typeof document === "undefined") return;
|
|
1392
|
+
this.ensureDiffUiStyle();
|
|
1393
|
+
const containerStyle = (_globalThis$getComput2 = (_globalThis2 = globalThis).getComputedStyle) === null || _globalThis$getComput2 === void 0 ? void 0 : _globalThis$getComput2.call(_globalThis2, this.lastContainer);
|
|
1394
|
+
if (!containerStyle || containerStyle.position === "static") this.lastContainer.style.position = "relative";
|
|
1395
|
+
const overlay = document.createElement("div");
|
|
1396
|
+
overlay.className = "stream-monaco-diff-hunk-overlay";
|
|
1397
|
+
this.diffHunkOverlay = overlay;
|
|
1398
|
+
this.lastContainer.append(overlay);
|
|
1399
|
+
this.diffHunkUpperNode = this.createDiffHunkActionNode("upper");
|
|
1400
|
+
this.diffHunkLowerNode = this.createDiffHunkActionNode("lower");
|
|
1401
|
+
overlay.append(this.diffHunkUpperNode, this.diffHunkLowerNode);
|
|
1402
|
+
const originalEditor = this.diffEditorView.getOriginalEditor();
|
|
1403
|
+
const modifiedEditor = this.diffEditorView.getModifiedEditor();
|
|
1404
|
+
const bindHover = (editor, side) => {
|
|
1405
|
+
this.diffHunkDisposables.push(editor.onMouseMove((event) => {
|
|
1406
|
+
this.handleDiffHunkMouseMove(side, event);
|
|
1407
|
+
}));
|
|
1408
|
+
this.diffHunkDisposables.push(editor.onMouseLeave(() => this.scheduleHideDiffHunkActions()));
|
|
1409
|
+
this.diffHunkDisposables.push(editor.onDidScrollChange(() => this.repositionDiffHunkNodes()));
|
|
1410
|
+
this.diffHunkDisposables.push(editor.onDidLayoutChange(() => this.repositionDiffHunkNodes()));
|
|
1411
|
+
};
|
|
1412
|
+
bindHover(originalEditor, "original");
|
|
1413
|
+
bindHover(modifiedEditor, "modified");
|
|
1414
|
+
this.diffHunkDisposables.push(this.diffEditorView.onDidUpdateDiff(() => {
|
|
1415
|
+
this.diffHunkLineChanges = this.getEffectiveLineChanges();
|
|
1416
|
+
if (this.diffHunkActiveChange) this.hideDiffHunkActions();
|
|
1417
|
+
}));
|
|
1418
|
+
this.diffHunkLineChanges = this.getEffectiveLineChanges();
|
|
1419
|
+
}
|
|
1420
|
+
cancelScheduledHideDiffHunkActions() {
|
|
1421
|
+
if (this.diffHunkHideTimer != null) {
|
|
1422
|
+
clearTimeout(this.diffHunkHideTimer);
|
|
1423
|
+
this.diffHunkHideTimer = null;
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
scheduleHideDiffHunkActions(delayMs = this.options.diffHunkHoverHideDelayMs ?? 160) {
|
|
1427
|
+
this.cancelScheduledHideDiffHunkActions();
|
|
1428
|
+
this.diffHunkHideTimer = setTimeout(() => {
|
|
1429
|
+
this.diffHunkHideTimer = null;
|
|
1430
|
+
this.hideDiffHunkActions();
|
|
1431
|
+
}, delayMs);
|
|
1432
|
+
}
|
|
1433
|
+
hideDiffHunkActions() {
|
|
1434
|
+
this.diffHunkActiveChange = null;
|
|
1435
|
+
if (this.diffHunkUpperNode) this.diffHunkUpperNode.style.display = "none";
|
|
1436
|
+
if (this.diffHunkLowerNode) this.diffHunkLowerNode.style.display = "none";
|
|
1437
|
+
}
|
|
1438
|
+
hasOriginalLines(change) {
|
|
1439
|
+
return change.originalStartLineNumber > 0 && change.originalEndLineNumber >= change.originalStartLineNumber;
|
|
1440
|
+
}
|
|
1441
|
+
hasModifiedLines(change) {
|
|
1442
|
+
return change.modifiedStartLineNumber > 0 && change.modifiedEndLineNumber >= change.modifiedStartLineNumber;
|
|
1443
|
+
}
|
|
1444
|
+
distanceToLineChange(side, change, line) {
|
|
1445
|
+
const hasRange = side === "original" ? this.hasOriginalLines(change) : this.hasModifiedLines(change);
|
|
1446
|
+
const start = side === "original" ? change.originalStartLineNumber : change.modifiedStartLineNumber;
|
|
1447
|
+
const end = side === "original" ? change.originalEndLineNumber : change.modifiedEndLineNumber;
|
|
1448
|
+
if (hasRange) {
|
|
1449
|
+
if (line < start) return start - line;
|
|
1450
|
+
if (line > end) return line - end;
|
|
1451
|
+
return 0;
|
|
1452
|
+
}
|
|
1453
|
+
const fallbackAnchor = Math.max(1, start || end || 1);
|
|
1454
|
+
return Math.abs(line - fallbackAnchor);
|
|
1455
|
+
}
|
|
1456
|
+
findLineChangeByHoverLine(side, line) {
|
|
1457
|
+
if (this.diffHunkLineChanges.length === 0) return null;
|
|
1458
|
+
let best = null;
|
|
1459
|
+
let bestDistance = Number.POSITIVE_INFINITY;
|
|
1460
|
+
for (const change of this.diffHunkLineChanges) {
|
|
1461
|
+
const distance = this.distanceToLineChange(side, change, line);
|
|
1462
|
+
if (distance < bestDistance) {
|
|
1463
|
+
bestDistance = distance;
|
|
1464
|
+
best = change;
|
|
1465
|
+
if (distance === 0) break;
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
if (bestDistance > 2) return null;
|
|
1469
|
+
return best;
|
|
1470
|
+
}
|
|
1471
|
+
handleDiffHunkMouseMove(side, event) {
|
|
1472
|
+
var _event$target$positio;
|
|
1473
|
+
const line = (_event$target$positio = event.target.position) === null || _event$target$positio === void 0 ? void 0 : _event$target$positio.lineNumber;
|
|
1474
|
+
if (!line) {
|
|
1475
|
+
this.scheduleHideDiffHunkActions(120);
|
|
1476
|
+
return;
|
|
1477
|
+
}
|
|
1478
|
+
const change = this.findLineChangeByHoverLine(side, line);
|
|
1479
|
+
if (!change) {
|
|
1480
|
+
this.scheduleHideDiffHunkActions(120);
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
this.cancelScheduledHideDiffHunkActions();
|
|
1484
|
+
this.diffHunkActiveChange = change;
|
|
1485
|
+
this.repositionDiffHunkNodes();
|
|
1486
|
+
}
|
|
1487
|
+
isOriginalEditorCollapsed() {
|
|
1488
|
+
var _this$diffEditorView$3, _this$diffEditorView$4;
|
|
1489
|
+
if (!this.diffEditorView) return true;
|
|
1490
|
+
const info = (_this$diffEditorView$3 = (_this$diffEditorView$4 = this.diffEditorView.getOriginalEditor()).getLayoutInfo) === null || _this$diffEditorView$3 === void 0 ? void 0 : _this$diffEditorView$3.call(_this$diffEditorView$4);
|
|
1491
|
+
return !info || info.width < 24;
|
|
1492
|
+
}
|
|
1493
|
+
getEditorBySide(side) {
|
|
1494
|
+
if (!this.diffEditorView) return null;
|
|
1495
|
+
return side === "original" ? this.diffEditorView.getOriginalEditor() : this.diffEditorView.getModifiedEditor();
|
|
1496
|
+
}
|
|
1497
|
+
getFullLineRange(model, startLine, endLine) {
|
|
1498
|
+
if (endLine < startLine) return null;
|
|
1499
|
+
const lineCount = model.getLineCount();
|
|
1500
|
+
if (lineCount < 1) return null;
|
|
1501
|
+
const start = Math.max(1, Math.min(startLine, lineCount));
|
|
1502
|
+
const end = Math.max(start, Math.min(endLine, lineCount));
|
|
1503
|
+
if (end < lineCount) return new monaco_shim_exports.Range(start, 1, end + 1, 1);
|
|
1504
|
+
return new monaco_shim_exports.Range(start, 1, end, model.getLineMaxColumn(end));
|
|
1505
|
+
}
|
|
1506
|
+
getLinesText(model, startLine, endLine) {
|
|
1507
|
+
const range = this.getFullLineRange(model, startLine, endLine);
|
|
1508
|
+
if (!range) return "";
|
|
1509
|
+
return model.getValueInRange(range);
|
|
1510
|
+
}
|
|
1511
|
+
getInsertRangeBeforeLine(model, lineNumber) {
|
|
1512
|
+
const lineCount = model.getLineCount();
|
|
1513
|
+
if (lineNumber <= 1) return new monaco_shim_exports.Range(1, 1, 1, 1);
|
|
1514
|
+
if (lineNumber <= lineCount) return new monaco_shim_exports.Range(lineNumber, 1, lineNumber, 1);
|
|
1515
|
+
const lastLine = lineCount;
|
|
1516
|
+
const lastColumn = model.getLineMaxColumn(lastLine);
|
|
1517
|
+
return new monaco_shim_exports.Range(lastLine, lastColumn, lastLine, lastColumn);
|
|
1518
|
+
}
|
|
1519
|
+
getInsertRangeAfterLine(model, lineNumber) {
|
|
1520
|
+
const lineCount = model.getLineCount();
|
|
1521
|
+
if (lineNumber < 1) return new monaco_shim_exports.Range(1, 1, 1, 1);
|
|
1522
|
+
if (lineNumber < lineCount) return new monaco_shim_exports.Range(lineNumber + 1, 1, lineNumber + 1, 1);
|
|
1523
|
+
const lastLine = lineCount;
|
|
1524
|
+
const lastColumn = model.getLineMaxColumn(lastLine);
|
|
1525
|
+
return new monaco_shim_exports.Range(lastLine, lastColumn, lastLine, lastColumn);
|
|
1526
|
+
}
|
|
1527
|
+
syncDiffKnownValues() {
|
|
1528
|
+
var _this$diffEditorView5, _this$diffEditorView6, _this$diffEditorView7, _this$diffHeightManag;
|
|
1529
|
+
if (this.originalModel) this.lastKnownOriginalCode = this.originalModel.getValue();
|
|
1530
|
+
if (this.modifiedModel) {
|
|
1531
|
+
this.lastKnownModifiedCode = this.modifiedModel.getValue();
|
|
1532
|
+
this.lastKnownModifiedLineCount = this.modifiedModel.getLineCount();
|
|
1533
|
+
}
|
|
1534
|
+
this.lastKnownModifiedDirty = false;
|
|
1535
|
+
this._hasScrollBar = false;
|
|
1536
|
+
this.cachedComputedHeightDiff = this.computedHeight();
|
|
1537
|
+
this.cachedScrollHeightDiff = ((_this$diffEditorView5 = this.diffEditorView) === null || _this$diffEditorView5 === void 0 || (_this$diffEditorView7 = (_this$diffEditorView6 = _this$diffEditorView5.getModifiedEditor()).getScrollHeight) === null || _this$diffEditorView7 === void 0 ? void 0 : _this$diffEditorView7.call(_this$diffEditorView6)) ?? this.cachedScrollHeightDiff;
|
|
1538
|
+
(_this$diffHeightManag = this.diffHeightManager) === null || _this$diffHeightManag === void 0 || _this$diffHeightManag.update();
|
|
1539
|
+
}
|
|
1540
|
+
applyDefaultDiffHunkAction(context) {
|
|
1541
|
+
const { action, side, lineChange } = context;
|
|
1542
|
+
if (!this.originalModel || !this.modifiedModel) return;
|
|
1543
|
+
const hasOriginal = this.hasOriginalLines(lineChange);
|
|
1544
|
+
const hasModified = this.hasModifiedLines(lineChange);
|
|
1545
|
+
if (action === "revert" && side === "upper") {
|
|
1546
|
+
if (!hasOriginal) return;
|
|
1547
|
+
const text = this.getLinesText(this.originalModel, lineChange.originalStartLineNumber, lineChange.originalEndLineNumber);
|
|
1548
|
+
if (!text) return;
|
|
1549
|
+
const anchor = hasModified ? lineChange.modifiedStartLineNumber : Math.max(1, lineChange.modifiedStartLineNumber || lineChange.modifiedEndLineNumber || this.modifiedModel.getLineCount());
|
|
1550
|
+
const range = this.getInsertRangeBeforeLine(this.modifiedModel, anchor);
|
|
1551
|
+
this.modifiedModel.applyEdits([{
|
|
1552
|
+
range,
|
|
1553
|
+
text,
|
|
1554
|
+
forceMoveMarkers: true
|
|
1555
|
+
}]);
|
|
1556
|
+
return;
|
|
1557
|
+
}
|
|
1558
|
+
if (action === "revert" && side === "lower") {
|
|
1559
|
+
if (!hasModified) return;
|
|
1560
|
+
const range = this.getFullLineRange(this.modifiedModel, lineChange.modifiedStartLineNumber, lineChange.modifiedEndLineNumber);
|
|
1561
|
+
if (!range) return;
|
|
1562
|
+
this.modifiedModel.applyEdits([{
|
|
1563
|
+
range,
|
|
1564
|
+
text: "",
|
|
1565
|
+
forceMoveMarkers: true
|
|
1566
|
+
}]);
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1569
|
+
if (action === "stage" && side === "upper") {
|
|
1570
|
+
if (!hasOriginal) return;
|
|
1571
|
+
const range = this.getFullLineRange(this.originalModel, lineChange.originalStartLineNumber, lineChange.originalEndLineNumber);
|
|
1572
|
+
if (!range) return;
|
|
1573
|
+
this.originalModel.applyEdits([{
|
|
1574
|
+
range,
|
|
1575
|
+
text: "",
|
|
1576
|
+
forceMoveMarkers: true
|
|
1577
|
+
}]);
|
|
1578
|
+
return;
|
|
1579
|
+
}
|
|
1580
|
+
if (action === "stage" && side === "lower") {
|
|
1581
|
+
if (!hasModified) return;
|
|
1582
|
+
const text = this.getLinesText(this.modifiedModel, lineChange.modifiedStartLineNumber, lineChange.modifiedEndLineNumber);
|
|
1583
|
+
if (!text) return;
|
|
1584
|
+
const anchor = hasOriginal ? lineChange.originalEndLineNumber : Math.max(0, lineChange.originalStartLineNumber - 1);
|
|
1585
|
+
const range = this.getInsertRangeAfterLine(this.originalModel, anchor);
|
|
1586
|
+
this.originalModel.applyEdits([{
|
|
1587
|
+
range,
|
|
1588
|
+
text,
|
|
1589
|
+
forceMoveMarkers: true
|
|
1590
|
+
}]);
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
applyDiffHunkAction(side, action) {
|
|
1594
|
+
if (!this.diffHunkActiveChange || !this.originalModel || !this.modifiedModel) return;
|
|
1595
|
+
this.flushOriginalAppendBufferSync();
|
|
1596
|
+
this.flushModifiedAppendBufferSync();
|
|
1597
|
+
const context = {
|
|
1598
|
+
action,
|
|
1599
|
+
side,
|
|
1600
|
+
lineChange: this.diffHunkActiveChange,
|
|
1601
|
+
originalModel: this.originalModel,
|
|
1602
|
+
modifiedModel: this.modifiedModel
|
|
1603
|
+
};
|
|
1604
|
+
let allowDefault = true;
|
|
1605
|
+
if (typeof this.options.onDiffHunkAction === "function") try {
|
|
1606
|
+
allowDefault = this.options.onDiffHunkAction(context) !== false;
|
|
1607
|
+
} catch (error$1) {
|
|
1608
|
+
console.warn("onDiffHunkAction callback threw an error:", error$1);
|
|
1609
|
+
}
|
|
1610
|
+
if (allowDefault) this.applyDefaultDiffHunkAction(context);
|
|
1611
|
+
this.syncDiffKnownValues();
|
|
1612
|
+
this.hideDiffHunkActions();
|
|
1613
|
+
}
|
|
1614
|
+
setDiffHunkNodeEnabled(node, enabled) {
|
|
1615
|
+
if (!node) return;
|
|
1616
|
+
const buttons = node.querySelectorAll("button");
|
|
1617
|
+
buttons.forEach((button) => {
|
|
1618
|
+
button.disabled = !enabled;
|
|
1619
|
+
});
|
|
1620
|
+
}
|
|
1621
|
+
positionDiffHunkNode(node, side, anchorLine, extraOffsetY = 0) {
|
|
1622
|
+
var _editor$getScrollTop;
|
|
1623
|
+
if (!this.diffHunkOverlay) return;
|
|
1624
|
+
const editor = this.getEditorBySide(side);
|
|
1625
|
+
if (!editor) return;
|
|
1626
|
+
const host = editor.getContainerDomNode();
|
|
1627
|
+
const line = Math.max(1, anchorLine);
|
|
1628
|
+
const rawTop = editor.getTopForLineNumber(line) - (((_editor$getScrollTop = editor.getScrollTop) === null || _editor$getScrollTop === void 0 ? void 0 : _editor$getScrollTop.call(editor)) ?? 0);
|
|
1629
|
+
const lineHeight = editor.getOption(monaco_shim_exports.editor.EditorOption.lineHeight);
|
|
1630
|
+
const nodeWidth = node.offsetWidth || 130;
|
|
1631
|
+
const nodeHeight = node.offsetHeight || 30;
|
|
1632
|
+
const left = host.offsetLeft + Math.max(6, host.clientWidth - nodeWidth - 10);
|
|
1633
|
+
const hostTop = host.offsetTop;
|
|
1634
|
+
const minTop = hostTop + 4;
|
|
1635
|
+
const maxTop = hostTop + Math.max(4, host.clientHeight - nodeHeight - 4);
|
|
1636
|
+
const top = Math.min(maxTop, Math.max(minTop, hostTop + rawTop + Math.round(lineHeight * .2) + extraOffsetY));
|
|
1637
|
+
node.style.transform = `translate(${Math.round(left)}px, ${Math.round(top)}px)`;
|
|
1638
|
+
node.style.display = "flex";
|
|
1639
|
+
}
|
|
1640
|
+
repositionDiffHunkNodes() {
|
|
1641
|
+
if (!this.diffHunkActiveChange) {
|
|
1642
|
+
this.hideDiffHunkActions();
|
|
1643
|
+
return;
|
|
1644
|
+
}
|
|
1645
|
+
if (!this.diffHunkUpperNode || !this.diffHunkLowerNode) return;
|
|
1646
|
+
if (!this.diffEditorView) return;
|
|
1647
|
+
const change = this.diffHunkActiveChange;
|
|
1648
|
+
const hasOriginal = this.hasOriginalLines(change);
|
|
1649
|
+
const hasModified = this.hasModifiedLines(change);
|
|
1650
|
+
this.setDiffHunkNodeEnabled(this.diffHunkUpperNode, hasOriginal);
|
|
1651
|
+
this.setDiffHunkNodeEnabled(this.diffHunkLowerNode, hasModified);
|
|
1652
|
+
const originalCollapsed = this.isOriginalEditorCollapsed();
|
|
1653
|
+
if (hasOriginal) {
|
|
1654
|
+
const upperSide = originalCollapsed ? "modified" : "original";
|
|
1655
|
+
const upperAnchor = originalCollapsed ? Math.max(1, change.modifiedStartLineNumber || change.modifiedEndLineNumber || 1) : change.originalStartLineNumber;
|
|
1656
|
+
this.positionDiffHunkNode(this.diffHunkUpperNode, upperSide, upperAnchor);
|
|
1657
|
+
} else this.diffHunkUpperNode.style.display = "none";
|
|
1658
|
+
if (hasModified) {
|
|
1659
|
+
const samePane = originalCollapsed;
|
|
1660
|
+
const lowerAnchor = change.modifiedStartLineNumber;
|
|
1661
|
+
this.positionDiffHunkNode(this.diffHunkLowerNode, "modified", lowerAnchor, samePane ? 32 : 0);
|
|
1662
|
+
} else this.diffHunkLowerNode.style.display = "none";
|
|
537
1663
|
}
|
|
538
1664
|
scheduleFlushAppendBufferDiff() {
|
|
539
1665
|
if (this.appendBufferDiffScheduled) return;
|
|
@@ -730,9 +1856,9 @@ var DiffEditorManager = class {
|
|
|
730
1856
|
lastRevealLineDiff: this.lastRevealLineDiff
|
|
731
1857
|
});
|
|
732
1858
|
try {
|
|
733
|
-
var _this$
|
|
1859
|
+
var _this$diffEditorView8, _this$diffEditorView9, _this$diffEditorView10;
|
|
734
1860
|
this.shouldAutoScrollDiff = true;
|
|
735
|
-
this.lastScrollTopDiff = ((_this$
|
|
1861
|
+
this.lastScrollTopDiff = ((_this$diffEditorView8 = this.diffEditorView) === null || _this$diffEditorView8 === void 0 || (_this$diffEditorView10 = (_this$diffEditorView9 = _this$diffEditorView8.getModifiedEditor()).getScrollTop) === null || _this$diffEditorView10 === void 0 ? void 0 : _this$diffEditorView10.call(_this$diffEditorView9)) ?? this.lastScrollTopDiff;
|
|
736
1862
|
} catch {}
|
|
737
1863
|
});
|
|
738
1864
|
}
|
|
@@ -751,9 +1877,9 @@ var DiffEditorManager = class {
|
|
|
751
1877
|
ticket
|
|
752
1878
|
});
|
|
753
1879
|
try {
|
|
754
|
-
var _this$
|
|
1880
|
+
var _this$diffEditorView11, _this$diffEditorView12, _this$diffEditorView13;
|
|
755
1881
|
this.shouldAutoScrollDiff = true;
|
|
756
|
-
this.lastScrollTopDiff = ((_this$
|
|
1882
|
+
this.lastScrollTopDiff = ((_this$diffEditorView11 = this.diffEditorView) === null || _this$diffEditorView11 === void 0 || (_this$diffEditorView13 = (_this$diffEditorView12 = _this$diffEditorView11.getModifiedEditor()).getScrollTop) === null || _this$diffEditorView13 === void 0 ? void 0 : _this$diffEditorView13.call(_this$diffEditorView12)) ?? this.lastScrollTopDiff;
|
|
757
1883
|
} catch {}
|
|
758
1884
|
}
|
|
759
1885
|
scheduleImmediateRevealAfterLayoutDiff(line) {
|
|
@@ -794,6 +1920,7 @@ var DiffEditorManager = class {
|
|
|
794
1920
|
const lang = processedLanguage(language) || language;
|
|
795
1921
|
this.originalModel = monaco_shim_exports.editor.createModel(originalCode, lang);
|
|
796
1922
|
this.modifiedModel = monaco_shim_exports.editor.createModel(modifiedCode, lang);
|
|
1923
|
+
const hideUnchangedRegions = this.resolveDiffHideUnchangedRegionsOption();
|
|
797
1924
|
this.diffEditorView = monaco_shim_exports.editor.createDiffEditor(container, {
|
|
798
1925
|
automaticLayout: true,
|
|
799
1926
|
scrollBeyondLastLine: false,
|
|
@@ -807,7 +1934,8 @@ var DiffEditorManager = class {
|
|
|
807
1934
|
...defaultScrollbar,
|
|
808
1935
|
...this.options.scrollbar || {}
|
|
809
1936
|
},
|
|
810
|
-
...this.options
|
|
1937
|
+
...this.options,
|
|
1938
|
+
hideUnchangedRegions
|
|
811
1939
|
});
|
|
812
1940
|
monaco_shim_exports.editor.setTheme(currentTheme);
|
|
813
1941
|
this.diffEditorView.setModel({
|
|
@@ -816,7 +1944,7 @@ var DiffEditorManager = class {
|
|
|
816
1944
|
});
|
|
817
1945
|
this.lastKnownOriginalCode = originalCode;
|
|
818
1946
|
this.lastKnownModifiedCode = modifiedCode;
|
|
819
|
-
this.diffUpdateThrottleMs = this.options.diffUpdateThrottleMs ?? 50;
|
|
1947
|
+
this.diffUpdateThrottleMs = this.diffUpdateThrottleMsOption ?? this.options.diffUpdateThrottleMs ?? 50;
|
|
820
1948
|
this.shouldAutoScrollDiff = !!(this.autoScrollInitial && this.diffAutoScroll);
|
|
821
1949
|
if (this.diffScrollWatcher) {
|
|
822
1950
|
this.diffScrollWatcher.dispose();
|
|
@@ -865,12 +1993,12 @@ var DiffEditorManager = class {
|
|
|
865
1993
|
(_oEditor$onDidContent = oEditor.onDidContentSizeChange) === null || _oEditor$onDidContent === void 0 || _oEditor$onDidContent.call(oEditor, () => {
|
|
866
1994
|
this._hasScrollBar = false;
|
|
867
1995
|
this.rafScheduler.schedule("content-size-change-diff", () => {
|
|
868
|
-
var _oEditor$getScrollHei, _oEditor$getOption, _this$
|
|
1996
|
+
var _oEditor$getScrollHei, _oEditor$getOption, _this$diffHeightManag2, _this$diffHeightManag3;
|
|
869
1997
|
this.cachedScrollHeightDiff = ((_oEditor$getScrollHei = oEditor.getScrollHeight) === null || _oEditor$getScrollHei === void 0 ? void 0 : _oEditor$getScrollHei.call(oEditor)) ?? this.cachedScrollHeightDiff;
|
|
870
1998
|
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;
|
|
871
1999
|
this.cachedComputedHeightDiff = this.computedHeight();
|
|
872
|
-
if ((_this$
|
|
873
|
-
(_this$
|
|
2000
|
+
if ((_this$diffHeightManag2 = this.diffHeightManager) === null || _this$diffHeightManag2 === void 0 ? void 0 : _this$diffHeightManag2.isSuppressed()) return;
|
|
2001
|
+
(_this$diffHeightManag3 = this.diffHeightManager) === null || _this$diffHeightManag3 === void 0 || _this$diffHeightManag3.update();
|
|
874
2002
|
const computed$1 = this.computedHeight();
|
|
875
2003
|
if (this.lastContainer) {
|
|
876
2004
|
const prevOverflow = this.lastContainer.style.overflow;
|
|
@@ -888,12 +2016,12 @@ var DiffEditorManager = class {
|
|
|
888
2016
|
(_mEditor$onDidContent = mEditor.onDidContentSizeChange) === null || _mEditor$onDidContent === void 0 || _mEditor$onDidContent.call(mEditor, () => {
|
|
889
2017
|
this._hasScrollBar = false;
|
|
890
2018
|
this.rafScheduler.schedule("content-size-change-diff", () => {
|
|
891
|
-
var _mEditor$getScrollHei, _mEditor$getOption, _this$
|
|
2019
|
+
var _mEditor$getScrollHei, _mEditor$getOption, _this$diffHeightManag4, _this$diffHeightManag5;
|
|
892
2020
|
this.cachedScrollHeightDiff = ((_mEditor$getScrollHei = mEditor.getScrollHeight) === null || _mEditor$getScrollHei === void 0 ? void 0 : _mEditor$getScrollHei.call(mEditor)) ?? this.cachedScrollHeightDiff;
|
|
893
2021
|
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;
|
|
894
2022
|
this.cachedComputedHeightDiff = this.computedHeight();
|
|
895
|
-
if ((_this$
|
|
896
|
-
(_this$
|
|
2023
|
+
if ((_this$diffHeightManag4 = this.diffHeightManager) === null || _this$diffHeightManag4 === void 0 ? void 0 : _this$diffHeightManag4.isSuppressed()) return;
|
|
2024
|
+
(_this$diffHeightManag5 = this.diffHeightManager) === null || _this$diffHeightManag5 === void 0 || _this$diffHeightManag5.update();
|
|
897
2025
|
const computed$1 = this.computedHeight();
|
|
898
2026
|
if (this.lastContainer) {
|
|
899
2027
|
const prevOverflow = this.lastContainer.style.overflow;
|
|
@@ -913,6 +2041,8 @@ var DiffEditorManager = class {
|
|
|
913
2041
|
this.rafScheduler.schedule("sync-last-known-modified", () => this.syncLastKnownModified());
|
|
914
2042
|
});
|
|
915
2043
|
this.maybeScrollDiffToBottom(this.modifiedModel.getLineCount(), this.lastKnownModifiedLineCount ?? void 0);
|
|
2044
|
+
this.setupDiffUnchangedRegionEnhancements();
|
|
2045
|
+
this.setupDiffHunkInteractions();
|
|
916
2046
|
return this.diffEditorView;
|
|
917
2047
|
}
|
|
918
2048
|
updateDiff(originalCode, modifiedCode, codeLanguage) {
|
|
@@ -1054,6 +2184,8 @@ var DiffEditorManager = class {
|
|
|
1054
2184
|
}
|
|
1055
2185
|
this.rafScheduler.cancel("content-size-change-diff");
|
|
1056
2186
|
this.rafScheduler.cancel("sync-last-known-modified");
|
|
2187
|
+
this.disposeDiffHunkInteractions();
|
|
2188
|
+
this.disposeDiffUnchangedRegionEnhancements();
|
|
1057
2189
|
if (this.diffScrollWatcher) {
|
|
1058
2190
|
this.diffScrollWatcher.dispose();
|
|
1059
2191
|
this.diffScrollWatcher = null;
|
|
@@ -1077,6 +2209,7 @@ var DiffEditorManager = class {
|
|
|
1077
2209
|
this.lastKnownOriginalCode = null;
|
|
1078
2210
|
this.lastKnownModifiedCode = null;
|
|
1079
2211
|
if (this.lastContainer) {
|
|
2212
|
+
this.lastContainer.classList.remove("stream-monaco-diff-root");
|
|
1080
2213
|
this.lastContainer.innerHTML = "";
|
|
1081
2214
|
this.lastContainer = null;
|
|
1082
2215
|
}
|
|
@@ -1094,6 +2227,7 @@ var DiffEditorManager = class {
|
|
|
1094
2227
|
}
|
|
1095
2228
|
this.revealTicketDiff = 0;
|
|
1096
2229
|
this.lastRevealLineDiff = null;
|
|
2230
|
+
this.diffPersistedUnchangedModelState = null;
|
|
1097
2231
|
}
|
|
1098
2232
|
safeClean() {
|
|
1099
2233
|
this.rafScheduler.cancel("diff");
|
|
@@ -1106,6 +2240,9 @@ var DiffEditorManager = class {
|
|
|
1106
2240
|
clearTimeout(this.appendFlushThrottleTimerDiff);
|
|
1107
2241
|
this.appendFlushThrottleTimerDiff = null;
|
|
1108
2242
|
}
|
|
2243
|
+
this.hideDiffHunkActions();
|
|
2244
|
+
this.cancelScheduledHideDiffHunkActions();
|
|
2245
|
+
this.disposeDiffUnchangedRegionEnhancements();
|
|
1109
2246
|
if (this.diffScrollWatcher) {
|
|
1110
2247
|
this.diffScrollWatcher.dispose();
|
|
1111
2248
|
this.diffScrollWatcher = null;
|
|
@@ -1131,6 +2268,7 @@ var DiffEditorManager = class {
|
|
|
1131
2268
|
}
|
|
1132
2269
|
this.revealTicketDiff = 0;
|
|
1133
2270
|
this.lastRevealLineDiff = null;
|
|
2271
|
+
this.diffPersistedUnchangedModelState = null;
|
|
1134
2272
|
this.rafScheduler.cancel("content-size-change-diff");
|
|
1135
2273
|
this.rafScheduler.cancel("sync-last-known-modified");
|
|
1136
2274
|
}
|
|
@@ -1329,9 +2467,9 @@ var DiffEditorManager = class {
|
|
|
1329
2467
|
} catch {}
|
|
1330
2468
|
if (suppressedByFlush) watcherApi.setSuppressed(false);
|
|
1331
2469
|
try {
|
|
1332
|
-
var _this$
|
|
2470
|
+
var _this$diffEditorView14, _this$diffEditorView15, _this$diffEditorView16;
|
|
1333
2471
|
this.shouldAutoScrollDiff = true;
|
|
1334
|
-
this.lastScrollTopDiff = ((_this$
|
|
2472
|
+
this.lastScrollTopDiff = ((_this$diffEditorView14 = this.diffEditorView) === null || _this$diffEditorView14 === void 0 || (_this$diffEditorView16 = (_this$diffEditorView15 = _this$diffEditorView14.getModifiedEditor()).getScrollTop) === null || _this$diffEditorView16 === void 0 ? void 0 : _this$diffEditorView16.call(_this$diffEditorView15)) ?? this.lastScrollTopDiff;
|
|
1335
2473
|
} catch {}
|
|
1336
2474
|
}
|
|
1337
2475
|
applyMinimalEditToModel(model, prev, next) {
|
|
@@ -2015,6 +3153,41 @@ function arraysEqual(a, b) {
|
|
|
2015
3153
|
|
|
2016
3154
|
//#endregion
|
|
2017
3155
|
//#region src/utils/registerMonacoThemes.ts
|
|
3156
|
+
const LEGACY_ONIG_INIT_KEY = "__streamMonacoLegacyOnigurumaInit__";
|
|
3157
|
+
const LEGACY_ENGINE_KEY = "__streamMonacoLegacyShikiEngine__";
|
|
3158
|
+
const LEGACY_MONACO_LANGS_INIT_KEY = "__streamMonacoLegacyMonacoLangsInit__";
|
|
3159
|
+
async function awaitLegacyOnigurumaInitIfPresent() {
|
|
3160
|
+
try {
|
|
3161
|
+
var _globalThis;
|
|
3162
|
+
const p = (_globalThis = globalThis) === null || _globalThis === void 0 ? void 0 : _globalThis[LEGACY_ONIG_INIT_KEY];
|
|
3163
|
+
if (p && typeof p.then === "function") await p;
|
|
3164
|
+
} catch {}
|
|
3165
|
+
}
|
|
3166
|
+
async function awaitLegacyMonacoLanguageContributionsIfPresent() {
|
|
3167
|
+
try {
|
|
3168
|
+
var _globalThis2;
|
|
3169
|
+
const p = (_globalThis2 = globalThis) === null || _globalThis2 === void 0 ? void 0 : _globalThis2[LEGACY_MONACO_LANGS_INIT_KEY];
|
|
3170
|
+
if (p && typeof p.then === "function") await p;
|
|
3171
|
+
} catch {}
|
|
3172
|
+
}
|
|
3173
|
+
async function getLegacyShikiEngineIfPresent() {
|
|
3174
|
+
try {
|
|
3175
|
+
var _globalThis3;
|
|
3176
|
+
const p = (_globalThis3 = globalThis) === null || _globalThis3 === void 0 ? void 0 : _globalThis3[LEGACY_ENGINE_KEY];
|
|
3177
|
+
if (p && typeof p.then === "function") return await p;
|
|
3178
|
+
} catch {}
|
|
3179
|
+
return null;
|
|
3180
|
+
}
|
|
3181
|
+
async function createHighlighterWithLegacyEngineIfNeeded(options) {
|
|
3182
|
+
await awaitLegacyOnigurumaInitIfPresent();
|
|
3183
|
+
await awaitLegacyMonacoLanguageContributionsIfPresent();
|
|
3184
|
+
const engine = await getLegacyShikiEngineIfPresent();
|
|
3185
|
+
if (engine) return (0, shiki.createHighlighter)({
|
|
3186
|
+
...options,
|
|
3187
|
+
engine
|
|
3188
|
+
});
|
|
3189
|
+
return (0, shiki.createHighlighter)(options);
|
|
3190
|
+
}
|
|
2018
3191
|
let languagesRegistered = false;
|
|
2019
3192
|
let currentLanguages = [];
|
|
2020
3193
|
let themeRegisterPromise = null;
|
|
@@ -2030,6 +3203,7 @@ function setThemeRegisterPromise(p) {
|
|
|
2030
3203
|
const highlighterCache = /* @__PURE__ */ new Map();
|
|
2031
3204
|
let monacoHighlighterPromise = null;
|
|
2032
3205
|
let lastPatchedHighlighter = null;
|
|
3206
|
+
let lastPatchedLanguages = /* @__PURE__ */ new Set();
|
|
2033
3207
|
const monacoThemeByKey = /* @__PURE__ */ new Map();
|
|
2034
3208
|
const monacoLanguageSet = /* @__PURE__ */ new Set();
|
|
2035
3209
|
function themeKey(t) {
|
|
@@ -2041,7 +3215,7 @@ async function ensureMonacoHighlighter(themes, languages$1) {
|
|
|
2041
3215
|
if (!monacoHighlighterPromise) {
|
|
2042
3216
|
const initialThemes = Array.from(monacoThemeByKey.values());
|
|
2043
3217
|
const initialLangs = Array.from(monacoLanguageSet.values());
|
|
2044
|
-
monacoHighlighterPromise = (
|
|
3218
|
+
monacoHighlighterPromise = createHighlighterWithLegacyEngineIfNeeded({
|
|
2045
3219
|
themes: initialThemes,
|
|
2046
3220
|
langs: initialLangs
|
|
2047
3221
|
}).then((h$1) => h$1);
|
|
@@ -2069,7 +3243,7 @@ async function ensureMonacoHighlighter(themes, languages$1) {
|
|
|
2069
3243
|
}
|
|
2070
3244
|
return h;
|
|
2071
3245
|
}
|
|
2072
|
-
const p = (
|
|
3246
|
+
const p = createHighlighterWithLegacyEngineIfNeeded({
|
|
2073
3247
|
themes: wantsThemes,
|
|
2074
3248
|
langs: wantsLangs
|
|
2075
3249
|
}).then((hh) => hh);
|
|
@@ -2113,7 +3287,7 @@ async function getOrCreateHighlighter(themes, languages$1) {
|
|
|
2113
3287
|
}
|
|
2114
3288
|
const union = new Set([...existing.languages, ...requestedSet]);
|
|
2115
3289
|
const langsArray = Array.from(union);
|
|
2116
|
-
const p$1 = (
|
|
3290
|
+
const p$1 = createHighlighterWithLegacyEngineIfNeeded({
|
|
2117
3291
|
themes,
|
|
2118
3292
|
langs: langsArray
|
|
2119
3293
|
});
|
|
@@ -2127,7 +3301,7 @@ async function getOrCreateHighlighter(themes, languages$1) {
|
|
|
2127
3301
|
});
|
|
2128
3302
|
return p$1;
|
|
2129
3303
|
}
|
|
2130
|
-
const p = (
|
|
3304
|
+
const p = createHighlighterWithLegacyEngineIfNeeded({
|
|
2131
3305
|
themes,
|
|
2132
3306
|
langs: Array.from(requestedSet)
|
|
2133
3307
|
});
|
|
@@ -2152,9 +3326,47 @@ async function registerMonacoThemes(themes, languages$1) {
|
|
|
2152
3326
|
registerMonacoLanguages(languages$1);
|
|
2153
3327
|
const p = (async () => {
|
|
2154
3328
|
const highlighter = await ensureMonacoHighlighter(themes, languages$1);
|
|
2155
|
-
|
|
2156
|
-
|
|
3329
|
+
const wantsLangs = Array.from(monacoLanguageSet.values());
|
|
3330
|
+
const needsLanguagePatch = lastPatchedHighlighter !== highlighter || wantsLangs.some((l) => !lastPatchedLanguages.has(l));
|
|
3331
|
+
if (needsLanguagePatch) {
|
|
3332
|
+
if (lastPatchedHighlighter !== highlighter) lastPatchedLanguages = /* @__PURE__ */ new Set();
|
|
3333
|
+
const realLanguages = monaco_shim_exports.languages;
|
|
3334
|
+
const realEditor = monaco_shim_exports.editor;
|
|
3335
|
+
const setTokensProvider = typeof (realLanguages === null || realLanguages === void 0 ? void 0 : realLanguages.setTokensProvider) === "function" ? realLanguages.setTokensProvider.bind(realLanguages) : null;
|
|
3336
|
+
const getLanguages = typeof (realLanguages === null || realLanguages === void 0 ? void 0 : realLanguages.getLanguages) === "function" ? realLanguages.getLanguages.bind(realLanguages) : null;
|
|
3337
|
+
const monacoProxy = {
|
|
3338
|
+
__proto__: monaco_shim_exports,
|
|
3339
|
+
editor: realEditor,
|
|
3340
|
+
languages: {
|
|
3341
|
+
__proto__: realLanguages,
|
|
3342
|
+
getLanguages,
|
|
3343
|
+
setTokensProvider(lang, provider) {
|
|
3344
|
+
if (provider && typeof provider.tokenize === "function") {
|
|
3345
|
+
const originalTokenize = provider.tokenize.bind(provider);
|
|
3346
|
+
provider = {
|
|
3347
|
+
...provider,
|
|
3348
|
+
tokenize(line, state) {
|
|
3349
|
+
try {
|
|
3350
|
+
return originalTokenize(line, state);
|
|
3351
|
+
} catch {
|
|
3352
|
+
return {
|
|
3353
|
+
endState: state,
|
|
3354
|
+
tokens: [{
|
|
3355
|
+
startIndex: 0,
|
|
3356
|
+
scopes: ""
|
|
3357
|
+
}]
|
|
3358
|
+
};
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
};
|
|
3362
|
+
}
|
|
3363
|
+
return setTokensProvider === null || setTokensProvider === void 0 ? void 0 : setTokensProvider(lang, provider);
|
|
3364
|
+
}
|
|
3365
|
+
}
|
|
3366
|
+
};
|
|
3367
|
+
(0, __shikijs_monaco.shikiToMonaco)(highlighter, monacoProxy);
|
|
2157
3368
|
lastPatchedHighlighter = highlighter;
|
|
3369
|
+
lastPatchedLanguages = new Set(wantsLangs);
|
|
2158
3370
|
}
|
|
2159
3371
|
currentLanguages = languages$1.slice();
|
|
2160
3372
|
return highlighter;
|
|
@@ -2822,6 +4034,12 @@ Object.defineProperty(exports, 'RevealStrategy', {
|
|
|
2822
4034
|
return RevealStrategy;
|
|
2823
4035
|
}
|
|
2824
4036
|
});
|
|
4037
|
+
Object.defineProperty(exports, '__toESM', {
|
|
4038
|
+
enumerable: true,
|
|
4039
|
+
get: function () {
|
|
4040
|
+
return __toESM;
|
|
4041
|
+
}
|
|
4042
|
+
});
|
|
2825
4043
|
Object.defineProperty(exports, 'clearHighlighterCache', {
|
|
2826
4044
|
enumerable: true,
|
|
2827
4045
|
get: function () {
|
|
@@ -2852,6 +4070,18 @@ Object.defineProperty(exports, 'getOrCreateHighlighter', {
|
|
|
2852
4070
|
return getOrCreateHighlighter;
|
|
2853
4071
|
}
|
|
2854
4072
|
});
|
|
4073
|
+
Object.defineProperty(exports, 'monaco_shim_exports', {
|
|
4074
|
+
enumerable: true,
|
|
4075
|
+
get: function () {
|
|
4076
|
+
return monaco_shim_exports;
|
|
4077
|
+
}
|
|
4078
|
+
});
|
|
4079
|
+
Object.defineProperty(exports, 'processedLanguage', {
|
|
4080
|
+
enumerable: true,
|
|
4081
|
+
get: function () {
|
|
4082
|
+
return processedLanguage;
|
|
4083
|
+
}
|
|
4084
|
+
});
|
|
2855
4085
|
Object.defineProperty(exports, 'registerMonacoThemes', {
|
|
2856
4086
|
enumerable: true,
|
|
2857
4087
|
get: function () {
|