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-C62vOlc9.js → preloadMonacoWorkers.shared-DQ17-Bwz.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __export, __reExport } from "./chunk-CHLpw0oG.js";
|
|
2
|
-
import * as _monaco from "monaco-editor";
|
|
2
|
+
import * as _monaco from "monaco-editor/esm/vs/editor/editor.api";
|
|
3
3
|
import { computed } from "alien-signals";
|
|
4
4
|
import { shikiToMonaco } from "@shikijs/monaco";
|
|
5
5
|
import { createHighlighter } from "shiki";
|
|
@@ -81,7 +81,11 @@ function detectLanguage(code, additionalLanguages) {
|
|
|
81
81
|
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";
|
|
82
82
|
}
|
|
83
83
|
function processedLanguage(language) {
|
|
84
|
-
|
|
84
|
+
try {
|
|
85
|
+
var _globalThis;
|
|
86
|
+
if (((_globalThis = globalThis) === null || _globalThis === void 0 ? void 0 : _globalThis.__streamMonacoLegacy__) && /^vue$/i.test(language)) return "html";
|
|
87
|
+
} catch {}
|
|
88
|
+
if (/^(?:shellscript|bash|sh|shell|zsh)/i.test(language)) return "shellscript";
|
|
85
89
|
if (/^(?:powershell|ps1?)/i.test(language)) return "powershell";
|
|
86
90
|
return language.split(":")[0];
|
|
87
91
|
}
|
|
@@ -111,6 +115,14 @@ function processedLanguage(language) {
|
|
|
111
115
|
* `, customLanguages) // 'kotlin'
|
|
112
116
|
*/
|
|
113
117
|
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/monaco-shim.ts
|
|
120
|
+
var monaco_shim_exports = {};
|
|
121
|
+
__export(monaco_shim_exports, { default: () => monaco });
|
|
122
|
+
import * as import_monaco_editor_esm_vs_editor_editor_api from "monaco-editor/esm/vs/editor/editor.api";
|
|
123
|
+
__reExport(monaco_shim_exports, import_monaco_editor_esm_vs_editor_editor_api);
|
|
124
|
+
const monaco = _monaco;
|
|
125
|
+
|
|
114
126
|
//#endregion
|
|
115
127
|
//#region src/constant.ts
|
|
116
128
|
const defaultLanguages = [
|
|
@@ -124,6 +136,8 @@ const defaultLanguages = [
|
|
|
124
136
|
"cpp",
|
|
125
137
|
"rust",
|
|
126
138
|
"go",
|
|
139
|
+
"shell",
|
|
140
|
+
"shellscript",
|
|
127
141
|
"powershell",
|
|
128
142
|
"sql",
|
|
129
143
|
"json",
|
|
@@ -191,14 +205,6 @@ function computeMinimalEdit(prev, next) {
|
|
|
191
205
|
};
|
|
192
206
|
}
|
|
193
207
|
|
|
194
|
-
//#endregion
|
|
195
|
-
//#region src/monaco-shim.ts
|
|
196
|
-
var monaco_shim_exports = {};
|
|
197
|
-
__export(monaco_shim_exports, { default: () => monaco });
|
|
198
|
-
import * as import_monaco_editor from "monaco-editor";
|
|
199
|
-
__reExport(monaco_shim_exports, import_monaco_editor);
|
|
200
|
-
const monaco = _monaco;
|
|
201
|
-
|
|
202
208
|
//#endregion
|
|
203
209
|
//#region src/utils/logger.ts
|
|
204
210
|
let seq = 0;
|
|
@@ -440,7 +446,8 @@ function createScrollWatcherForEditor(ed, opts) {
|
|
|
440
446
|
|
|
441
447
|
//#endregion
|
|
442
448
|
//#region src/core/DiffEditorManager.ts
|
|
443
|
-
var DiffEditorManager = class {
|
|
449
|
+
var DiffEditorManager = class DiffEditorManager {
|
|
450
|
+
static diffUiStyleId = "stream-monaco-diff-ui-style";
|
|
444
451
|
diffEditorView = null;
|
|
445
452
|
originalModel = null;
|
|
446
453
|
modifiedModel = null;
|
|
@@ -496,7 +503,21 @@ var DiffEditorManager = class {
|
|
|
496
503
|
appendFlushThrottleTimerDiff = null;
|
|
497
504
|
rafScheduler = createRafScheduler();
|
|
498
505
|
diffHeightManager = null;
|
|
499
|
-
|
|
506
|
+
diffHunkDisposables = [];
|
|
507
|
+
diffHunkOverlay = null;
|
|
508
|
+
diffHunkUpperNode = null;
|
|
509
|
+
diffHunkLowerNode = null;
|
|
510
|
+
diffHunkActiveChange = null;
|
|
511
|
+
diffHunkLineChanges = [];
|
|
512
|
+
diffHunkFallbackLineChanges = [];
|
|
513
|
+
diffHunkFallbackVersions = null;
|
|
514
|
+
diffHunkHideTimer = null;
|
|
515
|
+
diffUnchangedRegionDisposables = [];
|
|
516
|
+
diffUnchangedRegionObserver = null;
|
|
517
|
+
diffUnchangedBridgeOverlay = null;
|
|
518
|
+
diffUnchangedBridgeDisposables = [];
|
|
519
|
+
diffPersistedUnchangedModelState = null;
|
|
520
|
+
constructor(options, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, diffAutoScroll, revealDebounceMsOption, diffUpdateThrottleMsOption) {
|
|
500
521
|
this.options = options;
|
|
501
522
|
this.maxHeightValue = maxHeightValue;
|
|
502
523
|
this.maxHeightCSS = maxHeightCSS;
|
|
@@ -506,6 +527,1111 @@ var DiffEditorManager = class {
|
|
|
506
527
|
this.autoScrollThresholdLines = autoScrollThresholdLines;
|
|
507
528
|
this.diffAutoScroll = diffAutoScroll;
|
|
508
529
|
this.revealDebounceMsOption = revealDebounceMsOption;
|
|
530
|
+
this.diffUpdateThrottleMsOption = diffUpdateThrottleMsOption;
|
|
531
|
+
}
|
|
532
|
+
resolveDiffHideUnchangedRegionsOption() {
|
|
533
|
+
const normalize = (value) => {
|
|
534
|
+
if (typeof value === "boolean") return { enabled: value };
|
|
535
|
+
if (value && typeof value === "object") {
|
|
536
|
+
const raw = value;
|
|
537
|
+
return {
|
|
538
|
+
enabled: raw.enabled ?? true,
|
|
539
|
+
...raw
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
return { enabled: false };
|
|
543
|
+
};
|
|
544
|
+
const direct = this.options.hideUnchangedRegions;
|
|
545
|
+
if (typeof direct !== "undefined") return normalize(direct);
|
|
546
|
+
const viaOption = this.options.diffHideUnchangedRegions;
|
|
547
|
+
if (typeof viaOption !== "undefined") return normalize(viaOption);
|
|
548
|
+
return {
|
|
549
|
+
enabled: true,
|
|
550
|
+
contextLineCount: 3,
|
|
551
|
+
minimumLineCount: 3,
|
|
552
|
+
revealLineCount: 3
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
disposeDiffHunkInteractions() {
|
|
556
|
+
if (this.diffHunkHideTimer != null) {
|
|
557
|
+
clearTimeout(this.diffHunkHideTimer);
|
|
558
|
+
this.diffHunkHideTimer = null;
|
|
559
|
+
}
|
|
560
|
+
this.diffHunkActiveChange = null;
|
|
561
|
+
this.diffHunkLineChanges = [];
|
|
562
|
+
this.diffHunkFallbackLineChanges = [];
|
|
563
|
+
this.diffHunkFallbackVersions = null;
|
|
564
|
+
if (this.diffHunkDisposables.length > 0) {
|
|
565
|
+
for (const d of this.diffHunkDisposables) try {
|
|
566
|
+
d.dispose();
|
|
567
|
+
} catch {}
|
|
568
|
+
this.diffHunkDisposables.length = 0;
|
|
569
|
+
}
|
|
570
|
+
if (this.diffHunkOverlay) {
|
|
571
|
+
this.diffHunkOverlay.remove();
|
|
572
|
+
this.diffHunkOverlay = null;
|
|
573
|
+
}
|
|
574
|
+
this.diffHunkUpperNode = null;
|
|
575
|
+
this.diffHunkLowerNode = null;
|
|
576
|
+
}
|
|
577
|
+
computeLineChangesFallback(originalModel, modifiedModel) {
|
|
578
|
+
const original = originalModel.getValue().split(/\r?\n/);
|
|
579
|
+
const modified = modifiedModel.getValue().split(/\r?\n/);
|
|
580
|
+
const n = original.length;
|
|
581
|
+
const m = modified.length;
|
|
582
|
+
if (n === 0 && m === 0) return [];
|
|
583
|
+
const maxCells = 15e5;
|
|
584
|
+
if ((n + 1) * (m + 1) > maxCells) return originalModel.getValue() === modifiedModel.getValue() ? [] : [{
|
|
585
|
+
originalStartLineNumber: 1,
|
|
586
|
+
originalEndLineNumber: n,
|
|
587
|
+
modifiedStartLineNumber: 1,
|
|
588
|
+
modifiedEndLineNumber: m,
|
|
589
|
+
charChanges: []
|
|
590
|
+
}];
|
|
591
|
+
const cols = m + 1;
|
|
592
|
+
const dp = new Uint32Array((n + 1) * (m + 1));
|
|
593
|
+
for (let i$1 = 1; i$1 <= n; i$1++) for (let j$1 = 1; j$1 <= m; j$1++) {
|
|
594
|
+
const idx = i$1 * cols + j$1;
|
|
595
|
+
if (original[i$1 - 1] === modified[j$1 - 1]) dp[idx] = dp[(i$1 - 1) * cols + (j$1 - 1)] + 1;
|
|
596
|
+
else {
|
|
597
|
+
const top = dp[(i$1 - 1) * cols + j$1];
|
|
598
|
+
const left = dp[i$1 * cols + (j$1 - 1)];
|
|
599
|
+
dp[idx] = top >= left ? top : left;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
const matches = [];
|
|
603
|
+
let i = n;
|
|
604
|
+
let j = m;
|
|
605
|
+
while (i > 0 && j > 0) if (original[i - 1] === modified[j - 1]) {
|
|
606
|
+
matches.push({
|
|
607
|
+
o: i,
|
|
608
|
+
m: j
|
|
609
|
+
});
|
|
610
|
+
i--;
|
|
611
|
+
j--;
|
|
612
|
+
} else {
|
|
613
|
+
const top = dp[(i - 1) * cols + j];
|
|
614
|
+
const left = dp[i * cols + (j - 1)];
|
|
615
|
+
if (top >= left) i--;
|
|
616
|
+
else j--;
|
|
617
|
+
}
|
|
618
|
+
matches.reverse();
|
|
619
|
+
matches.push({
|
|
620
|
+
o: n + 1,
|
|
621
|
+
m: m + 1
|
|
622
|
+
});
|
|
623
|
+
const lineChanges = [];
|
|
624
|
+
let prevO = 1;
|
|
625
|
+
let prevM = 1;
|
|
626
|
+
for (const match of matches) {
|
|
627
|
+
const oStart = prevO;
|
|
628
|
+
const oEnd = match.o - 1;
|
|
629
|
+
const mStart = prevM;
|
|
630
|
+
const mEnd = match.m - 1;
|
|
631
|
+
const hasOriginal = oStart <= oEnd;
|
|
632
|
+
const hasModified = mStart <= mEnd;
|
|
633
|
+
if (hasOriginal || hasModified) lineChanges.push({
|
|
634
|
+
originalStartLineNumber: hasOriginal ? oStart : oStart,
|
|
635
|
+
originalEndLineNumber: hasOriginal ? oEnd : oStart - 1,
|
|
636
|
+
modifiedStartLineNumber: hasModified ? mStart : mStart,
|
|
637
|
+
modifiedEndLineNumber: hasModified ? mEnd : mStart - 1,
|
|
638
|
+
charChanges: []
|
|
639
|
+
});
|
|
640
|
+
prevO = match.o + 1;
|
|
641
|
+
prevM = match.m + 1;
|
|
642
|
+
}
|
|
643
|
+
return lineChanges;
|
|
644
|
+
}
|
|
645
|
+
getEffectiveLineChanges() {
|
|
646
|
+
if (!this.diffEditorView) return [];
|
|
647
|
+
const nativeLineChanges = this.diffEditorView.getLineChanges();
|
|
648
|
+
if (nativeLineChanges) {
|
|
649
|
+
this.diffHunkFallbackLineChanges = [];
|
|
650
|
+
this.diffHunkFallbackVersions = null;
|
|
651
|
+
return nativeLineChanges;
|
|
652
|
+
}
|
|
653
|
+
if (!this.originalModel || !this.modifiedModel) return [];
|
|
654
|
+
const versions = {
|
|
655
|
+
original: this.originalModel.getAlternativeVersionId(),
|
|
656
|
+
modified: this.modifiedModel.getAlternativeVersionId()
|
|
657
|
+
};
|
|
658
|
+
if (this.diffHunkFallbackVersions && this.diffHunkFallbackVersions.original === versions.original && this.diffHunkFallbackVersions.modified === versions.modified) return this.diffHunkFallbackLineChanges;
|
|
659
|
+
this.diffHunkFallbackLineChanges = this.computeLineChangesFallback(this.originalModel, this.modifiedModel);
|
|
660
|
+
this.diffHunkFallbackVersions = versions;
|
|
661
|
+
return this.diffHunkFallbackLineChanges;
|
|
662
|
+
}
|
|
663
|
+
ensureDiffUiStyle() {
|
|
664
|
+
if (typeof document === "undefined") return;
|
|
665
|
+
if (document.getElementById(DiffEditorManager.diffUiStyleId)) return;
|
|
666
|
+
const style = document.createElement("style");
|
|
667
|
+
style.id = DiffEditorManager.diffUiStyleId;
|
|
668
|
+
style.textContent = `
|
|
669
|
+
.stream-monaco-diff-root {
|
|
670
|
+
--stream-monaco-unchanged-fg: var(--vscode-diffEditor-unchangedRegionForeground, var(--vscode-editor-foreground, currentColor));
|
|
671
|
+
--stream-monaco-unchanged-bg: var(--vscode-diffEditor-unchangedRegionBackground, transparent);
|
|
672
|
+
--stream-monaco-editor-bg: var(--vscode-editor-background, #fff);
|
|
673
|
+
--stream-monaco-widget-shadow: var(--vscode-widget-shadow, rgb(0 0 0 / 30%));
|
|
674
|
+
--stream-monaco-focus: var(--vscode-focusBorder, var(--stream-monaco-unchanged-fg));
|
|
675
|
+
--stream-monaco-surface: color-mix(in srgb, var(--stream-monaco-unchanged-bg) 82%, var(--stream-monaco-editor-bg) 18%);
|
|
676
|
+
--stream-monaco-surface-hover: color-mix(in srgb, var(--stream-monaco-unchanged-bg) 72%, var(--stream-monaco-editor-bg) 28%);
|
|
677
|
+
--stream-monaco-surface-soft: color-mix(in srgb, var(--stream-monaco-unchanged-bg) 55%, transparent);
|
|
678
|
+
--stream-monaco-border: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 20%, transparent);
|
|
679
|
+
--stream-monaco-border-strong: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 34%, transparent);
|
|
680
|
+
--stream-monaco-muted: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 72%, transparent);
|
|
681
|
+
--stream-monaco-accent-soft: color-mix(in srgb, var(--stream-monaco-focus) 18%, transparent);
|
|
682
|
+
}
|
|
683
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines-widget {
|
|
684
|
+
pointer-events: auto;
|
|
685
|
+
box-sizing: border-box;
|
|
686
|
+
}
|
|
687
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines {
|
|
688
|
+
height: auto;
|
|
689
|
+
width: 100%;
|
|
690
|
+
transform: translateY(-10px);
|
|
691
|
+
padding: 4px 4px 6px;
|
|
692
|
+
box-sizing: border-box;
|
|
693
|
+
}
|
|
694
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .top,
|
|
695
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .bottom {
|
|
696
|
+
display: none !important;
|
|
697
|
+
pointer-events: none !important;
|
|
698
|
+
}
|
|
699
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center {
|
|
700
|
+
align-items: center;
|
|
701
|
+
gap: 10px;
|
|
702
|
+
max-width: calc(100% - 6px);
|
|
703
|
+
min-height: 32px;
|
|
704
|
+
margin: 0 auto;
|
|
705
|
+
padding: 4px 10px 4px 8px;
|
|
706
|
+
border-radius: 14px;
|
|
707
|
+
border: 1px solid var(--stream-monaco-border);
|
|
708
|
+
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%);
|
|
709
|
+
box-shadow: 0 14px 26px -22px var(--stream-monaco-widget-shadow);
|
|
710
|
+
box-sizing: border-box;
|
|
711
|
+
overflow: hidden;
|
|
712
|
+
transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
|
|
713
|
+
}
|
|
714
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-clickable {
|
|
715
|
+
cursor: pointer;
|
|
716
|
+
}
|
|
717
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-unchanged-bridge-source {
|
|
718
|
+
opacity: 0;
|
|
719
|
+
pointer-events: none;
|
|
720
|
+
border-color: transparent;
|
|
721
|
+
background: transparent;
|
|
722
|
+
box-shadow: none;
|
|
723
|
+
transform: none !important;
|
|
724
|
+
}
|
|
725
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-unchanged-bridge-source > * {
|
|
726
|
+
visibility: hidden;
|
|
727
|
+
}
|
|
728
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-unchanged-merged-secondary {
|
|
729
|
+
padding-left: 10px;
|
|
730
|
+
}
|
|
731
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center:hover,
|
|
732
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-focus-within {
|
|
733
|
+
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%);
|
|
734
|
+
border-color: var(--stream-monaco-border-strong);
|
|
735
|
+
box-shadow: 0 18px 30px -24px var(--stream-monaco-widget-shadow);
|
|
736
|
+
transform: translateY(-1px);
|
|
737
|
+
}
|
|
738
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-unchanged-merged-secondary .stream-monaco-unchanged-primary {
|
|
739
|
+
display: none !important;
|
|
740
|
+
}
|
|
741
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-primary,
|
|
742
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-primary {
|
|
743
|
+
display: flex;
|
|
744
|
+
align-items: center;
|
|
745
|
+
flex: 0 0 auto;
|
|
746
|
+
width: auto !important;
|
|
747
|
+
min-width: max-content;
|
|
748
|
+
overflow: visible;
|
|
749
|
+
justify-content: flex-start !important;
|
|
750
|
+
}
|
|
751
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-primary {
|
|
752
|
+
width: 100% !important;
|
|
753
|
+
justify-content: center !important;
|
|
754
|
+
}
|
|
755
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-expand,
|
|
756
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-expand {
|
|
757
|
+
appearance: none;
|
|
758
|
+
display: inline-flex;
|
|
759
|
+
align-items: center;
|
|
760
|
+
justify-content: center;
|
|
761
|
+
gap: 6px;
|
|
762
|
+
min-height: 24px;
|
|
763
|
+
padding: 0 10px;
|
|
764
|
+
border-radius: 999px;
|
|
765
|
+
text-decoration: none;
|
|
766
|
+
color: inherit;
|
|
767
|
+
background: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 12%, transparent);
|
|
768
|
+
border: 1px solid color-mix(in srgb, var(--stream-monaco-unchanged-fg) 10%, transparent);
|
|
769
|
+
font-size: 11px;
|
|
770
|
+
font-weight: 700;
|
|
771
|
+
letter-spacing: 0.01em;
|
|
772
|
+
white-space: nowrap;
|
|
773
|
+
transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
|
|
774
|
+
}
|
|
775
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-expand {
|
|
776
|
+
min-height: 0;
|
|
777
|
+
padding: 0;
|
|
778
|
+
border: 0;
|
|
779
|
+
border-radius: 0;
|
|
780
|
+
background: transparent;
|
|
781
|
+
box-shadow: none;
|
|
782
|
+
}
|
|
783
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-expand::after,
|
|
784
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-expand::after {
|
|
785
|
+
content: attr(data-stream-monaco-label);
|
|
786
|
+
}
|
|
787
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-expand:hover,
|
|
788
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-expand:focus-visible,
|
|
789
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-expand:hover {
|
|
790
|
+
background: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 18%, transparent);
|
|
791
|
+
border-color: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 22%, transparent);
|
|
792
|
+
transform: translateY(-1px);
|
|
793
|
+
}
|
|
794
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-expand:hover {
|
|
795
|
+
background: transparent;
|
|
796
|
+
border-color: transparent;
|
|
797
|
+
transform: none;
|
|
798
|
+
}
|
|
799
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-meta,
|
|
800
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-meta {
|
|
801
|
+
display: flex;
|
|
802
|
+
align-items: center;
|
|
803
|
+
gap: 8px;
|
|
804
|
+
min-width: 0;
|
|
805
|
+
flex: 1 1 auto;
|
|
806
|
+
overflow: hidden;
|
|
807
|
+
color: var(--stream-monaco-muted);
|
|
808
|
+
white-space: nowrap;
|
|
809
|
+
}
|
|
810
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-unchanged-merged-secondary .stream-monaco-unchanged-meta {
|
|
811
|
+
justify-content: center;
|
|
812
|
+
}
|
|
813
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-count,
|
|
814
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-count {
|
|
815
|
+
display: inline-flex;
|
|
816
|
+
align-items: center;
|
|
817
|
+
flex: 0 0 auto;
|
|
818
|
+
padding: 2px 8px;
|
|
819
|
+
border-radius: 999px;
|
|
820
|
+
background: var(--stream-monaco-surface-soft);
|
|
821
|
+
color: var(--stream-monaco-unchanged-fg);
|
|
822
|
+
font-size: 11px;
|
|
823
|
+
font-weight: 700;
|
|
824
|
+
letter-spacing: 0.01em;
|
|
825
|
+
}
|
|
826
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-separator {
|
|
827
|
+
flex: 0 0 auto;
|
|
828
|
+
opacity: 0.35;
|
|
829
|
+
}
|
|
830
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-breadcrumb,
|
|
831
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .breadcrumb-item {
|
|
832
|
+
min-width: 0;
|
|
833
|
+
max-width: 100%;
|
|
834
|
+
}
|
|
835
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-breadcrumb {
|
|
836
|
+
display: inline-flex;
|
|
837
|
+
align-items: center;
|
|
838
|
+
gap: 4px;
|
|
839
|
+
overflow: hidden;
|
|
840
|
+
text-overflow: ellipsis;
|
|
841
|
+
white-space: nowrap;
|
|
842
|
+
border-radius: 6px;
|
|
843
|
+
padding: 2px 6px;
|
|
844
|
+
transition: background-color 0.14s ease, color 0.14s ease;
|
|
845
|
+
}
|
|
846
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center .stream-monaco-unchanged-breadcrumb:hover {
|
|
847
|
+
background: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 10%, transparent);
|
|
848
|
+
color: var(--stream-monaco-unchanged-fg);
|
|
849
|
+
}
|
|
850
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-unchanged-merged-secondary .stream-monaco-unchanged-separator,
|
|
851
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center.stream-monaco-unchanged-merged-secondary .stream-monaco-unchanged-breadcrumb {
|
|
852
|
+
display: none;
|
|
853
|
+
}
|
|
854
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-overlay {
|
|
855
|
+
position: absolute;
|
|
856
|
+
inset: 0;
|
|
857
|
+
pointer-events: none;
|
|
858
|
+
z-index: 12;
|
|
859
|
+
}
|
|
860
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge {
|
|
861
|
+
position: absolute;
|
|
862
|
+
display: grid;
|
|
863
|
+
grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
|
|
864
|
+
align-items: center;
|
|
865
|
+
column-gap: 12px;
|
|
866
|
+
min-height: 32px;
|
|
867
|
+
padding: 4px 12px 4px 10px;
|
|
868
|
+
border-radius: 14px;
|
|
869
|
+
border: 1px solid color-mix(in srgb, var(--stream-monaco-unchanged-fg) 24%, transparent);
|
|
870
|
+
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%);
|
|
871
|
+
box-shadow: 0 14px 26px -22px var(--stream-monaco-widget-shadow);
|
|
872
|
+
box-sizing: border-box;
|
|
873
|
+
overflow: hidden;
|
|
874
|
+
pointer-events: auto;
|
|
875
|
+
transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
|
|
876
|
+
}
|
|
877
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge:hover,
|
|
878
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge.stream-monaco-focus-visible {
|
|
879
|
+
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%);
|
|
880
|
+
border-color: color-mix(in srgb, var(--stream-monaco-unchanged-fg) 32%, transparent);
|
|
881
|
+
box-shadow: 0 18px 30px -24px var(--stream-monaco-widget-shadow);
|
|
882
|
+
transform: translateY(-1px);
|
|
883
|
+
}
|
|
884
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge:focus {
|
|
885
|
+
outline: none;
|
|
886
|
+
}
|
|
887
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-meta {
|
|
888
|
+
justify-self: center;
|
|
889
|
+
justify-content: center;
|
|
890
|
+
}
|
|
891
|
+
.stream-monaco-diff-root .stream-monaco-diff-unchanged-bridge .stream-monaco-unchanged-spacer {
|
|
892
|
+
display: block;
|
|
893
|
+
visibility: hidden;
|
|
894
|
+
width: 100%;
|
|
895
|
+
height: 1px;
|
|
896
|
+
flex: 0 0 auto;
|
|
897
|
+
}
|
|
898
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines-compact {
|
|
899
|
+
align-items: center;
|
|
900
|
+
gap: 6px;
|
|
901
|
+
height: 16px;
|
|
902
|
+
}
|
|
903
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines-compact .text {
|
|
904
|
+
padding: 0 6px;
|
|
905
|
+
border-radius: 999px;
|
|
906
|
+
background: var(--stream-monaco-surface-soft);
|
|
907
|
+
color: var(--stream-monaco-unchanged-fg);
|
|
908
|
+
}
|
|
909
|
+
.stream-monaco-diff-root .monaco-editor .fold-unchanged {
|
|
910
|
+
display: flex !important;
|
|
911
|
+
align-items: center;
|
|
912
|
+
justify-content: center;
|
|
913
|
+
width: 18px !important;
|
|
914
|
+
height: 18px !important;
|
|
915
|
+
margin-left: 4px;
|
|
916
|
+
border-radius: 999px;
|
|
917
|
+
color: var(--stream-monaco-unchanged-fg);
|
|
918
|
+
background: var(--stream-monaco-surface);
|
|
919
|
+
border: 1px solid var(--stream-monaco-border);
|
|
920
|
+
box-shadow: 0 10px 18px -18px var(--stream-monaco-widget-shadow);
|
|
921
|
+
opacity: 0.88 !important;
|
|
922
|
+
transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.14s ease, opacity 0.14s ease, box-shadow 0.14s ease;
|
|
923
|
+
}
|
|
924
|
+
.stream-monaco-diff-root .monaco-editor .fold-unchanged:hover,
|
|
925
|
+
.stream-monaco-diff-root .monaco-editor .fold-unchanged.stream-monaco-focus-visible {
|
|
926
|
+
opacity: 1 !important;
|
|
927
|
+
transform: translateY(-1px);
|
|
928
|
+
background: var(--stream-monaco-surface-hover);
|
|
929
|
+
border-color: var(--stream-monaco-border-strong);
|
|
930
|
+
box-shadow: 0 14px 24px -18px var(--stream-monaco-widget-shadow);
|
|
931
|
+
}
|
|
932
|
+
.stream-monaco-diff-root .monaco-editor .diff-hidden-lines .center:focus,
|
|
933
|
+
.stream-monaco-diff-root .monaco-editor .fold-unchanged:focus {
|
|
934
|
+
outline: none;
|
|
935
|
+
}
|
|
936
|
+
.stream-monaco-diff-hunk-overlay {
|
|
937
|
+
position: absolute;
|
|
938
|
+
inset: 0;
|
|
939
|
+
pointer-events: none;
|
|
940
|
+
z-index: 20;
|
|
941
|
+
}
|
|
942
|
+
.stream-monaco-diff-hunk-actions {
|
|
943
|
+
position: absolute;
|
|
944
|
+
left: 0;
|
|
945
|
+
top: 0;
|
|
946
|
+
display: none;
|
|
947
|
+
gap: 6px;
|
|
948
|
+
pointer-events: auto;
|
|
949
|
+
padding: 4px;
|
|
950
|
+
border-radius: 999px;
|
|
951
|
+
background: color-mix(in srgb, #f8f8f8 92%, #000 8%);
|
|
952
|
+
border: 1px solid color-mix(in srgb, #ddd 88%, #000 12%);
|
|
953
|
+
box-shadow: 0 2px 12px rgb(0 0 0 / 10%);
|
|
954
|
+
}
|
|
955
|
+
.stream-monaco-diff-hunk-actions button {
|
|
956
|
+
appearance: none;
|
|
957
|
+
border: 0;
|
|
958
|
+
border-radius: 999px;
|
|
959
|
+
padding: 3px 9px;
|
|
960
|
+
font-size: 11px;
|
|
961
|
+
line-height: 1.35;
|
|
962
|
+
background: white;
|
|
963
|
+
color: #222;
|
|
964
|
+
cursor: pointer;
|
|
965
|
+
}
|
|
966
|
+
.stream-monaco-diff-hunk-actions button:hover {
|
|
967
|
+
background: #f1f1f1;
|
|
968
|
+
}
|
|
969
|
+
.stream-monaco-diff-hunk-actions button:disabled {
|
|
970
|
+
opacity: 0.45;
|
|
971
|
+
cursor: default;
|
|
972
|
+
}
|
|
973
|
+
`;
|
|
974
|
+
document.head.append(style);
|
|
975
|
+
}
|
|
976
|
+
createDomDisposable(bucket, el, eventName, listener) {
|
|
977
|
+
el.addEventListener(eventName, listener);
|
|
978
|
+
bucket.push({ dispose: () => el.removeEventListener(eventName, listener) });
|
|
979
|
+
}
|
|
980
|
+
createDiffHunkActionNode(side) {
|
|
981
|
+
const node = document.createElement("div");
|
|
982
|
+
node.className = "stream-monaco-diff-hunk-actions";
|
|
983
|
+
node.dataset.side = side;
|
|
984
|
+
const createButton = (action, label) => {
|
|
985
|
+
const button = document.createElement("button");
|
|
986
|
+
button.type = "button";
|
|
987
|
+
button.textContent = label;
|
|
988
|
+
button.dataset.action = action;
|
|
989
|
+
button.addEventListener("click", (event) => {
|
|
990
|
+
event.preventDefault();
|
|
991
|
+
event.stopPropagation();
|
|
992
|
+
this.applyDiffHunkAction(side, action);
|
|
993
|
+
});
|
|
994
|
+
return button;
|
|
995
|
+
};
|
|
996
|
+
node.append(createButton("revert", "Revert"), createButton("stage", "Stage"));
|
|
997
|
+
this.createDomDisposable(this.diffHunkDisposables, node, "mouseenter", () => this.cancelScheduledHideDiffHunkActions());
|
|
998
|
+
this.createDomDisposable(this.diffHunkDisposables, node, "mouseleave", () => this.scheduleHideDiffHunkActions());
|
|
999
|
+
return node;
|
|
1000
|
+
}
|
|
1001
|
+
cloneSerializableValue(value) {
|
|
1002
|
+
if (typeof structuredClone === "function") return structuredClone(value);
|
|
1003
|
+
return JSON.parse(JSON.stringify(value));
|
|
1004
|
+
}
|
|
1005
|
+
capturePersistedDiffUnchangedState() {
|
|
1006
|
+
if (!this.diffEditorView) return;
|
|
1007
|
+
const state = this.diffEditorView.saveViewState();
|
|
1008
|
+
if (!(state === null || state === void 0 ? void 0 : state.modelState)) {
|
|
1009
|
+
this.diffPersistedUnchangedModelState = null;
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
this.diffPersistedUnchangedModelState = this.cloneSerializableValue(state.modelState);
|
|
1013
|
+
}
|
|
1014
|
+
scheduleCapturePersistedDiffUnchangedState(frames = 1) {
|
|
1015
|
+
this.rafScheduler.schedule("capture-diff-unchanged-state", () => {
|
|
1016
|
+
let remaining = Math.max(0, frames);
|
|
1017
|
+
const step = () => {
|
|
1018
|
+
if (remaining > 0) {
|
|
1019
|
+
remaining--;
|
|
1020
|
+
requestAnimationFrame(step);
|
|
1021
|
+
return;
|
|
1022
|
+
}
|
|
1023
|
+
this.capturePersistedDiffUnchangedState();
|
|
1024
|
+
};
|
|
1025
|
+
step();
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
restorePersistedDiffUnchangedState() {
|
|
1029
|
+
if (!this.diffEditorView || !this.diffPersistedUnchangedModelState) return;
|
|
1030
|
+
const current = this.diffEditorView.saveViewState();
|
|
1031
|
+
if (!current) return;
|
|
1032
|
+
this.diffEditorView.restoreViewState({
|
|
1033
|
+
original: current.original,
|
|
1034
|
+
modified: current.modified,
|
|
1035
|
+
modelState: this.cloneSerializableValue(this.diffPersistedUnchangedModelState)
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
scheduleRestorePersistedDiffUnchangedState() {
|
|
1039
|
+
if (!this.diffPersistedUnchangedModelState) return;
|
|
1040
|
+
this.rafScheduler.schedule("restore-diff-unchanged-state", () => {
|
|
1041
|
+
requestAnimationFrame(() => {
|
|
1042
|
+
this.restorePersistedDiffUnchangedState();
|
|
1043
|
+
});
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
bindPersistOnMouseRelease(bucket, node) {
|
|
1047
|
+
this.createDomDisposable(bucket, node, "mousedown", (event) => {
|
|
1048
|
+
const mouseEvent = event;
|
|
1049
|
+
if (mouseEvent.button !== 0) return;
|
|
1050
|
+
const view = node.ownerDocument.defaultView;
|
|
1051
|
+
if (!view) return;
|
|
1052
|
+
const handleMouseUp = () => {
|
|
1053
|
+
view.removeEventListener("mouseup", handleMouseUp);
|
|
1054
|
+
this.scheduleCapturePersistedDiffUnchangedState(1);
|
|
1055
|
+
};
|
|
1056
|
+
view.addEventListener("mouseup", handleMouseUp, { once: true });
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
disposeDiffUnchangedRegionEnhancements() {
|
|
1060
|
+
if (this.diffUnchangedRegionObserver) {
|
|
1061
|
+
this.diffUnchangedRegionObserver.disconnect();
|
|
1062
|
+
this.diffUnchangedRegionObserver = null;
|
|
1063
|
+
}
|
|
1064
|
+
this.clearDiffUnchangedBridgeOverlay();
|
|
1065
|
+
if (this.diffUnchangedRegionDisposables.length > 0) {
|
|
1066
|
+
for (const d of this.diffUnchangedRegionDisposables) try {
|
|
1067
|
+
d.dispose();
|
|
1068
|
+
} catch {}
|
|
1069
|
+
this.diffUnchangedRegionDisposables.length = 0;
|
|
1070
|
+
}
|
|
1071
|
+
this.rafScheduler.cancel("patch-diff-unchanged-regions");
|
|
1072
|
+
this.rafScheduler.cancel("capture-diff-unchanged-state");
|
|
1073
|
+
this.rafScheduler.cancel("restore-diff-unchanged-state");
|
|
1074
|
+
}
|
|
1075
|
+
bindFocusVisibleClass(bucket, node) {
|
|
1076
|
+
this.createDomDisposable(bucket, node, "focus", () => node.classList.add("stream-monaco-focus-visible"));
|
|
1077
|
+
this.createDomDisposable(bucket, node, "blur", () => node.classList.remove("stream-monaco-focus-visible"));
|
|
1078
|
+
}
|
|
1079
|
+
bindFocusWithinClass(bucket, node, className) {
|
|
1080
|
+
this.createDomDisposable(bucket, node, "focusin", () => node.classList.add(className));
|
|
1081
|
+
this.createDomDisposable(bucket, node, "focusout", () => {
|
|
1082
|
+
requestAnimationFrame(() => {
|
|
1083
|
+
if (node.matches(":focus-within")) return;
|
|
1084
|
+
node.classList.remove(className);
|
|
1085
|
+
});
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
clearDiffUnchangedBridgeOverlay(removeContainer = true) {
|
|
1089
|
+
var _this$diffUnchangedBr;
|
|
1090
|
+
if (this.lastContainer) {
|
|
1091
|
+
const bridgedCenters = this.lastContainer.querySelectorAll(".stream-monaco-unchanged-bridge-source");
|
|
1092
|
+
bridgedCenters.forEach((node) => node.classList.remove("stream-monaco-unchanged-bridge-source"));
|
|
1093
|
+
}
|
|
1094
|
+
if (this.diffUnchangedBridgeOverlay) this.diffUnchangedBridgeOverlay.replaceChildren();
|
|
1095
|
+
if (this.diffUnchangedBridgeDisposables.length > 0) {
|
|
1096
|
+
for (const d of this.diffUnchangedBridgeDisposables) try {
|
|
1097
|
+
d.dispose();
|
|
1098
|
+
} catch {}
|
|
1099
|
+
this.diffUnchangedBridgeDisposables.length = 0;
|
|
1100
|
+
}
|
|
1101
|
+
if (removeContainer && ((_this$diffUnchangedBr = this.diffUnchangedBridgeOverlay) === null || _this$diffUnchangedBr === void 0 ? void 0 : _this$diffUnchangedBr.parentElement)) this.diffUnchangedBridgeOverlay.remove();
|
|
1102
|
+
if (removeContainer) this.diffUnchangedBridgeOverlay = null;
|
|
1103
|
+
}
|
|
1104
|
+
ensureDiffUnchangedBridgeOverlay() {
|
|
1105
|
+
if (!this.lastContainer) return null;
|
|
1106
|
+
if (!this.diffUnchangedBridgeOverlay) {
|
|
1107
|
+
const overlay = document.createElement("div");
|
|
1108
|
+
overlay.className = "stream-monaco-diff-unchanged-overlay";
|
|
1109
|
+
this.lastContainer.append(overlay);
|
|
1110
|
+
this.diffUnchangedBridgeOverlay = overlay;
|
|
1111
|
+
}
|
|
1112
|
+
return this.diffUnchangedBridgeOverlay;
|
|
1113
|
+
}
|
|
1114
|
+
dispatchSyntheticMouseDown(node) {
|
|
1115
|
+
const view = node.ownerDocument.defaultView;
|
|
1116
|
+
if (!view) return;
|
|
1117
|
+
const rect = node.getBoundingClientRect();
|
|
1118
|
+
node.dispatchEvent(new view.MouseEvent("mousedown", {
|
|
1119
|
+
bubbles: true,
|
|
1120
|
+
cancelable: true,
|
|
1121
|
+
button: 0,
|
|
1122
|
+
clientX: rect.left + rect.width / 2,
|
|
1123
|
+
clientY: rect.top + rect.height / 2
|
|
1124
|
+
}));
|
|
1125
|
+
}
|
|
1126
|
+
resolveDiffUnchangedMergeRole(node) {
|
|
1127
|
+
var _this$diffEditorView, _this$diffEditorView$, _this$diffEditorView$2, _this$diffEditorView2, _this$diffEditorView3, _this$diffEditorView4;
|
|
1128
|
+
const diffRoot = node.closest(".monaco-diff-editor.side-by-side");
|
|
1129
|
+
if (!(diffRoot instanceof HTMLElement)) return "none";
|
|
1130
|
+
const nodeRect = node.getBoundingClientRect();
|
|
1131
|
+
const nodeCenter = nodeRect.left + nodeRect.width / 2;
|
|
1132
|
+
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$);
|
|
1133
|
+
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);
|
|
1134
|
+
if (originalHost instanceof HTMLElement && modifiedHost instanceof HTMLElement) {
|
|
1135
|
+
const originalRect = originalHost.getBoundingClientRect();
|
|
1136
|
+
const modifiedRect = modifiedHost.getBoundingClientRect();
|
|
1137
|
+
const originalCenter = originalRect.left + originalRect.width / 2;
|
|
1138
|
+
const modifiedCenter = modifiedRect.left + modifiedRect.width / 2;
|
|
1139
|
+
return Math.abs(nodeCenter - originalCenter) <= Math.abs(nodeCenter - modifiedCenter) ? "secondary" : "primary";
|
|
1140
|
+
}
|
|
1141
|
+
const diffRect = diffRoot.getBoundingClientRect();
|
|
1142
|
+
return nodeCenter < diffRect.left + diffRect.width / 2 ? "secondary" : "primary";
|
|
1143
|
+
}
|
|
1144
|
+
patchDiffUnchangedCenter(node) {
|
|
1145
|
+
node.classList.add("stream-monaco-clickable");
|
|
1146
|
+
node.title = "Click to expand all hidden unchanged lines";
|
|
1147
|
+
const mergeRole = this.resolveDiffUnchangedMergeRole(node);
|
|
1148
|
+
const shouldUseMergedSecondary = mergeRole === "secondary";
|
|
1149
|
+
node.classList.toggle("stream-monaco-unchanged-merged-secondary", shouldUseMergedSecondary);
|
|
1150
|
+
node.classList.toggle("stream-monaco-unchanged-merged-primary", mergeRole === "primary");
|
|
1151
|
+
const primary = node.children.item(0);
|
|
1152
|
+
const meta = node.children.item(1);
|
|
1153
|
+
if (primary instanceof HTMLElement) primary.classList.add("stream-monaco-unchanged-primary");
|
|
1154
|
+
if (meta instanceof HTMLElement) {
|
|
1155
|
+
meta.classList.add("stream-monaco-unchanged-meta");
|
|
1156
|
+
const metaChildren = Array.from(meta.children);
|
|
1157
|
+
metaChildren.forEach((child, index) => {
|
|
1158
|
+
if (!(child instanceof HTMLElement)) return;
|
|
1159
|
+
child.classList.remove("stream-monaco-unchanged-count", "stream-monaco-unchanged-separator", "stream-monaco-unchanged-breadcrumb");
|
|
1160
|
+
if (index === 0) child.classList.add("stream-monaco-unchanged-count");
|
|
1161
|
+
else if (child.classList.contains("breadcrumb-item")) child.classList.add("stream-monaco-unchanged-breadcrumb");
|
|
1162
|
+
else child.classList.add("stream-monaco-unchanged-separator");
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
const action = node.querySelector("a");
|
|
1166
|
+
if (action instanceof HTMLElement) {
|
|
1167
|
+
action.classList.add("stream-monaco-unchanged-expand");
|
|
1168
|
+
action.dataset.streamMonacoLabel = "Expand all";
|
|
1169
|
+
action.title = "Expand all hidden lines";
|
|
1170
|
+
action.setAttribute("aria-label", "Expand all hidden lines");
|
|
1171
|
+
action.toggleAttribute("aria-hidden", shouldUseMergedSecondary);
|
|
1172
|
+
action.tabIndex = shouldUseMergedSecondary ? -1 : 0;
|
|
1173
|
+
if (action.dataset.streamMonacoExpandPatched !== "true") {
|
|
1174
|
+
action.dataset.streamMonacoExpandPatched = "true";
|
|
1175
|
+
this.createDomDisposable(this.diffUnchangedRegionDisposables, action, "click", () => {
|
|
1176
|
+
this.scheduleCapturePersistedDiffUnchangedState(1);
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
if (node.dataset.streamMonacoCenterPatched !== "true") {
|
|
1181
|
+
node.dataset.streamMonacoCenterPatched = "true";
|
|
1182
|
+
this.bindFocusWithinClass(this.diffUnchangedRegionDisposables, node, "stream-monaco-focus-within");
|
|
1183
|
+
const activate = () => {
|
|
1184
|
+
const action$1 = node.querySelector("a");
|
|
1185
|
+
if (action$1 instanceof HTMLElement) action$1.click();
|
|
1186
|
+
};
|
|
1187
|
+
this.createDomDisposable(this.diffUnchangedRegionDisposables, node, "click", (event) => {
|
|
1188
|
+
const mouseEvent = event;
|
|
1189
|
+
if (mouseEvent.button !== 0) return;
|
|
1190
|
+
const target = event.target instanceof HTMLElement ? event.target : null;
|
|
1191
|
+
if (target === null || target === void 0 ? void 0 : target.closest("a, .breadcrumb-item")) return;
|
|
1192
|
+
event.preventDefault();
|
|
1193
|
+
activate();
|
|
1194
|
+
this.scheduleCapturePersistedDiffUnchangedState(1);
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
renderMergedDiffUnchangedBridge(secondaryNode, primaryNode) {
|
|
1199
|
+
var _countSource$textCont;
|
|
1200
|
+
if (!this.lastContainer) return;
|
|
1201
|
+
const overlay = this.ensureDiffUnchangedBridgeOverlay();
|
|
1202
|
+
if (!overlay) return;
|
|
1203
|
+
const containerRect = this.lastContainer.getBoundingClientRect();
|
|
1204
|
+
const secondaryRect = secondaryNode.getBoundingClientRect();
|
|
1205
|
+
const primaryRect = primaryNode.getBoundingClientRect();
|
|
1206
|
+
const primaryStyle = globalThis.getComputedStyle(primaryNode);
|
|
1207
|
+
const primaryAction = primaryNode.querySelector(".stream-monaco-unchanged-expand");
|
|
1208
|
+
const primaryActionRect = primaryAction === null || primaryAction === void 0 ? void 0 : primaryAction.getBoundingClientRect();
|
|
1209
|
+
const countSource = primaryNode.querySelector(".stream-monaco-unchanged-count") ?? secondaryNode.querySelector(".stream-monaco-unchanged-count");
|
|
1210
|
+
const countText = (countSource === null || countSource === void 0 || (_countSource$textCont = countSource.textContent) === null || _countSource$textCont === void 0 ? void 0 : _countSource$textCont.trim()) || "Hidden lines";
|
|
1211
|
+
const editorSurface = primaryNode.closest(".monaco-editor") ?? primaryNode;
|
|
1212
|
+
const editorSurfaceStyle = globalThis.getComputedStyle(editorSurface);
|
|
1213
|
+
secondaryNode.classList.add("stream-monaco-unchanged-bridge-source");
|
|
1214
|
+
primaryNode.classList.add("stream-monaco-unchanged-bridge-source");
|
|
1215
|
+
const bridge = document.createElement("div");
|
|
1216
|
+
bridge.className = "stream-monaco-diff-unchanged-bridge";
|
|
1217
|
+
bridge.tabIndex = 0;
|
|
1218
|
+
bridge.setAttribute("role", "button");
|
|
1219
|
+
bridge.setAttribute("aria-label", `${countText}. Expand all hidden lines`);
|
|
1220
|
+
bridge.title = "Expand all hidden lines";
|
|
1221
|
+
bridge.style.left = `${secondaryRect.left - containerRect.left}px`;
|
|
1222
|
+
bridge.style.top = `${primaryRect.top - containerRect.top}px`;
|
|
1223
|
+
bridge.style.width = `${primaryRect.right - secondaryRect.left}px`;
|
|
1224
|
+
bridge.style.height = `${Math.max(secondaryRect.height, primaryRect.height)}px`;
|
|
1225
|
+
bridge.style.color = primaryStyle.color;
|
|
1226
|
+
bridge.style.fontFamily = primaryStyle.fontFamily;
|
|
1227
|
+
bridge.style.fontSize = primaryStyle.fontSize;
|
|
1228
|
+
bridge.style.lineHeight = primaryStyle.lineHeight;
|
|
1229
|
+
bridge.style.setProperty("--stream-monaco-unchanged-fg", primaryStyle.color);
|
|
1230
|
+
bridge.style.setProperty("--stream-monaco-editor-bg", editorSurfaceStyle.backgroundColor);
|
|
1231
|
+
const visualPrimary = document.createElement("span");
|
|
1232
|
+
visualPrimary.className = "stream-monaco-unchanged-primary";
|
|
1233
|
+
const visualAction = document.createElement("span");
|
|
1234
|
+
visualAction.className = "stream-monaco-unchanged-expand";
|
|
1235
|
+
visualAction.dataset.streamMonacoLabel = "Expand all";
|
|
1236
|
+
visualAction.setAttribute("aria-hidden", "true");
|
|
1237
|
+
visualAction.innerHTML = "<span class=\"codicon codicon-unfold\"></span>";
|
|
1238
|
+
visualPrimary.append(visualAction);
|
|
1239
|
+
const visualMeta = document.createElement("div");
|
|
1240
|
+
visualMeta.className = "stream-monaco-unchanged-meta";
|
|
1241
|
+
const visualCount = document.createElement("span");
|
|
1242
|
+
visualCount.className = "stream-monaco-unchanged-count";
|
|
1243
|
+
visualCount.textContent = countText;
|
|
1244
|
+
visualMeta.append(visualCount);
|
|
1245
|
+
const spacer = document.createElement("span");
|
|
1246
|
+
spacer.className = "stream-monaco-unchanged-spacer";
|
|
1247
|
+
spacer.style.width = `${(primaryActionRect === null || primaryActionRect === void 0 ? void 0 : primaryActionRect.width) ?? 102}px`;
|
|
1248
|
+
bridge.append(visualPrimary, visualMeta, spacer);
|
|
1249
|
+
overlay.append(bridge);
|
|
1250
|
+
this.bindFocusVisibleClass(this.diffUnchangedBridgeDisposables, bridge);
|
|
1251
|
+
const activate = () => {
|
|
1252
|
+
const action = primaryNode.querySelector("a, button") ?? secondaryNode.querySelector("a, button");
|
|
1253
|
+
if (action instanceof HTMLElement) {
|
|
1254
|
+
action.click();
|
|
1255
|
+
this.scheduleCapturePersistedDiffUnchangedState(1);
|
|
1256
|
+
}
|
|
1257
|
+
};
|
|
1258
|
+
this.createDomDisposable(this.diffUnchangedBridgeDisposables, bridge, "click", (event) => {
|
|
1259
|
+
const mouseEvent = event;
|
|
1260
|
+
if (mouseEvent.button !== 0) return;
|
|
1261
|
+
event.preventDefault();
|
|
1262
|
+
activate();
|
|
1263
|
+
});
|
|
1264
|
+
this.createDomDisposable(this.diffUnchangedBridgeDisposables, bridge, "keydown", (event) => {
|
|
1265
|
+
const keyboardEvent = event;
|
|
1266
|
+
if (keyboardEvent.key !== "Enter" && keyboardEvent.key !== " ") return;
|
|
1267
|
+
keyboardEvent.preventDefault();
|
|
1268
|
+
activate();
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
patchDiffUnchangedFoldGlyph(node) {
|
|
1272
|
+
if (node.dataset.streamMonacoFoldGlyphPatched === "true") return;
|
|
1273
|
+
node.dataset.streamMonacoFoldGlyphPatched = "true";
|
|
1274
|
+
node.tabIndex = 0;
|
|
1275
|
+
node.setAttribute("role", "button");
|
|
1276
|
+
node.setAttribute("aria-label", "Collapse unchanged lines");
|
|
1277
|
+
node.title = node.title || "Collapse unchanged lines";
|
|
1278
|
+
this.bindFocusVisibleClass(this.diffUnchangedRegionDisposables, node);
|
|
1279
|
+
this.bindPersistOnMouseRelease(this.diffUnchangedRegionDisposables, node);
|
|
1280
|
+
this.createDomDisposable(this.diffUnchangedRegionDisposables, node, "keydown", (event) => {
|
|
1281
|
+
const keyboardEvent = event;
|
|
1282
|
+
if (keyboardEvent.key !== "Enter" && keyboardEvent.key !== " ") return;
|
|
1283
|
+
keyboardEvent.preventDefault();
|
|
1284
|
+
this.dispatchSyntheticMouseDown(node);
|
|
1285
|
+
this.scheduleCapturePersistedDiffUnchangedState(1);
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
scanAndPatchDiffUnchangedRegions() {
|
|
1289
|
+
if (!this.lastContainer) return;
|
|
1290
|
+
const centers = this.lastContainer.querySelectorAll(".diff-hidden-lines .center");
|
|
1291
|
+
centers.forEach((node) => this.patchDiffUnchangedCenter(node));
|
|
1292
|
+
const partialRevealHandles = this.lastContainer.querySelectorAll(".diff-hidden-lines .top, .diff-hidden-lines .bottom");
|
|
1293
|
+
partialRevealHandles.forEach((node) => {
|
|
1294
|
+
node.removeAttribute("title");
|
|
1295
|
+
node.removeAttribute("aria-label");
|
|
1296
|
+
node.removeAttribute("role");
|
|
1297
|
+
node.removeAttribute("tabindex");
|
|
1298
|
+
});
|
|
1299
|
+
this.clearDiffUnchangedBridgeOverlay(false);
|
|
1300
|
+
const secondaryCenters = Array.from(centers).filter((node) => node.classList.contains("stream-monaco-unchanged-merged-secondary")).sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top);
|
|
1301
|
+
const primaryCenters = Array.from(centers).filter((node) => node.classList.contains("stream-monaco-unchanged-merged-primary")).sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top);
|
|
1302
|
+
const pairCount = Math.min(secondaryCenters.length, primaryCenters.length);
|
|
1303
|
+
for (let i = 0; i < pairCount; i++) {
|
|
1304
|
+
const secondaryNode = secondaryCenters[i];
|
|
1305
|
+
const primaryNode = primaryCenters[i];
|
|
1306
|
+
const topDelta = Math.abs(secondaryNode.getBoundingClientRect().top - primaryNode.getBoundingClientRect().top);
|
|
1307
|
+
if (topDelta > 6) continue;
|
|
1308
|
+
this.renderMergedDiffUnchangedBridge(secondaryNode, primaryNode);
|
|
1309
|
+
}
|
|
1310
|
+
const foldGlyphs = this.lastContainer.querySelectorAll(".fold-unchanged");
|
|
1311
|
+
foldGlyphs.forEach((node) => this.patchDiffUnchangedFoldGlyph(node));
|
|
1312
|
+
}
|
|
1313
|
+
schedulePatchDiffUnchangedRegions() {
|
|
1314
|
+
this.rafScheduler.schedule("patch-diff-unchanged-regions", () => {
|
|
1315
|
+
this.scanAndPatchDiffUnchangedRegions();
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
setupDiffUnchangedRegionEnhancements() {
|
|
1319
|
+
var _globalThis$getComput, _globalThis;
|
|
1320
|
+
this.disposeDiffUnchangedRegionEnhancements();
|
|
1321
|
+
if (!this.diffEditorView || !this.lastContainer) return;
|
|
1322
|
+
if (typeof document === "undefined") return;
|
|
1323
|
+
this.ensureDiffUiStyle();
|
|
1324
|
+
const containerStyle = (_globalThis$getComput = (_globalThis = globalThis).getComputedStyle) === null || _globalThis$getComput === void 0 ? void 0 : _globalThis$getComput.call(_globalThis, this.lastContainer);
|
|
1325
|
+
if (!containerStyle || containerStyle.position === "static") this.lastContainer.style.position = "relative";
|
|
1326
|
+
this.lastContainer.classList.add("stream-monaco-diff-root");
|
|
1327
|
+
this.schedulePatchDiffUnchangedRegions();
|
|
1328
|
+
if (typeof MutationObserver !== "undefined") {
|
|
1329
|
+
this.diffUnchangedRegionObserver = new MutationObserver((mutations) => {
|
|
1330
|
+
const shouldRepatch = mutations.some((mutation) => {
|
|
1331
|
+
const target = mutation.target instanceof HTMLElement ? mutation.target : null;
|
|
1332
|
+
if (target === null || target === void 0 ? void 0 : target.closest(".stream-monaco-diff-unchanged-overlay")) return false;
|
|
1333
|
+
const changedNodes = [...mutation.addedNodes, ...mutation.removedNodes];
|
|
1334
|
+
if (changedNodes.length > 0 && changedNodes.every((node) => {
|
|
1335
|
+
return node instanceof HTMLElement && node.classList.contains("stream-monaco-diff-unchanged-overlay");
|
|
1336
|
+
})) return false;
|
|
1337
|
+
return true;
|
|
1338
|
+
});
|
|
1339
|
+
if (shouldRepatch) this.schedulePatchDiffUnchangedRegions();
|
|
1340
|
+
});
|
|
1341
|
+
this.diffUnchangedRegionObserver.observe(this.lastContainer, {
|
|
1342
|
+
childList: true,
|
|
1343
|
+
subtree: true
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
const originalEditor = this.diffEditorView.getOriginalEditor();
|
|
1347
|
+
const modifiedEditor = this.diffEditorView.getModifiedEditor();
|
|
1348
|
+
const repatch = () => this.schedulePatchDiffUnchangedRegions();
|
|
1349
|
+
this.diffUnchangedRegionDisposables.push(this.diffEditorView.onDidUpdateDiff(() => {
|
|
1350
|
+
repatch();
|
|
1351
|
+
this.scheduleRestorePersistedDiffUnchangedState();
|
|
1352
|
+
}));
|
|
1353
|
+
this.diffUnchangedRegionDisposables.push(originalEditor.onDidLayoutChange(repatch));
|
|
1354
|
+
this.diffUnchangedRegionDisposables.push(modifiedEditor.onDidLayoutChange(repatch));
|
|
1355
|
+
this.diffUnchangedRegionDisposables.push(originalEditor.onDidScrollChange(repatch));
|
|
1356
|
+
this.diffUnchangedRegionDisposables.push(modifiedEditor.onDidScrollChange(repatch));
|
|
1357
|
+
}
|
|
1358
|
+
setupDiffHunkInteractions() {
|
|
1359
|
+
var _globalThis$getComput2, _globalThis2;
|
|
1360
|
+
this.disposeDiffHunkInteractions();
|
|
1361
|
+
if (!this.diffEditorView || !this.lastContainer) return;
|
|
1362
|
+
if (this.options.diffHunkActionsOnHover !== true) return;
|
|
1363
|
+
if (typeof document === "undefined") return;
|
|
1364
|
+
this.ensureDiffUiStyle();
|
|
1365
|
+
const containerStyle = (_globalThis$getComput2 = (_globalThis2 = globalThis).getComputedStyle) === null || _globalThis$getComput2 === void 0 ? void 0 : _globalThis$getComput2.call(_globalThis2, this.lastContainer);
|
|
1366
|
+
if (!containerStyle || containerStyle.position === "static") this.lastContainer.style.position = "relative";
|
|
1367
|
+
const overlay = document.createElement("div");
|
|
1368
|
+
overlay.className = "stream-monaco-diff-hunk-overlay";
|
|
1369
|
+
this.diffHunkOverlay = overlay;
|
|
1370
|
+
this.lastContainer.append(overlay);
|
|
1371
|
+
this.diffHunkUpperNode = this.createDiffHunkActionNode("upper");
|
|
1372
|
+
this.diffHunkLowerNode = this.createDiffHunkActionNode("lower");
|
|
1373
|
+
overlay.append(this.diffHunkUpperNode, this.diffHunkLowerNode);
|
|
1374
|
+
const originalEditor = this.diffEditorView.getOriginalEditor();
|
|
1375
|
+
const modifiedEditor = this.diffEditorView.getModifiedEditor();
|
|
1376
|
+
const bindHover = (editor, side) => {
|
|
1377
|
+
this.diffHunkDisposables.push(editor.onMouseMove((event) => {
|
|
1378
|
+
this.handleDiffHunkMouseMove(side, event);
|
|
1379
|
+
}));
|
|
1380
|
+
this.diffHunkDisposables.push(editor.onMouseLeave(() => this.scheduleHideDiffHunkActions()));
|
|
1381
|
+
this.diffHunkDisposables.push(editor.onDidScrollChange(() => this.repositionDiffHunkNodes()));
|
|
1382
|
+
this.diffHunkDisposables.push(editor.onDidLayoutChange(() => this.repositionDiffHunkNodes()));
|
|
1383
|
+
};
|
|
1384
|
+
bindHover(originalEditor, "original");
|
|
1385
|
+
bindHover(modifiedEditor, "modified");
|
|
1386
|
+
this.diffHunkDisposables.push(this.diffEditorView.onDidUpdateDiff(() => {
|
|
1387
|
+
this.diffHunkLineChanges = this.getEffectiveLineChanges();
|
|
1388
|
+
if (this.diffHunkActiveChange) this.hideDiffHunkActions();
|
|
1389
|
+
}));
|
|
1390
|
+
this.diffHunkLineChanges = this.getEffectiveLineChanges();
|
|
1391
|
+
}
|
|
1392
|
+
cancelScheduledHideDiffHunkActions() {
|
|
1393
|
+
if (this.diffHunkHideTimer != null) {
|
|
1394
|
+
clearTimeout(this.diffHunkHideTimer);
|
|
1395
|
+
this.diffHunkHideTimer = null;
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
scheduleHideDiffHunkActions(delayMs = this.options.diffHunkHoverHideDelayMs ?? 160) {
|
|
1399
|
+
this.cancelScheduledHideDiffHunkActions();
|
|
1400
|
+
this.diffHunkHideTimer = setTimeout(() => {
|
|
1401
|
+
this.diffHunkHideTimer = null;
|
|
1402
|
+
this.hideDiffHunkActions();
|
|
1403
|
+
}, delayMs);
|
|
1404
|
+
}
|
|
1405
|
+
hideDiffHunkActions() {
|
|
1406
|
+
this.diffHunkActiveChange = null;
|
|
1407
|
+
if (this.diffHunkUpperNode) this.diffHunkUpperNode.style.display = "none";
|
|
1408
|
+
if (this.diffHunkLowerNode) this.diffHunkLowerNode.style.display = "none";
|
|
1409
|
+
}
|
|
1410
|
+
hasOriginalLines(change) {
|
|
1411
|
+
return change.originalStartLineNumber > 0 && change.originalEndLineNumber >= change.originalStartLineNumber;
|
|
1412
|
+
}
|
|
1413
|
+
hasModifiedLines(change) {
|
|
1414
|
+
return change.modifiedStartLineNumber > 0 && change.modifiedEndLineNumber >= change.modifiedStartLineNumber;
|
|
1415
|
+
}
|
|
1416
|
+
distanceToLineChange(side, change, line) {
|
|
1417
|
+
const hasRange = side === "original" ? this.hasOriginalLines(change) : this.hasModifiedLines(change);
|
|
1418
|
+
const start = side === "original" ? change.originalStartLineNumber : change.modifiedStartLineNumber;
|
|
1419
|
+
const end = side === "original" ? change.originalEndLineNumber : change.modifiedEndLineNumber;
|
|
1420
|
+
if (hasRange) {
|
|
1421
|
+
if (line < start) return start - line;
|
|
1422
|
+
if (line > end) return line - end;
|
|
1423
|
+
return 0;
|
|
1424
|
+
}
|
|
1425
|
+
const fallbackAnchor = Math.max(1, start || end || 1);
|
|
1426
|
+
return Math.abs(line - fallbackAnchor);
|
|
1427
|
+
}
|
|
1428
|
+
findLineChangeByHoverLine(side, line) {
|
|
1429
|
+
if (this.diffHunkLineChanges.length === 0) return null;
|
|
1430
|
+
let best = null;
|
|
1431
|
+
let bestDistance = Number.POSITIVE_INFINITY;
|
|
1432
|
+
for (const change of this.diffHunkLineChanges) {
|
|
1433
|
+
const distance = this.distanceToLineChange(side, change, line);
|
|
1434
|
+
if (distance < bestDistance) {
|
|
1435
|
+
bestDistance = distance;
|
|
1436
|
+
best = change;
|
|
1437
|
+
if (distance === 0) break;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
if (bestDistance > 2) return null;
|
|
1441
|
+
return best;
|
|
1442
|
+
}
|
|
1443
|
+
handleDiffHunkMouseMove(side, event) {
|
|
1444
|
+
var _event$target$positio;
|
|
1445
|
+
const line = (_event$target$positio = event.target.position) === null || _event$target$positio === void 0 ? void 0 : _event$target$positio.lineNumber;
|
|
1446
|
+
if (!line) {
|
|
1447
|
+
this.scheduleHideDiffHunkActions(120);
|
|
1448
|
+
return;
|
|
1449
|
+
}
|
|
1450
|
+
const change = this.findLineChangeByHoverLine(side, line);
|
|
1451
|
+
if (!change) {
|
|
1452
|
+
this.scheduleHideDiffHunkActions(120);
|
|
1453
|
+
return;
|
|
1454
|
+
}
|
|
1455
|
+
this.cancelScheduledHideDiffHunkActions();
|
|
1456
|
+
this.diffHunkActiveChange = change;
|
|
1457
|
+
this.repositionDiffHunkNodes();
|
|
1458
|
+
}
|
|
1459
|
+
isOriginalEditorCollapsed() {
|
|
1460
|
+
var _this$diffEditorView$3, _this$diffEditorView$4;
|
|
1461
|
+
if (!this.diffEditorView) return true;
|
|
1462
|
+
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);
|
|
1463
|
+
return !info || info.width < 24;
|
|
1464
|
+
}
|
|
1465
|
+
getEditorBySide(side) {
|
|
1466
|
+
if (!this.diffEditorView) return null;
|
|
1467
|
+
return side === "original" ? this.diffEditorView.getOriginalEditor() : this.diffEditorView.getModifiedEditor();
|
|
1468
|
+
}
|
|
1469
|
+
getFullLineRange(model, startLine, endLine) {
|
|
1470
|
+
if (endLine < startLine) return null;
|
|
1471
|
+
const lineCount = model.getLineCount();
|
|
1472
|
+
if (lineCount < 1) return null;
|
|
1473
|
+
const start = Math.max(1, Math.min(startLine, lineCount));
|
|
1474
|
+
const end = Math.max(start, Math.min(endLine, lineCount));
|
|
1475
|
+
if (end < lineCount) return new monaco_shim_exports.Range(start, 1, end + 1, 1);
|
|
1476
|
+
return new monaco_shim_exports.Range(start, 1, end, model.getLineMaxColumn(end));
|
|
1477
|
+
}
|
|
1478
|
+
getLinesText(model, startLine, endLine) {
|
|
1479
|
+
const range = this.getFullLineRange(model, startLine, endLine);
|
|
1480
|
+
if (!range) return "";
|
|
1481
|
+
return model.getValueInRange(range);
|
|
1482
|
+
}
|
|
1483
|
+
getInsertRangeBeforeLine(model, lineNumber) {
|
|
1484
|
+
const lineCount = model.getLineCount();
|
|
1485
|
+
if (lineNumber <= 1) return new monaco_shim_exports.Range(1, 1, 1, 1);
|
|
1486
|
+
if (lineNumber <= lineCount) return new monaco_shim_exports.Range(lineNumber, 1, lineNumber, 1);
|
|
1487
|
+
const lastLine = lineCount;
|
|
1488
|
+
const lastColumn = model.getLineMaxColumn(lastLine);
|
|
1489
|
+
return new monaco_shim_exports.Range(lastLine, lastColumn, lastLine, lastColumn);
|
|
1490
|
+
}
|
|
1491
|
+
getInsertRangeAfterLine(model, lineNumber) {
|
|
1492
|
+
const lineCount = model.getLineCount();
|
|
1493
|
+
if (lineNumber < 1) return new monaco_shim_exports.Range(1, 1, 1, 1);
|
|
1494
|
+
if (lineNumber < lineCount) return new monaco_shim_exports.Range(lineNumber + 1, 1, lineNumber + 1, 1);
|
|
1495
|
+
const lastLine = lineCount;
|
|
1496
|
+
const lastColumn = model.getLineMaxColumn(lastLine);
|
|
1497
|
+
return new monaco_shim_exports.Range(lastLine, lastColumn, lastLine, lastColumn);
|
|
1498
|
+
}
|
|
1499
|
+
syncDiffKnownValues() {
|
|
1500
|
+
var _this$diffEditorView5, _this$diffEditorView6, _this$diffEditorView7, _this$diffHeightManag;
|
|
1501
|
+
if (this.originalModel) this.lastKnownOriginalCode = this.originalModel.getValue();
|
|
1502
|
+
if (this.modifiedModel) {
|
|
1503
|
+
this.lastKnownModifiedCode = this.modifiedModel.getValue();
|
|
1504
|
+
this.lastKnownModifiedLineCount = this.modifiedModel.getLineCount();
|
|
1505
|
+
}
|
|
1506
|
+
this.lastKnownModifiedDirty = false;
|
|
1507
|
+
this._hasScrollBar = false;
|
|
1508
|
+
this.cachedComputedHeightDiff = this.computedHeight();
|
|
1509
|
+
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;
|
|
1510
|
+
(_this$diffHeightManag = this.diffHeightManager) === null || _this$diffHeightManag === void 0 || _this$diffHeightManag.update();
|
|
1511
|
+
}
|
|
1512
|
+
applyDefaultDiffHunkAction(context) {
|
|
1513
|
+
const { action, side, lineChange } = context;
|
|
1514
|
+
if (!this.originalModel || !this.modifiedModel) return;
|
|
1515
|
+
const hasOriginal = this.hasOriginalLines(lineChange);
|
|
1516
|
+
const hasModified = this.hasModifiedLines(lineChange);
|
|
1517
|
+
if (action === "revert" && side === "upper") {
|
|
1518
|
+
if (!hasOriginal) return;
|
|
1519
|
+
const text = this.getLinesText(this.originalModel, lineChange.originalStartLineNumber, lineChange.originalEndLineNumber);
|
|
1520
|
+
if (!text) return;
|
|
1521
|
+
const anchor = hasModified ? lineChange.modifiedStartLineNumber : Math.max(1, lineChange.modifiedStartLineNumber || lineChange.modifiedEndLineNumber || this.modifiedModel.getLineCount());
|
|
1522
|
+
const range = this.getInsertRangeBeforeLine(this.modifiedModel, anchor);
|
|
1523
|
+
this.modifiedModel.applyEdits([{
|
|
1524
|
+
range,
|
|
1525
|
+
text,
|
|
1526
|
+
forceMoveMarkers: true
|
|
1527
|
+
}]);
|
|
1528
|
+
return;
|
|
1529
|
+
}
|
|
1530
|
+
if (action === "revert" && side === "lower") {
|
|
1531
|
+
if (!hasModified) return;
|
|
1532
|
+
const range = this.getFullLineRange(this.modifiedModel, lineChange.modifiedStartLineNumber, lineChange.modifiedEndLineNumber);
|
|
1533
|
+
if (!range) return;
|
|
1534
|
+
this.modifiedModel.applyEdits([{
|
|
1535
|
+
range,
|
|
1536
|
+
text: "",
|
|
1537
|
+
forceMoveMarkers: true
|
|
1538
|
+
}]);
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1541
|
+
if (action === "stage" && side === "upper") {
|
|
1542
|
+
if (!hasOriginal) return;
|
|
1543
|
+
const range = this.getFullLineRange(this.originalModel, lineChange.originalStartLineNumber, lineChange.originalEndLineNumber);
|
|
1544
|
+
if (!range) return;
|
|
1545
|
+
this.originalModel.applyEdits([{
|
|
1546
|
+
range,
|
|
1547
|
+
text: "",
|
|
1548
|
+
forceMoveMarkers: true
|
|
1549
|
+
}]);
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
if (action === "stage" && side === "lower") {
|
|
1553
|
+
if (!hasModified) return;
|
|
1554
|
+
const text = this.getLinesText(this.modifiedModel, lineChange.modifiedStartLineNumber, lineChange.modifiedEndLineNumber);
|
|
1555
|
+
if (!text) return;
|
|
1556
|
+
const anchor = hasOriginal ? lineChange.originalEndLineNumber : Math.max(0, lineChange.originalStartLineNumber - 1);
|
|
1557
|
+
const range = this.getInsertRangeAfterLine(this.originalModel, anchor);
|
|
1558
|
+
this.originalModel.applyEdits([{
|
|
1559
|
+
range,
|
|
1560
|
+
text,
|
|
1561
|
+
forceMoveMarkers: true
|
|
1562
|
+
}]);
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
applyDiffHunkAction(side, action) {
|
|
1566
|
+
if (!this.diffHunkActiveChange || !this.originalModel || !this.modifiedModel) return;
|
|
1567
|
+
this.flushOriginalAppendBufferSync();
|
|
1568
|
+
this.flushModifiedAppendBufferSync();
|
|
1569
|
+
const context = {
|
|
1570
|
+
action,
|
|
1571
|
+
side,
|
|
1572
|
+
lineChange: this.diffHunkActiveChange,
|
|
1573
|
+
originalModel: this.originalModel,
|
|
1574
|
+
modifiedModel: this.modifiedModel
|
|
1575
|
+
};
|
|
1576
|
+
let allowDefault = true;
|
|
1577
|
+
if (typeof this.options.onDiffHunkAction === "function") try {
|
|
1578
|
+
allowDefault = this.options.onDiffHunkAction(context) !== false;
|
|
1579
|
+
} catch (error$1) {
|
|
1580
|
+
console.warn("onDiffHunkAction callback threw an error:", error$1);
|
|
1581
|
+
}
|
|
1582
|
+
if (allowDefault) this.applyDefaultDiffHunkAction(context);
|
|
1583
|
+
this.syncDiffKnownValues();
|
|
1584
|
+
this.hideDiffHunkActions();
|
|
1585
|
+
}
|
|
1586
|
+
setDiffHunkNodeEnabled(node, enabled) {
|
|
1587
|
+
if (!node) return;
|
|
1588
|
+
const buttons = node.querySelectorAll("button");
|
|
1589
|
+
buttons.forEach((button) => {
|
|
1590
|
+
button.disabled = !enabled;
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
positionDiffHunkNode(node, side, anchorLine, extraOffsetY = 0) {
|
|
1594
|
+
var _editor$getScrollTop;
|
|
1595
|
+
if (!this.diffHunkOverlay) return;
|
|
1596
|
+
const editor = this.getEditorBySide(side);
|
|
1597
|
+
if (!editor) return;
|
|
1598
|
+
const host = editor.getContainerDomNode();
|
|
1599
|
+
const line = Math.max(1, anchorLine);
|
|
1600
|
+
const rawTop = editor.getTopForLineNumber(line) - (((_editor$getScrollTop = editor.getScrollTop) === null || _editor$getScrollTop === void 0 ? void 0 : _editor$getScrollTop.call(editor)) ?? 0);
|
|
1601
|
+
const lineHeight = editor.getOption(monaco_shim_exports.editor.EditorOption.lineHeight);
|
|
1602
|
+
const nodeWidth = node.offsetWidth || 130;
|
|
1603
|
+
const nodeHeight = node.offsetHeight || 30;
|
|
1604
|
+
const left = host.offsetLeft + Math.max(6, host.clientWidth - nodeWidth - 10);
|
|
1605
|
+
const hostTop = host.offsetTop;
|
|
1606
|
+
const minTop = hostTop + 4;
|
|
1607
|
+
const maxTop = hostTop + Math.max(4, host.clientHeight - nodeHeight - 4);
|
|
1608
|
+
const top = Math.min(maxTop, Math.max(minTop, hostTop + rawTop + Math.round(lineHeight * .2) + extraOffsetY));
|
|
1609
|
+
node.style.transform = `translate(${Math.round(left)}px, ${Math.round(top)}px)`;
|
|
1610
|
+
node.style.display = "flex";
|
|
1611
|
+
}
|
|
1612
|
+
repositionDiffHunkNodes() {
|
|
1613
|
+
if (!this.diffHunkActiveChange) {
|
|
1614
|
+
this.hideDiffHunkActions();
|
|
1615
|
+
return;
|
|
1616
|
+
}
|
|
1617
|
+
if (!this.diffHunkUpperNode || !this.diffHunkLowerNode) return;
|
|
1618
|
+
if (!this.diffEditorView) return;
|
|
1619
|
+
const change = this.diffHunkActiveChange;
|
|
1620
|
+
const hasOriginal = this.hasOriginalLines(change);
|
|
1621
|
+
const hasModified = this.hasModifiedLines(change);
|
|
1622
|
+
this.setDiffHunkNodeEnabled(this.diffHunkUpperNode, hasOriginal);
|
|
1623
|
+
this.setDiffHunkNodeEnabled(this.diffHunkLowerNode, hasModified);
|
|
1624
|
+
const originalCollapsed = this.isOriginalEditorCollapsed();
|
|
1625
|
+
if (hasOriginal) {
|
|
1626
|
+
const upperSide = originalCollapsed ? "modified" : "original";
|
|
1627
|
+
const upperAnchor = originalCollapsed ? Math.max(1, change.modifiedStartLineNumber || change.modifiedEndLineNumber || 1) : change.originalStartLineNumber;
|
|
1628
|
+
this.positionDiffHunkNode(this.diffHunkUpperNode, upperSide, upperAnchor);
|
|
1629
|
+
} else this.diffHunkUpperNode.style.display = "none";
|
|
1630
|
+
if (hasModified) {
|
|
1631
|
+
const samePane = originalCollapsed;
|
|
1632
|
+
const lowerAnchor = change.modifiedStartLineNumber;
|
|
1633
|
+
this.positionDiffHunkNode(this.diffHunkLowerNode, "modified", lowerAnchor, samePane ? 32 : 0);
|
|
1634
|
+
} else this.diffHunkLowerNode.style.display = "none";
|
|
509
1635
|
}
|
|
510
1636
|
scheduleFlushAppendBufferDiff() {
|
|
511
1637
|
if (this.appendBufferDiffScheduled) return;
|
|
@@ -702,9 +1828,9 @@ var DiffEditorManager = class {
|
|
|
702
1828
|
lastRevealLineDiff: this.lastRevealLineDiff
|
|
703
1829
|
});
|
|
704
1830
|
try {
|
|
705
|
-
var _this$
|
|
1831
|
+
var _this$diffEditorView8, _this$diffEditorView9, _this$diffEditorView10;
|
|
706
1832
|
this.shouldAutoScrollDiff = true;
|
|
707
|
-
this.lastScrollTopDiff = ((_this$
|
|
1833
|
+
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;
|
|
708
1834
|
} catch {}
|
|
709
1835
|
});
|
|
710
1836
|
}
|
|
@@ -723,9 +1849,9 @@ var DiffEditorManager = class {
|
|
|
723
1849
|
ticket
|
|
724
1850
|
});
|
|
725
1851
|
try {
|
|
726
|
-
var _this$
|
|
1852
|
+
var _this$diffEditorView11, _this$diffEditorView12, _this$diffEditorView13;
|
|
727
1853
|
this.shouldAutoScrollDiff = true;
|
|
728
|
-
this.lastScrollTopDiff = ((_this$
|
|
1854
|
+
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;
|
|
729
1855
|
} catch {}
|
|
730
1856
|
}
|
|
731
1857
|
scheduleImmediateRevealAfterLayoutDiff(line) {
|
|
@@ -766,6 +1892,7 @@ var DiffEditorManager = class {
|
|
|
766
1892
|
const lang = processedLanguage(language) || language;
|
|
767
1893
|
this.originalModel = monaco_shim_exports.editor.createModel(originalCode, lang);
|
|
768
1894
|
this.modifiedModel = monaco_shim_exports.editor.createModel(modifiedCode, lang);
|
|
1895
|
+
const hideUnchangedRegions = this.resolveDiffHideUnchangedRegionsOption();
|
|
769
1896
|
this.diffEditorView = monaco_shim_exports.editor.createDiffEditor(container, {
|
|
770
1897
|
automaticLayout: true,
|
|
771
1898
|
scrollBeyondLastLine: false,
|
|
@@ -779,7 +1906,8 @@ var DiffEditorManager = class {
|
|
|
779
1906
|
...defaultScrollbar,
|
|
780
1907
|
...this.options.scrollbar || {}
|
|
781
1908
|
},
|
|
782
|
-
...this.options
|
|
1909
|
+
...this.options,
|
|
1910
|
+
hideUnchangedRegions
|
|
783
1911
|
});
|
|
784
1912
|
monaco_shim_exports.editor.setTheme(currentTheme);
|
|
785
1913
|
this.diffEditorView.setModel({
|
|
@@ -788,7 +1916,7 @@ var DiffEditorManager = class {
|
|
|
788
1916
|
});
|
|
789
1917
|
this.lastKnownOriginalCode = originalCode;
|
|
790
1918
|
this.lastKnownModifiedCode = modifiedCode;
|
|
791
|
-
this.diffUpdateThrottleMs = this.options.diffUpdateThrottleMs ?? 50;
|
|
1919
|
+
this.diffUpdateThrottleMs = this.diffUpdateThrottleMsOption ?? this.options.diffUpdateThrottleMs ?? 50;
|
|
792
1920
|
this.shouldAutoScrollDiff = !!(this.autoScrollInitial && this.diffAutoScroll);
|
|
793
1921
|
if (this.diffScrollWatcher) {
|
|
794
1922
|
this.diffScrollWatcher.dispose();
|
|
@@ -837,12 +1965,12 @@ var DiffEditorManager = class {
|
|
|
837
1965
|
(_oEditor$onDidContent = oEditor.onDidContentSizeChange) === null || _oEditor$onDidContent === void 0 || _oEditor$onDidContent.call(oEditor, () => {
|
|
838
1966
|
this._hasScrollBar = false;
|
|
839
1967
|
this.rafScheduler.schedule("content-size-change-diff", () => {
|
|
840
|
-
var _oEditor$getScrollHei, _oEditor$getOption, _this$
|
|
1968
|
+
var _oEditor$getScrollHei, _oEditor$getOption, _this$diffHeightManag2, _this$diffHeightManag3;
|
|
841
1969
|
this.cachedScrollHeightDiff = ((_oEditor$getScrollHei = oEditor.getScrollHeight) === null || _oEditor$getScrollHei === void 0 ? void 0 : _oEditor$getScrollHei.call(oEditor)) ?? this.cachedScrollHeightDiff;
|
|
842
1970
|
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;
|
|
843
1971
|
this.cachedComputedHeightDiff = this.computedHeight();
|
|
844
|
-
if ((_this$
|
|
845
|
-
(_this$
|
|
1972
|
+
if ((_this$diffHeightManag2 = this.diffHeightManager) === null || _this$diffHeightManag2 === void 0 ? void 0 : _this$diffHeightManag2.isSuppressed()) return;
|
|
1973
|
+
(_this$diffHeightManag3 = this.diffHeightManager) === null || _this$diffHeightManag3 === void 0 || _this$diffHeightManag3.update();
|
|
846
1974
|
const computed$2 = this.computedHeight();
|
|
847
1975
|
if (this.lastContainer) {
|
|
848
1976
|
const prevOverflow = this.lastContainer.style.overflow;
|
|
@@ -860,12 +1988,12 @@ var DiffEditorManager = class {
|
|
|
860
1988
|
(_mEditor$onDidContent = mEditor.onDidContentSizeChange) === null || _mEditor$onDidContent === void 0 || _mEditor$onDidContent.call(mEditor, () => {
|
|
861
1989
|
this._hasScrollBar = false;
|
|
862
1990
|
this.rafScheduler.schedule("content-size-change-diff", () => {
|
|
863
|
-
var _mEditor$getScrollHei, _mEditor$getOption, _this$
|
|
1991
|
+
var _mEditor$getScrollHei, _mEditor$getOption, _this$diffHeightManag4, _this$diffHeightManag5;
|
|
864
1992
|
this.cachedScrollHeightDiff = ((_mEditor$getScrollHei = mEditor.getScrollHeight) === null || _mEditor$getScrollHei === void 0 ? void 0 : _mEditor$getScrollHei.call(mEditor)) ?? this.cachedScrollHeightDiff;
|
|
865
1993
|
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;
|
|
866
1994
|
this.cachedComputedHeightDiff = this.computedHeight();
|
|
867
|
-
if ((_this$
|
|
868
|
-
(_this$
|
|
1995
|
+
if ((_this$diffHeightManag4 = this.diffHeightManager) === null || _this$diffHeightManag4 === void 0 ? void 0 : _this$diffHeightManag4.isSuppressed()) return;
|
|
1996
|
+
(_this$diffHeightManag5 = this.diffHeightManager) === null || _this$diffHeightManag5 === void 0 || _this$diffHeightManag5.update();
|
|
869
1997
|
const computed$2 = this.computedHeight();
|
|
870
1998
|
if (this.lastContainer) {
|
|
871
1999
|
const prevOverflow = this.lastContainer.style.overflow;
|
|
@@ -885,6 +2013,8 @@ var DiffEditorManager = class {
|
|
|
885
2013
|
this.rafScheduler.schedule("sync-last-known-modified", () => this.syncLastKnownModified());
|
|
886
2014
|
});
|
|
887
2015
|
this.maybeScrollDiffToBottom(this.modifiedModel.getLineCount(), this.lastKnownModifiedLineCount ?? void 0);
|
|
2016
|
+
this.setupDiffUnchangedRegionEnhancements();
|
|
2017
|
+
this.setupDiffHunkInteractions();
|
|
888
2018
|
return this.diffEditorView;
|
|
889
2019
|
}
|
|
890
2020
|
updateDiff(originalCode, modifiedCode, codeLanguage) {
|
|
@@ -1026,6 +2156,8 @@ var DiffEditorManager = class {
|
|
|
1026
2156
|
}
|
|
1027
2157
|
this.rafScheduler.cancel("content-size-change-diff");
|
|
1028
2158
|
this.rafScheduler.cancel("sync-last-known-modified");
|
|
2159
|
+
this.disposeDiffHunkInteractions();
|
|
2160
|
+
this.disposeDiffUnchangedRegionEnhancements();
|
|
1029
2161
|
if (this.diffScrollWatcher) {
|
|
1030
2162
|
this.diffScrollWatcher.dispose();
|
|
1031
2163
|
this.diffScrollWatcher = null;
|
|
@@ -1049,6 +2181,7 @@ var DiffEditorManager = class {
|
|
|
1049
2181
|
this.lastKnownOriginalCode = null;
|
|
1050
2182
|
this.lastKnownModifiedCode = null;
|
|
1051
2183
|
if (this.lastContainer) {
|
|
2184
|
+
this.lastContainer.classList.remove("stream-monaco-diff-root");
|
|
1052
2185
|
this.lastContainer.innerHTML = "";
|
|
1053
2186
|
this.lastContainer = null;
|
|
1054
2187
|
}
|
|
@@ -1066,6 +2199,7 @@ var DiffEditorManager = class {
|
|
|
1066
2199
|
}
|
|
1067
2200
|
this.revealTicketDiff = 0;
|
|
1068
2201
|
this.lastRevealLineDiff = null;
|
|
2202
|
+
this.diffPersistedUnchangedModelState = null;
|
|
1069
2203
|
}
|
|
1070
2204
|
safeClean() {
|
|
1071
2205
|
this.rafScheduler.cancel("diff");
|
|
@@ -1078,6 +2212,9 @@ var DiffEditorManager = class {
|
|
|
1078
2212
|
clearTimeout(this.appendFlushThrottleTimerDiff);
|
|
1079
2213
|
this.appendFlushThrottleTimerDiff = null;
|
|
1080
2214
|
}
|
|
2215
|
+
this.hideDiffHunkActions();
|
|
2216
|
+
this.cancelScheduledHideDiffHunkActions();
|
|
2217
|
+
this.disposeDiffUnchangedRegionEnhancements();
|
|
1081
2218
|
if (this.diffScrollWatcher) {
|
|
1082
2219
|
this.diffScrollWatcher.dispose();
|
|
1083
2220
|
this.diffScrollWatcher = null;
|
|
@@ -1103,6 +2240,7 @@ var DiffEditorManager = class {
|
|
|
1103
2240
|
}
|
|
1104
2241
|
this.revealTicketDiff = 0;
|
|
1105
2242
|
this.lastRevealLineDiff = null;
|
|
2243
|
+
this.diffPersistedUnchangedModelState = null;
|
|
1106
2244
|
this.rafScheduler.cancel("content-size-change-diff");
|
|
1107
2245
|
this.rafScheduler.cancel("sync-last-known-modified");
|
|
1108
2246
|
}
|
|
@@ -1301,9 +2439,9 @@ var DiffEditorManager = class {
|
|
|
1301
2439
|
} catch {}
|
|
1302
2440
|
if (suppressedByFlush) watcherApi.setSuppressed(false);
|
|
1303
2441
|
try {
|
|
1304
|
-
var _this$
|
|
2442
|
+
var _this$diffEditorView14, _this$diffEditorView15, _this$diffEditorView16;
|
|
1305
2443
|
this.shouldAutoScrollDiff = true;
|
|
1306
|
-
this.lastScrollTopDiff = ((_this$
|
|
2444
|
+
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;
|
|
1307
2445
|
} catch {}
|
|
1308
2446
|
}
|
|
1309
2447
|
applyMinimalEditToModel(model, prev, next) {
|
|
@@ -1987,6 +3125,41 @@ function arraysEqual(a, b) {
|
|
|
1987
3125
|
|
|
1988
3126
|
//#endregion
|
|
1989
3127
|
//#region src/utils/registerMonacoThemes.ts
|
|
3128
|
+
const LEGACY_ONIG_INIT_KEY = "__streamMonacoLegacyOnigurumaInit__";
|
|
3129
|
+
const LEGACY_ENGINE_KEY = "__streamMonacoLegacyShikiEngine__";
|
|
3130
|
+
const LEGACY_MONACO_LANGS_INIT_KEY = "__streamMonacoLegacyMonacoLangsInit__";
|
|
3131
|
+
async function awaitLegacyOnigurumaInitIfPresent() {
|
|
3132
|
+
try {
|
|
3133
|
+
var _globalThis;
|
|
3134
|
+
const p = (_globalThis = globalThis) === null || _globalThis === void 0 ? void 0 : _globalThis[LEGACY_ONIG_INIT_KEY];
|
|
3135
|
+
if (p && typeof p.then === "function") await p;
|
|
3136
|
+
} catch {}
|
|
3137
|
+
}
|
|
3138
|
+
async function awaitLegacyMonacoLanguageContributionsIfPresent() {
|
|
3139
|
+
try {
|
|
3140
|
+
var _globalThis2;
|
|
3141
|
+
const p = (_globalThis2 = globalThis) === null || _globalThis2 === void 0 ? void 0 : _globalThis2[LEGACY_MONACO_LANGS_INIT_KEY];
|
|
3142
|
+
if (p && typeof p.then === "function") await p;
|
|
3143
|
+
} catch {}
|
|
3144
|
+
}
|
|
3145
|
+
async function getLegacyShikiEngineIfPresent() {
|
|
3146
|
+
try {
|
|
3147
|
+
var _globalThis3;
|
|
3148
|
+
const p = (_globalThis3 = globalThis) === null || _globalThis3 === void 0 ? void 0 : _globalThis3[LEGACY_ENGINE_KEY];
|
|
3149
|
+
if (p && typeof p.then === "function") return await p;
|
|
3150
|
+
} catch {}
|
|
3151
|
+
return null;
|
|
3152
|
+
}
|
|
3153
|
+
async function createHighlighterWithLegacyEngineIfNeeded(options) {
|
|
3154
|
+
await awaitLegacyOnigurumaInitIfPresent();
|
|
3155
|
+
await awaitLegacyMonacoLanguageContributionsIfPresent();
|
|
3156
|
+
const engine = await getLegacyShikiEngineIfPresent();
|
|
3157
|
+
if (engine) return createHighlighter({
|
|
3158
|
+
...options,
|
|
3159
|
+
engine
|
|
3160
|
+
});
|
|
3161
|
+
return createHighlighter(options);
|
|
3162
|
+
}
|
|
1990
3163
|
let languagesRegistered = false;
|
|
1991
3164
|
let currentLanguages = [];
|
|
1992
3165
|
let themeRegisterPromise = null;
|
|
@@ -2002,6 +3175,7 @@ function setThemeRegisterPromise(p) {
|
|
|
2002
3175
|
const highlighterCache = /* @__PURE__ */ new Map();
|
|
2003
3176
|
let monacoHighlighterPromise = null;
|
|
2004
3177
|
let lastPatchedHighlighter = null;
|
|
3178
|
+
let lastPatchedLanguages = /* @__PURE__ */ new Set();
|
|
2005
3179
|
const monacoThemeByKey = /* @__PURE__ */ new Map();
|
|
2006
3180
|
const monacoLanguageSet = /* @__PURE__ */ new Set();
|
|
2007
3181
|
function themeKey(t) {
|
|
@@ -2013,7 +3187,7 @@ async function ensureMonacoHighlighter(themes, languages$1) {
|
|
|
2013
3187
|
if (!monacoHighlighterPromise) {
|
|
2014
3188
|
const initialThemes = Array.from(monacoThemeByKey.values());
|
|
2015
3189
|
const initialLangs = Array.from(monacoLanguageSet.values());
|
|
2016
|
-
monacoHighlighterPromise =
|
|
3190
|
+
monacoHighlighterPromise = createHighlighterWithLegacyEngineIfNeeded({
|
|
2017
3191
|
themes: initialThemes,
|
|
2018
3192
|
langs: initialLangs
|
|
2019
3193
|
}).then((h$1) => h$1);
|
|
@@ -2041,7 +3215,7 @@ async function ensureMonacoHighlighter(themes, languages$1) {
|
|
|
2041
3215
|
}
|
|
2042
3216
|
return h;
|
|
2043
3217
|
}
|
|
2044
|
-
const p =
|
|
3218
|
+
const p = createHighlighterWithLegacyEngineIfNeeded({
|
|
2045
3219
|
themes: wantsThemes,
|
|
2046
3220
|
langs: wantsLangs
|
|
2047
3221
|
}).then((hh) => hh);
|
|
@@ -2085,7 +3259,7 @@ async function getOrCreateHighlighter(themes, languages$1) {
|
|
|
2085
3259
|
}
|
|
2086
3260
|
const union = new Set([...existing.languages, ...requestedSet]);
|
|
2087
3261
|
const langsArray = Array.from(union);
|
|
2088
|
-
const p$1 =
|
|
3262
|
+
const p$1 = createHighlighterWithLegacyEngineIfNeeded({
|
|
2089
3263
|
themes,
|
|
2090
3264
|
langs: langsArray
|
|
2091
3265
|
});
|
|
@@ -2099,7 +3273,7 @@ async function getOrCreateHighlighter(themes, languages$1) {
|
|
|
2099
3273
|
});
|
|
2100
3274
|
return p$1;
|
|
2101
3275
|
}
|
|
2102
|
-
const p =
|
|
3276
|
+
const p = createHighlighterWithLegacyEngineIfNeeded({
|
|
2103
3277
|
themes,
|
|
2104
3278
|
langs: Array.from(requestedSet)
|
|
2105
3279
|
});
|
|
@@ -2124,9 +3298,47 @@ async function registerMonacoThemes(themes, languages$1) {
|
|
|
2124
3298
|
registerMonacoLanguages(languages$1);
|
|
2125
3299
|
const p = (async () => {
|
|
2126
3300
|
const highlighter = await ensureMonacoHighlighter(themes, languages$1);
|
|
2127
|
-
|
|
2128
|
-
|
|
3301
|
+
const wantsLangs = Array.from(monacoLanguageSet.values());
|
|
3302
|
+
const needsLanguagePatch = lastPatchedHighlighter !== highlighter || wantsLangs.some((l) => !lastPatchedLanguages.has(l));
|
|
3303
|
+
if (needsLanguagePatch) {
|
|
3304
|
+
if (lastPatchedHighlighter !== highlighter) lastPatchedLanguages = /* @__PURE__ */ new Set();
|
|
3305
|
+
const realLanguages = monaco_shim_exports.languages;
|
|
3306
|
+
const realEditor = monaco_shim_exports.editor;
|
|
3307
|
+
const setTokensProvider = typeof (realLanguages === null || realLanguages === void 0 ? void 0 : realLanguages.setTokensProvider) === "function" ? realLanguages.setTokensProvider.bind(realLanguages) : null;
|
|
3308
|
+
const getLanguages = typeof (realLanguages === null || realLanguages === void 0 ? void 0 : realLanguages.getLanguages) === "function" ? realLanguages.getLanguages.bind(realLanguages) : null;
|
|
3309
|
+
const monacoProxy = {
|
|
3310
|
+
__proto__: monaco_shim_exports,
|
|
3311
|
+
editor: realEditor,
|
|
3312
|
+
languages: {
|
|
3313
|
+
__proto__: realLanguages,
|
|
3314
|
+
getLanguages,
|
|
3315
|
+
setTokensProvider(lang, provider) {
|
|
3316
|
+
if (provider && typeof provider.tokenize === "function") {
|
|
3317
|
+
const originalTokenize = provider.tokenize.bind(provider);
|
|
3318
|
+
provider = {
|
|
3319
|
+
...provider,
|
|
3320
|
+
tokenize(line, state) {
|
|
3321
|
+
try {
|
|
3322
|
+
return originalTokenize(line, state);
|
|
3323
|
+
} catch {
|
|
3324
|
+
return {
|
|
3325
|
+
endState: state,
|
|
3326
|
+
tokens: [{
|
|
3327
|
+
startIndex: 0,
|
|
3328
|
+
scopes: ""
|
|
3329
|
+
}]
|
|
3330
|
+
};
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
};
|
|
3334
|
+
}
|
|
3335
|
+
return setTokensProvider === null || setTokensProvider === void 0 ? void 0 : setTokensProvider(lang, provider);
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
};
|
|
3339
|
+
shikiToMonaco(highlighter, monacoProxy);
|
|
2129
3340
|
lastPatchedHighlighter = highlighter;
|
|
3341
|
+
lastPatchedLanguages = new Set(wantsLangs);
|
|
2130
3342
|
}
|
|
2131
3343
|
currentLanguages = languages$1.slice();
|
|
2132
3344
|
return highlighter;
|
|
@@ -2788,4 +4000,4 @@ const workerPathByLabel = {
|
|
|
2788
4000
|
const uniqueWorkerPaths = Array.from(new Set([editorWorkerPath, ...Object.values(workerPathByLabel)]));
|
|
2789
4001
|
|
|
2790
4002
|
//#endregion
|
|
2791
|
-
export { RevealStrategy, clearHighlighterCache, defaultRevealDebounceMs, detectLanguage, editorWorkerPath, getOrCreateHighlighter, registerMonacoThemes, uniqueWorkerPaths, useMonaco, workerPathByLabel };
|
|
4003
|
+
export { RevealStrategy, clearHighlighterCache, defaultRevealDebounceMs, detectLanguage, editorWorkerPath, getOrCreateHighlighter, monaco_shim_exports, processedLanguage, registerMonacoThemes, uniqueWorkerPaths, useMonaco, workerPathByLabel };
|