stream-monaco 0.0.21 → 0.0.22

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.
@@ -555,8 +555,14 @@ var DiffEditorManager = class DiffEditorManager {
555
555
  diffComputedVersions = null;
556
556
  preserveNativeDiffDecorationsOnStaleAppend = false;
557
557
  diffPresentationDisposables = [];
558
+ diffPresentationObserver = null;
558
559
  fallbackOriginalDecorationIds = [];
559
560
  fallbackModifiedDecorationIds = [];
561
+ fallbackInlineDeletedZoneIds = [];
562
+ fallbackInlineDeletedZoneSignature = null;
563
+ inlineDiffStreamingPresentationActive = false;
564
+ inlineDiffStreamingPresentationIdleTimer = null;
565
+ inlineDiffStreamingHeightFloor = 0;
560
566
  diffHunkHideTimer = null;
561
567
  diffUnchangedRegionDisposables = [];
562
568
  diffUnchangedRegionObserver = null;
@@ -569,9 +575,11 @@ var DiffEditorManager = class DiffEditorManager {
569
575
  diffUnchangedOverlayScrollLeft = 0;
570
576
  diffRootAppearanceSignature = null;
571
577
  diffPersistedUnchangedModelState = null;
578
+ diffPreviousUnchangedModelState = null;
572
579
  pendingPreparedDiffViewModel = null;
573
580
  cancelRafs() {
574
581
  this.rafScheduler.cancel("sync-diff-presentation");
582
+ this.rafScheduler.cancel("sync-diff-layout");
575
583
  this.rafScheduler.cancel("capture-diff-unchanged-state");
576
584
  this.rafScheduler.cancel("restore-diff-unchanged-state");
577
585
  this.rafScheduler.cancel("patch-diff-unchanged-regions");
@@ -658,6 +666,9 @@ var DiffEditorManager = class DiffEditorManager {
658
666
  revealLineCount: 5
659
667
  };
660
668
  }
669
+ resolveDiffGlyphMarginOption(hideUnchangedRegions = this.resolveDiffHideUnchangedRegionsOption()) {
670
+ return (hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled) ? true : this.options.glyphMargin;
671
+ }
661
672
  resolveDiffLineStyleOption() {
662
673
  return this.options.diffLineStyle === "bar" ? "bar" : "background";
663
674
  }
@@ -987,6 +998,220 @@ var DiffEditorManager = class DiffEditorManager {
987
998
  else this.fallbackOriginalDecorationIds = [];
988
999
  if (modifiedEditor && this.fallbackModifiedDecorationIds.length > 0) this.fallbackModifiedDecorationIds = modifiedEditor.deltaDecorations(this.fallbackModifiedDecorationIds, []);
989
1000
  else this.fallbackModifiedDecorationIds = [];
1001
+ this.clearFallbackInlineDeletedZones();
1002
+ }
1003
+ clearFallbackInlineDeletedZones() {
1004
+ var _this$diffEditorView13;
1005
+ const modifiedEditor = (_this$diffEditorView13 = this.diffEditorView) === null || _this$diffEditorView13 === void 0 ? void 0 : _this$diffEditorView13.getModifiedEditor();
1006
+ if (modifiedEditor && this.fallbackInlineDeletedZoneIds.length > 0) try {
1007
+ var _modifiedEditor$chang;
1008
+ (_modifiedEditor$chang = modifiedEditor.changeViewZones) === null || _modifiedEditor$chang === void 0 || _modifiedEditor$chang.call(modifiedEditor, (accessor) => {
1009
+ for (const id of this.fallbackInlineDeletedZoneIds) accessor.removeZone(id);
1010
+ });
1011
+ } catch {}
1012
+ this.fallbackInlineDeletedZoneIds = [];
1013
+ this.clearFallbackInlineDeletedZoneWrapperContent();
1014
+ this.fallbackInlineDeletedZoneSignature = null;
1015
+ }
1016
+ clearFallbackInlineDeletedZoneWrapperContent() {
1017
+ var _this$lastContainer, _this$lastContainer2, _node$parentElement;
1018
+ const querySelectorAll = typeof ((_this$lastContainer = this.lastContainer) === null || _this$lastContainer === void 0 ? void 0 : _this$lastContainer.querySelectorAll) === "function" ? (_this$lastContainer2 = this.lastContainer) === null || _this$lastContainer2 === void 0 ? void 0 : _this$lastContainer2.querySelectorAll.bind(this.lastContainer) : null;
1019
+ if (!querySelectorAll) return;
1020
+ const nodes = Array.from(querySelectorAll(".stream-monaco-fallback-inline-delete-zone[data-stream-monaco-native-wrapper=\"true\"], .stream-monaco-fallback-inline-delete-margin[data-stream-monaco-native-wrapper=\"true\"]") ?? []);
1021
+ for (const node of nodes) (_node$parentElement = node.parentElement) === null || _node$parentElement === void 0 || _node$parentElement.removeChild(node);
1022
+ }
1023
+ clearInlineDiffStreamingPresentationIdleTimer() {
1024
+ if (this.inlineDiffStreamingPresentationIdleTimer != null) {
1025
+ clearTimeout(this.inlineDiffStreamingPresentationIdleTimer);
1026
+ this.inlineDiffStreamingPresentationIdleTimer = null;
1027
+ }
1028
+ }
1029
+ resetInlineDiffStreamingHeightFloor() {
1030
+ this.inlineDiffStreamingHeightFloor = 0;
1031
+ }
1032
+ syncDiffEditorLayoutToContainer() {
1033
+ if (!this.diffEditorView || !this.lastContainer) return;
1034
+ const width = this.lastContainer.clientWidth || this.lastContainer.getBoundingClientRect().width;
1035
+ const height = this.lastContainer.clientHeight || this.lastContainer.getBoundingClientRect().height;
1036
+ if (!(width > 0) || !(height > 0)) return;
1037
+ try {
1038
+ var _layout, _ref;
1039
+ (_layout = (_ref = this.diffEditorView).layout) === null || _layout === void 0 || _layout.call(_ref, {
1040
+ width: Math.round(width),
1041
+ height: Math.round(height)
1042
+ });
1043
+ } catch {
1044
+ try {
1045
+ var _layout2, _ref2;
1046
+ (_layout2 = (_ref2 = this.diffEditorView).layout) === null || _layout2 === void 0 || _layout2.call(_ref2);
1047
+ } catch {}
1048
+ }
1049
+ }
1050
+ scheduleSyncDiffEditorLayoutToContainer() {
1051
+ this.rafScheduler.schedule("sync-diff-layout", () => {
1052
+ this.syncDiffEditorLayoutToContainer();
1053
+ });
1054
+ }
1055
+ readModelLineContent(model, lineNumber) {
1056
+ const direct = model.getLineContent;
1057
+ if (typeof direct === "function") return direct.call(model, lineNumber);
1058
+ return model.getValue().split(/\r?\n/)[lineNumber - 1] ?? "";
1059
+ }
1060
+ hasVisibleNativeInlineDeleteNodes() {
1061
+ if (!this.lastContainer) return false;
1062
+ const querySelectorAll = typeof this.lastContainer.querySelectorAll === "function" ? this.lastContainer.querySelectorAll.bind(this.lastContainer) : null;
1063
+ if (!querySelectorAll) return false;
1064
+ const nodes = Array.from(querySelectorAll(".editor.modified .view-zones .line-delete, .editor.modified .inline-deleted-text, .editor.modified .inline-deleted-margin-view-zone") ?? []);
1065
+ return nodes.some((node) => {
1066
+ var _node$getBoundingClie, _globalThis$getComput, _globalThis;
1067
+ if (!(node instanceof HTMLElement)) return false;
1068
+ const rect = (_node$getBoundingClie = node.getBoundingClientRect) === null || _node$getBoundingClie === void 0 ? void 0 : _node$getBoundingClie.call(node);
1069
+ const style = (_globalThis$getComput = (_globalThis = globalThis).getComputedStyle) === null || _globalThis$getComput === void 0 ? void 0 : _globalThis$getComput.call(_globalThis, node);
1070
+ return ((rect === null || rect === void 0 ? void 0 : rect.width) ?? 0) > 0 && ((rect === null || rect === void 0 ? void 0 : rect.height) ?? 0) > 0 && (style === null || style === void 0 ? void 0 : style.display) !== "none" && (style === null || style === void 0 ? void 0 : style.visibility) !== "hidden" && Number.parseFloat((style === null || style === void 0 ? void 0 : style.opacity) || "1") > .01;
1071
+ });
1072
+ }
1073
+ countNativeInlineDeleteZoneNodes() {
1074
+ if (!this.lastContainer) return 0;
1075
+ const querySelectorAll = typeof this.lastContainer.querySelectorAll === "function" ? this.lastContainer.querySelectorAll.bind(this.lastContainer) : null;
1076
+ if (!querySelectorAll) return 0;
1077
+ const nodes = Array.from(querySelectorAll(".editor.modified .view-zones [monaco-view-zone], .editor.modified .margin-view-zones [monaco-view-zone]") ?? []);
1078
+ return nodes.filter((node) => {
1079
+ if (!(node instanceof HTMLElement)) return false;
1080
+ return node.matches(".view-lines.line-delete") || !!node.querySelector(".view-lines.line-delete") || node.matches(".inline-deleted-margin-view-zone") || !!node.querySelector(".inline-deleted-margin-view-zone");
1081
+ }).length;
1082
+ }
1083
+ syncFallbackInlineDeletedZones(lineChanges) {
1084
+ var _modifiedEditor$getMo, _EditorOption, _modifiedEditor$getOp, _this$lastContainer3, _this$lastContainer3$, _this$lastContainer4, _this$lastContainer4$;
1085
+ if (typeof document === "undefined" || !this.diffEditorView || !this.originalModel || !this.isDiffInlineMode()) {
1086
+ this.clearFallbackInlineDeletedZones();
1087
+ return;
1088
+ }
1089
+ const modifiedEditor = this.diffEditorView.getModifiedEditor();
1090
+ const modifiedModel = modifiedEditor === null || modifiedEditor === void 0 || (_modifiedEditor$getMo = modifiedEditor.getModel) === null || _modifiedEditor$getMo === void 0 ? void 0 : _modifiedEditor$getMo.call(modifiedEditor);
1091
+ const originalModel = this.originalModel;
1092
+ if (!modifiedEditor || !modifiedModel || !originalModel) {
1093
+ this.fallbackInlineDeletedZoneIds = [];
1094
+ return;
1095
+ }
1096
+ const lineHeightOption = (_EditorOption = monaco_shim_exports.editor.EditorOption) === null || _EditorOption === void 0 ? void 0 : _EditorOption.lineHeight;
1097
+ const lineHeight = ((_modifiedEditor$getOp = modifiedEditor.getOption) === null || _modifiedEditor$getOp === void 0 ? void 0 : _modifiedEditor$getOp.call(modifiedEditor, lineHeightOption)) ?? 20;
1098
+ const relevantChanges = lineChanges.filter((change) => this.hasOriginalLines(change));
1099
+ const nativeViewWrappers = Array.from(((_this$lastContainer3 = this.lastContainer) === null || _this$lastContainer3 === void 0 || (_this$lastContainer3$ = _this$lastContainer3.querySelectorAll) === null || _this$lastContainer3$ === void 0 ? void 0 : _this$lastContainer3$.call(_this$lastContainer3, ".editor.modified .view-zones [monaco-view-zone]")) ?? []).filter((node) => {
1100
+ return node instanceof HTMLElement && !!node.querySelector(".view-lines.line-delete");
1101
+ });
1102
+ const nativeMarginWrappers = Array.from(((_this$lastContainer4 = this.lastContainer) === null || _this$lastContainer4 === void 0 || (_this$lastContainer4$ = _this$lastContainer4.querySelectorAll) === null || _this$lastContainer4$ === void 0 ? void 0 : _this$lastContainer4$.call(_this$lastContainer4, ".editor.modified .margin-view-zones [monaco-view-zone]")) ?? []).filter((node) => {
1103
+ return node instanceof HTMLElement && !!node.querySelector(".inline-deleted-margin-view-zone");
1104
+ });
1105
+ const nativePairs = nativeViewWrappers.map((viewWrapper) => {
1106
+ const id = viewWrapper.getAttribute("monaco-view-zone");
1107
+ if (!id) return null;
1108
+ const marginWrapper = nativeMarginWrappers.find((candidate) => candidate.getAttribute("monaco-view-zone") === id);
1109
+ return {
1110
+ id,
1111
+ top: Number.parseFloat(viewWrapper.style.top || "NaN"),
1112
+ viewWrapper,
1113
+ marginWrapper: marginWrapper ?? null
1114
+ };
1115
+ }).filter((entry) => !!entry && Number.isFinite(entry.top)).sort((left, right) => left.top - right.top);
1116
+ if (nativePairs.length >= relevantChanges.length && relevantChanges.length > 0) {
1117
+ const nextSignature$1 = nativePairs.slice(0, relevantChanges.length).map((pair, index) => {
1118
+ const change = relevantChanges[index];
1119
+ const text = Array.from({ length: change.originalEndLineNumber - change.originalStartLineNumber + 1 }, (_, offset) => this.readModelLineContent(originalModel, change.originalStartLineNumber + offset)).join("\n");
1120
+ return `${pair.id}:${text}`;
1121
+ }).join("|");
1122
+ if (nextSignature$1 && this.fallbackInlineDeletedZoneSignature === nextSignature$1 && this.fallbackInlineDeletedZoneIds.length === 0) return;
1123
+ if (this.fallbackInlineDeletedZoneIds.length > 0) {
1124
+ try {
1125
+ var _modifiedEditor$chang2;
1126
+ (_modifiedEditor$chang2 = modifiedEditor.changeViewZones) === null || _modifiedEditor$chang2 === void 0 || _modifiedEditor$chang2.call(modifiedEditor, (accessor) => {
1127
+ for (const id of this.fallbackInlineDeletedZoneIds) accessor.removeZone(id);
1128
+ });
1129
+ } catch {}
1130
+ this.fallbackInlineDeletedZoneIds = [];
1131
+ }
1132
+ this.clearFallbackInlineDeletedZoneWrapperContent();
1133
+ relevantChanges.forEach((change, index) => {
1134
+ var _modifiedEditor$apply;
1135
+ const pair = nativePairs[index];
1136
+ const domNode = document.createElement("div");
1137
+ domNode.className = "stream-monaco-fallback-inline-delete-zone";
1138
+ domNode.setAttribute("aria-hidden", "true");
1139
+ domNode.setAttribute("data-stream-monaco-native-wrapper", "true");
1140
+ (_modifiedEditor$apply = modifiedEditor.applyFontInfo) === null || _modifiedEditor$apply === void 0 || _modifiedEditor$apply.call(modifiedEditor, domNode);
1141
+ for (let line = change.originalStartLineNumber; line <= change.originalEndLineNumber; line++) {
1142
+ const lineNode = document.createElement("div");
1143
+ lineNode.className = "stream-monaco-fallback-inline-delete-line";
1144
+ lineNode.textContent = this.readModelLineContent(originalModel, line);
1145
+ lineNode.style.height = `${lineHeight}px`;
1146
+ lineNode.style.lineHeight = `${lineHeight}px`;
1147
+ domNode.append(lineNode);
1148
+ }
1149
+ pair.viewWrapper.append(domNode);
1150
+ if (pair.marginWrapper) {
1151
+ var _modifiedEditor$apply2;
1152
+ const marginDomNode = document.createElement("div");
1153
+ marginDomNode.className = "stream-monaco-fallback-inline-delete-margin";
1154
+ marginDomNode.setAttribute("aria-hidden", "true");
1155
+ marginDomNode.setAttribute("data-stream-monaco-native-wrapper", "true");
1156
+ marginDomNode.style.height = "100%";
1157
+ (_modifiedEditor$apply2 = modifiedEditor.applyFontInfo) === null || _modifiedEditor$apply2 === void 0 || _modifiedEditor$apply2.call(modifiedEditor, marginDomNode);
1158
+ pair.marginWrapper.append(marginDomNode);
1159
+ }
1160
+ });
1161
+ this.fallbackInlineDeletedZoneSignature = nextSignature$1 || null;
1162
+ return;
1163
+ }
1164
+ this.clearFallbackInlineDeletedZoneWrapperContent();
1165
+ const nextZones = relevantChanges.map((change) => {
1166
+ var _modifiedEditor$apply3, _modifiedEditor$apply4;
1167
+ const lineCount = change.originalEndLineNumber - change.originalStartLineNumber + 1;
1168
+ if (lineCount < 1) return null;
1169
+ const domNode = document.createElement("div");
1170
+ domNode.className = "stream-monaco-fallback-inline-delete-zone";
1171
+ domNode.setAttribute("aria-hidden", "true");
1172
+ (_modifiedEditor$apply3 = modifiedEditor.applyFontInfo) === null || _modifiedEditor$apply3 === void 0 || _modifiedEditor$apply3.call(modifiedEditor, domNode);
1173
+ for (let line = change.originalStartLineNumber; line <= change.originalEndLineNumber; line++) {
1174
+ const lineNode = document.createElement("div");
1175
+ lineNode.className = "stream-monaco-fallback-inline-delete-line";
1176
+ lineNode.textContent = this.readModelLineContent(originalModel, line);
1177
+ lineNode.style.height = `${lineHeight}px`;
1178
+ lineNode.style.lineHeight = `${lineHeight}px`;
1179
+ domNode.append(lineNode);
1180
+ }
1181
+ const marginDomNode = document.createElement("div");
1182
+ marginDomNode.className = "stream-monaco-fallback-inline-delete-margin";
1183
+ marginDomNode.setAttribute("aria-hidden", "true");
1184
+ (_modifiedEditor$apply4 = modifiedEditor.applyFontInfo) === null || _modifiedEditor$apply4 === void 0 || _modifiedEditor$apply4.call(modifiedEditor, marginDomNode);
1185
+ const anchorLine = Math.max(0, Math.min(modifiedModel.getLineCount(), (change.modifiedStartLineNumber || 1) - 1));
1186
+ return {
1187
+ afterLineNumber: anchorLine,
1188
+ heightInLines: lineCount,
1189
+ domNode,
1190
+ marginDomNode
1191
+ };
1192
+ }).filter(Boolean);
1193
+ const nextSignature = nextZones.map((zone) => {
1194
+ var _zone$domNode;
1195
+ const text = typeof ((_zone$domNode = zone.domNode) === null || _zone$domNode === void 0 ? void 0 : _zone$domNode.textContent) === "string" ? zone.domNode.textContent : "";
1196
+ return `${zone.afterLineNumber}:${zone.heightInLines}:${text}`;
1197
+ }).join("|");
1198
+ if (nextSignature && this.fallbackInlineDeletedZoneSignature === nextSignature && this.fallbackInlineDeletedZoneIds.length === nextZones.length) return;
1199
+ try {
1200
+ var _modifiedEditor$chang3;
1201
+ (_modifiedEditor$chang3 = modifiedEditor.changeViewZones) === null || _modifiedEditor$chang3 === void 0 || _modifiedEditor$chang3.call(modifiedEditor, (accessor) => {
1202
+ for (const id of this.fallbackInlineDeletedZoneIds) accessor.removeZone(id);
1203
+ this.fallbackInlineDeletedZoneIds = nextZones.map((zone) => accessor.addZone(zone));
1204
+ });
1205
+ this.fallbackInlineDeletedZoneSignature = nextSignature || null;
1206
+ } catch {
1207
+ this.fallbackInlineDeletedZoneIds = [];
1208
+ this.fallbackInlineDeletedZoneSignature = null;
1209
+ }
1210
+ try {
1211
+ var _modifiedEditor$layou, _render;
1212
+ (_modifiedEditor$layou = modifiedEditor.layout) === null || _modifiedEditor$layou === void 0 || _modifiedEditor$layou.call(modifiedEditor);
1213
+ (_render = modifiedEditor.render) === null || _render === void 0 || _render.call(modifiedEditor, true);
1214
+ } catch {}
990
1215
  }
991
1216
  toWholeLineDecoration(side, startLineNumber, endLineNumber) {
992
1217
  if (endLineNumber < startLineNumber || startLineNumber < 1) return null;
@@ -1004,26 +1229,45 @@ var DiffEditorManager = class DiffEditorManager {
1004
1229
  };
1005
1230
  }
1006
1231
  syncDiffPresentationDecorations() {
1007
- var _this$diffEditorView$3, _this$lastContainer$q, _this$lastContainer;
1232
+ var _this$diffEditorView$3, _this$lastContainer$q, _this$lastContainer5;
1008
1233
  if (!this.diffEditorView || !this.lastContainer) return;
1009
1234
  const nativeFresh = this.hasFreshNativeDiffResult();
1010
- const keepNativeDecorationsWhileStale = !nativeFresh && this.preserveNativeDiffDecorationsOnStaleAppend && ((((_this$diffEditorView$3 = this.diffEditorView.getLineChanges()) === null || _this$diffEditorView$3 === void 0 ? void 0 : _this$diffEditorView$3.length) ?? 0) > 0 || !!((_this$lastContainer$q = (_this$lastContainer = this.lastContainer).querySelector) === null || _this$lastContainer$q === void 0 ? void 0 : _this$lastContainer$q.call(_this$lastContainer, ".line-insert, .line-delete, .gutter-insert, .gutter-delete")));
1235
+ const useInlineMode = this.isDiffInlineMode();
1236
+ const lineChanges = this.getEffectiveLineChanges();
1237
+ const nativeInlineDeleteZoneCount = useInlineMode ? this.countNativeInlineDeleteZoneNodes() : 0;
1238
+ const hasNativeInlineDeleteZoneNodes = nativeInlineDeleteZoneCount > 0;
1239
+ const hasNativeInlineDeleteNodes = useInlineMode && this.hasVisibleNativeInlineDeleteNodes();
1240
+ const shouldKeepInlineFallback = useInlineMode && lineChanges.some((change) => this.hasOriginalLines(change)) && !hasNativeInlineDeleteZoneNodes;
1241
+ const useInlineStaleFallback = shouldKeepInlineFallback;
1242
+ this.lastContainer.classList.toggle("stream-monaco-diff-inline-native-ready", useInlineMode && !shouldKeepInlineFallback && (nativeFresh || hasNativeInlineDeleteNodes || hasNativeInlineDeleteZoneNodes));
1243
+ const keepNativeDecorationsWhileStale = !useInlineStaleFallback && !nativeFresh && this.preserveNativeDiffDecorationsOnStaleAppend && ((((_this$diffEditorView$3 = this.diffEditorView.getLineChanges()) === null || _this$diffEditorView$3 === void 0 ? void 0 : _this$diffEditorView$3.length) ?? 0) > 0 || !!((_this$lastContainer$q = (_this$lastContainer5 = this.lastContainer).querySelector) === null || _this$lastContainer$q === void 0 ? void 0 : _this$lastContainer$q.call(_this$lastContainer5, ".line-insert, .line-delete, .gutter-insert, .gutter-delete")));
1011
1244
  this.lastContainer.classList.toggle("stream-monaco-diff-native-stale", !nativeFresh && !keepNativeDecorationsWhileStale);
1012
- if (nativeFresh) {
1245
+ if (nativeFresh && !shouldKeepInlineFallback) {
1013
1246
  this.clearFallbackDiffDecorations();
1014
1247
  return;
1015
1248
  }
1016
1249
  const originalEditor = this.diffEditorView.getOriginalEditor();
1017
1250
  const modifiedEditor = this.diffEditorView.getModifiedEditor();
1018
- const lineChanges = this.getEffectiveLineChanges();
1019
1251
  const originalDecorations = lineChanges.map((change) => this.toWholeLineDecoration("original", change.originalStartLineNumber, change.originalEndLineNumber)).filter(Boolean);
1020
1252
  const modifiedDecorations = lineChanges.map((change) => this.toWholeLineDecoration("modified", change.modifiedStartLineNumber, change.modifiedEndLineNumber)).filter(Boolean);
1021
1253
  this.fallbackOriginalDecorationIds = originalEditor.deltaDecorations(this.fallbackOriginalDecorationIds, originalDecorations);
1022
1254
  this.fallbackModifiedDecorationIds = modifiedEditor.deltaDecorations(this.fallbackModifiedDecorationIds, modifiedDecorations);
1255
+ if (useInlineStaleFallback) this.syncFallbackInlineDeletedZones(lineChanges);
1256
+ else this.clearFallbackInlineDeletedZones();
1023
1257
  }
1024
1258
  disposeDiffPresentationTracking() {
1025
1259
  this.clearFallbackDiffDecorations();
1026
- if (this.lastContainer) this.lastContainer.classList.remove("stream-monaco-diff-native-stale");
1260
+ if (this.diffPresentationObserver) {
1261
+ this.diffPresentationObserver.disconnect();
1262
+ this.diffPresentationObserver = null;
1263
+ }
1264
+ this.clearInlineDiffStreamingPresentationIdleTimer();
1265
+ this.inlineDiffStreamingPresentationActive = false;
1266
+ this.resetInlineDiffStreamingHeightFloor();
1267
+ if (this.lastContainer) {
1268
+ this.lastContainer.classList.remove("stream-monaco-diff-native-stale");
1269
+ this.lastContainer.classList.remove("stream-monaco-diff-inline-native-ready");
1270
+ }
1027
1271
  this.diffComputedVersions = null;
1028
1272
  this.diffPresentationDisposables.forEach((disposable) => disposable.dispose());
1029
1273
  this.diffPresentationDisposables = [];
@@ -1374,6 +1618,31 @@ var DiffEditorManager = class DiffEditorManager {
1374
1618
  border: 0 !important;
1375
1619
  box-shadow: var(--stream-monaco-removed-line-shadow);
1376
1620
  }
1621
+ .stream-monaco-diff-root .monaco-editor .stream-monaco-fallback-inline-delete-zone {
1622
+ box-sizing: border-box;
1623
+ width: 100%;
1624
+ pointer-events: none;
1625
+ }
1626
+ .stream-monaco-diff-root .monaco-editor .stream-monaco-fallback-inline-delete-line {
1627
+ box-sizing: border-box;
1628
+ width: 100%;
1629
+ overflow: hidden;
1630
+ white-space: pre;
1631
+ color: inherit;
1632
+ background: var(--stream-monaco-removed-line-fill);
1633
+ box-shadow: var(--stream-monaco-removed-line-shadow);
1634
+ }
1635
+ .stream-monaco-diff-root .monaco-editor .stream-monaco-fallback-inline-delete-margin {
1636
+ box-sizing: border-box;
1637
+ width: 100%;
1638
+ background: var(--stream-monaco-removed-gutter);
1639
+ pointer-events: none;
1640
+ }
1641
+ .stream-monaco-diff-root.stream-monaco-diff-inline-native-ready .stream-monaco-fallback-inline-delete-zone,
1642
+ .stream-monaco-diff-root.stream-monaco-diff-inline-native-ready .stream-monaco-fallback-inline-delete-line,
1643
+ .stream-monaco-diff-root.stream-monaco-diff-inline-native-ready .stream-monaco-fallback-inline-delete-margin {
1644
+ display: none !important;
1645
+ }
1377
1646
  .stream-monaco-diff-root .monaco-editor .stream-monaco-fallback-gutter-insert,
1378
1647
  .stream-monaco-diff-root .monaco-diff-editor .stream-monaco-fallback-gutter-insert {
1379
1648
  background: var(--stream-monaco-added-gutter) !important;
@@ -1503,6 +1772,9 @@ var DiffEditorManager = class DiffEditorManager {
1503
1772
  }
1504
1773
  .stream-monaco-diff-root .monaco-diff-editor .editor.original .current-line {
1505
1774
  width: var(--stream-monaco-original-margin-width, auto) !important;
1775
+ display: none !important;
1776
+ opacity: 0 !important;
1777
+ pointer-events: none !important;
1506
1778
  }
1507
1779
  .stream-monaco-diff-root .monaco-diff-editor .editor.original .monaco-scrollable-element.editor-scrollable {
1508
1780
  left: var(--stream-monaco-original-scrollable-left, auto) !important;
@@ -1515,6 +1787,9 @@ var DiffEditorManager = class DiffEditorManager {
1515
1787
  }
1516
1788
  .stream-monaco-diff-root .monaco-diff-editor .editor.modified .current-line {
1517
1789
  width: var(--stream-monaco-modified-margin-width) !important;
1790
+ display: none !important;
1791
+ opacity: 0 !important;
1792
+ pointer-events: none !important;
1518
1793
  }
1519
1794
  .stream-monaco-diff-root .monaco-diff-editor .editor.modified .monaco-scrollable-element.editor-scrollable {
1520
1795
  left: var(--stream-monaco-modified-scrollable-left, var(--stream-monaco-modified-margin-width)) !important;
@@ -1545,15 +1820,39 @@ var DiffEditorManager = class DiffEditorManager {
1545
1820
  border: 0 !important;
1546
1821
  overflow: hidden !important;
1547
1822
  }
1823
+ .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .monaco-editor,
1824
+ .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .monaco-editor-background,
1825
+ .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .lines-content {
1826
+ width: 0 !important;
1827
+ min-width: 0 !important;
1828
+ background: transparent !important;
1829
+ opacity: 0 !important;
1830
+ pointer-events: none !important;
1831
+ }
1548
1832
  .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .monaco-scrollable-element.editor-scrollable {
1549
1833
  left: 0 !important;
1550
1834
  width: 0 !important;
1551
1835
  }
1836
+ .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .margin,
1837
+ .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .margin-view-overlays,
1838
+ .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .margin-view-zones,
1839
+ .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .overflow-guard {
1840
+ display: none !important;
1841
+ width: 0 !important;
1842
+ min-width: 0 !important;
1843
+ }
1552
1844
  .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.modified {
1553
1845
  left: 0 !important;
1554
1846
  width: 100% !important;
1555
1847
  border-left: 0 !important;
1556
1848
  }
1849
+ .stream-monaco-diff-root.stream-monaco-diff-inline.stream-monaco-diff-native-stale .monaco-diff-editor .editor.modified .view-lines.line-delete,
1850
+ .stream-monaco-diff-root.stream-monaco-diff-inline.stream-monaco-diff-native-stale .monaco-diff-editor .editor.modified .inline-deleted-margin-view-zone {
1851
+ display: none !important;
1852
+ height: 0 !important;
1853
+ min-height: 0 !important;
1854
+ overflow: hidden !important;
1855
+ }
1557
1856
  .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .gutter-delete,
1558
1857
  .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .gutter-insert,
1559
1858
  .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .line-delete,
@@ -2143,6 +2442,9 @@ var DiffEditorManager = class DiffEditorManager {
2143
2442
  opacity: 0.92 !important;
2144
2443
  transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.14s ease, opacity 0.14s ease, box-shadow 0.14s ease;
2145
2444
  }
2445
+ .stream-monaco-diff-root .monaco-editor .fold-unchanged.stream-monaco-fold-unchanged-hidden {
2446
+ display: none !important;
2447
+ }
2146
2448
  .stream-monaco-diff-root .monaco-editor .fold-unchanged:hover,
2147
2449
  .stream-monaco-diff-root .monaco-editor .fold-unchanged.stream-monaco-focus-visible {
2148
2450
  opacity: 1 !important;
@@ -2240,6 +2542,8 @@ var DiffEditorManager = class DiffEditorManager {
2240
2542
  }
2241
2543
  capturePersistedDiffUnchangedState() {
2242
2544
  if (!this.diffEditorView) return;
2545
+ const hideUnchangedRegions = this.diffHideUnchangedRegionsResolved ?? this.resolveDiffHideUnchangedRegionsOption();
2546
+ if (!(hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled) || this.diffHideUnchangedRegionsDeferred) return;
2243
2547
  const state = this.diffEditorView.saveViewState();
2244
2548
  if (!(state === null || state === void 0 ? void 0 : state.modelState)) {
2245
2549
  this.diffPersistedUnchangedModelState = null;
@@ -2247,6 +2551,14 @@ var DiffEditorManager = class DiffEditorManager {
2247
2551
  }
2248
2552
  this.diffPersistedUnchangedModelState = this.cloneSerializableValue(state.modelState);
2249
2553
  }
2554
+ capturePreviousDiffUnchangedState() {
2555
+ if (!this.diffEditorView) return;
2556
+ const hideUnchangedRegions = this.diffHideUnchangedRegionsResolved ?? this.resolveDiffHideUnchangedRegionsOption();
2557
+ if (!(hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled) || this.diffHideUnchangedRegionsDeferred) return;
2558
+ const state = this.diffEditorView.saveViewState();
2559
+ if (!(state === null || state === void 0 ? void 0 : state.modelState)) return;
2560
+ this.diffPreviousUnchangedModelState = this.cloneSerializableValue(state.modelState);
2561
+ }
2250
2562
  scheduleCapturePersistedDiffUnchangedState(frames = 1) {
2251
2563
  this.rafScheduler.schedule("capture-diff-unchanged-state", () => {
2252
2564
  let remaining = Math.max(0, frames);
@@ -2272,6 +2584,20 @@ var DiffEditorManager = class DiffEditorManager {
2272
2584
  });
2273
2585
  this.applyPendingDiffScrollRestore();
2274
2586
  }
2587
+ restorePreviousDiffUnchangedState() {
2588
+ if (!this.diffEditorView || !this.diffPreviousUnchangedModelState) return false;
2589
+ const current = this.diffEditorView.saveViewState();
2590
+ if (!current) return false;
2591
+ const previous = this.cloneSerializableValue(this.diffPreviousUnchangedModelState);
2592
+ this.diffEditorView.restoreViewState({
2593
+ original: current.original,
2594
+ modified: current.modified,
2595
+ modelState: previous
2596
+ });
2597
+ this.diffPersistedUnchangedModelState = this.cloneSerializableValue(previous);
2598
+ this.applyPendingDiffScrollRestore();
2599
+ return true;
2600
+ }
2275
2601
  scheduleRestorePersistedDiffUnchangedState() {
2276
2602
  if (this.diffHideUnchangedRegionsDeferred) return;
2277
2603
  if (!this.diffPersistedUnchangedModelState) return;
@@ -2435,7 +2761,7 @@ var DiffEditorManager = class DiffEditorManager {
2435
2761
  readOnly: this.options.readOnly ?? true,
2436
2762
  lineDecorationsWidth: this.options.lineDecorationsWidth,
2437
2763
  lineNumbersMinChars: this.options.lineNumbersMinChars,
2438
- glyphMargin: this.options.glyphMargin,
2764
+ glyphMargin: this.resolveDiffGlyphMarginOption(hideUnchangedRegions),
2439
2765
  fontFamily: this.options.fontFamily,
2440
2766
  fontSize: this.options.fontSize,
2441
2767
  lineHeight: this.options.lineHeight,
@@ -2455,9 +2781,10 @@ var DiffEditorManager = class DiffEditorManager {
2455
2781
  };
2456
2782
  }
2457
2783
  refreshDiffPresentation() {
2458
- var _this$diffHeightManag;
2784
+ var _this$diffHideUnchang, _this$diffHeightManag;
2459
2785
  if (!this.diffEditorView) return;
2460
2786
  const hideUnchangedRegions = this.resolveDiffHideUnchangedRegionsOption();
2787
+ const shouldRecomputeDiffViewModelForUnchangedRegions = !this.diffHideUnchangedRegionsDeferred && (hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled) === true && ((_this$diffHideUnchang = this.diffHideUnchangedRegionsResolved) === null || _this$diffHideUnchang === void 0 ? void 0 : _this$diffHideUnchang.enabled) === false && !!this.originalModel && !!this.modifiedModel;
2461
2788
  const presentationOptions = this.resolveDiffPresentationEditorOptions(hideUnchangedRegions);
2462
2789
  this.diffHideUnchangedRegionsResolved = hideUnchangedRegions;
2463
2790
  this.diffUpdateThrottleMs = this.resolveDiffStreamingThrottleMs();
@@ -2467,13 +2794,20 @@ var DiffEditorManager = class DiffEditorManager {
2467
2794
  this.lastContainer.style.removeProperty("--stream-monaco-editor-fg");
2468
2795
  }
2469
2796
  this.withLockedDiffScrollPosition(() => {
2470
- var _this$diffEditorView13;
2471
- (_this$diffEditorView13 = this.diffEditorView) === null || _this$diffEditorView13 === void 0 || _this$diffEditorView13.updateOptions(presentationOptions);
2797
+ var _this$diffEditorView14;
2798
+ (_this$diffEditorView14 = this.diffEditorView) === null || _this$diffEditorView14 === void 0 || _this$diffEditorView14.updateOptions(presentationOptions);
2472
2799
  });
2473
2800
  (_this$diffHeightManag = this.diffHeightManager) === null || _this$diffHeightManag === void 0 || _this$diffHeightManag.update();
2474
2801
  this.applyDiffRootAppearanceClass();
2475
2802
  this.schedulePatchDiffUnchangedRegionsAfterInteraction(1);
2476
2803
  this.repositionDiffHunkNodes();
2804
+ if (shouldRecomputeDiffViewModelForUnchangedRegions) this.setDiffModels({
2805
+ original: this.originalModel,
2806
+ modified: this.modifiedModel
2807
+ }, {
2808
+ preserveViewState: true,
2809
+ preserveModelState: false
2810
+ });
2477
2811
  }
2478
2812
  restoreDeferredDiffUnchangedRegions() {
2479
2813
  this.clearDeferredDiffUnchangedRegionsIdleTimer();
@@ -2483,8 +2817,8 @@ var DiffEditorManager = class DiffEditorManager {
2483
2817
  if (!this.diffHideUnchangedRegionsDeferred) return;
2484
2818
  this.diffHideUnchangedRegionsDeferred = false;
2485
2819
  this.withLockedDiffScrollPosition(() => {
2486
- var _this$diffEditorView14;
2487
- (_this$diffEditorView14 = this.diffEditorView) === null || _this$diffEditorView14 === void 0 || _this$diffEditorView14.updateOptions({ hideUnchangedRegions });
2820
+ var _this$diffEditorView15;
2821
+ (_this$diffEditorView15 = this.diffEditorView) === null || _this$diffEditorView15 === void 0 || _this$diffEditorView15.updateOptions({ hideUnchangedRegions });
2488
2822
  });
2489
2823
  this.schedulePatchDiffUnchangedRegionsAfterInteraction(1);
2490
2824
  if (this.shouldAutoScrollDiff) {
@@ -2493,6 +2827,22 @@ var DiffEditorManager = class DiffEditorManager {
2493
2827
  }
2494
2828
  }
2495
2829
  markDiffStreamingActivity() {
2830
+ var _this$lastContainer6;
2831
+ (_this$lastContainer6 = this.lastContainer) === null || _this$lastContainer6 === void 0 || _this$lastContainer6.classList.remove("stream-monaco-diff-inline-native-ready");
2832
+ if (this.isDiffInlineMode()) {
2833
+ var _this$diffHeightManag2, _this$lastContainer7, _this$lastContainer7$;
2834
+ this.inlineDiffStreamingPresentationActive = true;
2835
+ this.inlineDiffStreamingHeightFloor = Math.max(this.inlineDiffStreamingHeightFloor, ((_this$diffHeightManag2 = this.diffHeightManager) === null || _this$diffHeightManag2 === void 0 ? void 0 : _this$diffHeightManag2.getLastApplied()) ?? 0, ((_this$lastContainer7 = this.lastContainer) === null || _this$lastContainer7 === void 0 || (_this$lastContainer7$ = _this$lastContainer7.getBoundingClientRect) === null || _this$lastContainer7$ === void 0 ? void 0 : _this$lastContainer7$.call(_this$lastContainer7).height) ?? 0);
2836
+ this.clearInlineDiffStreamingPresentationIdleTimer();
2837
+ this.inlineDiffStreamingPresentationIdleTimer = setTimeout(() => {
2838
+ var _this$diffHeightManag3;
2839
+ this.inlineDiffStreamingPresentationIdleTimer = null;
2840
+ this.inlineDiffStreamingPresentationActive = false;
2841
+ this.resetInlineDiffStreamingHeightFloor();
2842
+ this.scheduleSyncDiffPresentationDecorations();
2843
+ (_this$diffHeightManag3 = this.diffHeightManager) === null || _this$diffHeightManag3 === void 0 || _this$diffHeightManag3.update();
2844
+ }, 3e3);
2845
+ }
2496
2846
  const hideUnchangedRegions = this.diffHideUnchangedRegionsResolved;
2497
2847
  if (!this.diffEditorView || !(hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled)) return;
2498
2848
  this.clearDeferredDiffUnchangedRegionsIdleTimer();
@@ -2504,8 +2854,8 @@ var DiffEditorManager = class DiffEditorManager {
2504
2854
  this.diffHideUnchangedRegionsDeferred = true;
2505
2855
  this.hideAllDiffUnchangedBridgeEntries();
2506
2856
  this.withLockedDiffScrollPosition(() => {
2507
- var _this$diffEditorView15;
2508
- (_this$diffEditorView15 = this.diffEditorView) === null || _this$diffEditorView15 === void 0 || _this$diffEditorView15.updateOptions({ hideUnchangedRegions: {
2857
+ var _this$diffEditorView16;
2858
+ (_this$diffEditorView16 = this.diffEditorView) === null || _this$diffEditorView16 === void 0 || _this$diffEditorView16.updateOptions({ hideUnchangedRegions: {
2509
2859
  ...hideUnchangedRegions,
2510
2860
  enabled: false
2511
2861
  } });
@@ -2603,8 +2953,8 @@ var DiffEditorManager = class DiffEditorManager {
2603
2953
  return this.diffUnchangedBridgeOverlay;
2604
2954
  }
2605
2955
  readDiffUnchangedOverlayScrollState() {
2606
- var _this$diffEditorView16, _modifiedEditor$getSc6, _modifiedEditor$getSc7;
2607
- const modifiedEditor = (_this$diffEditorView16 = this.diffEditorView) === null || _this$diffEditorView16 === void 0 ? void 0 : _this$diffEditorView16.getModifiedEditor();
2956
+ var _this$diffEditorView17, _modifiedEditor$getSc6, _modifiedEditor$getSc7;
2957
+ const modifiedEditor = (_this$diffEditorView17 = this.diffEditorView) === null || _this$diffEditorView17 === void 0 ? void 0 : _this$diffEditorView17.getModifiedEditor();
2608
2958
  return {
2609
2959
  top: (modifiedEditor === null || modifiedEditor === void 0 || (_modifiedEditor$getSc6 = modifiedEditor.getScrollTop) === null || _modifiedEditor$getSc6 === void 0 ? void 0 : _modifiedEditor$getSc6.call(modifiedEditor)) ?? 0,
2610
2960
  left: (modifiedEditor === null || modifiedEditor === void 0 || (_modifiedEditor$getSc7 = modifiedEditor.getScrollLeft) === null || _modifiedEditor$getSc7 === void 0 ? void 0 : _modifiedEditor$getSc7.call(modifiedEditor)) ?? 0
@@ -2961,7 +3311,7 @@ var DiffEditorManager = class DiffEditorManager {
2961
3311
  this.scheduleCapturePersistedDiffUnchangedState(1);
2962
3312
  }
2963
3313
  resolveDiffUnchangedRevealLayout(primaryNode, countText, pairIndex, pairCount) {
2964
- var _this$diffEditorView17, _this$diffEditorView18;
3314
+ var _this$diffEditorView18, _this$diffEditorView19;
2965
3315
  let showTopHandle = pairCount === 1 || pairIndex > 0;
2966
3316
  let showBottomHandle = pairCount === 1 || pairIndex < pairCount - 1;
2967
3317
  const countMatch = countText.match(/\d+/);
@@ -2991,7 +3341,7 @@ var DiffEditorManager = class DiffEditorManager {
2991
3341
  showTopHandle = false;
2992
3342
  showBottomHandle = true;
2993
3343
  }
2994
- const modelLineCount = ((_this$diffEditorView17 = this.diffEditorView) === null || _this$diffEditorView17 === void 0 || (_this$diffEditorView17 = _this$diffEditorView17.getModifiedEditor().getModel()) === null || _this$diffEditorView17 === void 0 || (_this$diffEditorView18 = _this$diffEditorView17.getLineCount) === null || _this$diffEditorView18 === void 0 ? void 0 : _this$diffEditorView18.call(_this$diffEditorView17)) ?? null;
3344
+ const modelLineCount = ((_this$diffEditorView18 = this.diffEditorView) === null || _this$diffEditorView18 === void 0 || (_this$diffEditorView18 = _this$diffEditorView18.getModifiedEditor().getModel()) === null || _this$diffEditorView18 === void 0 || (_this$diffEditorView19 = _this$diffEditorView18.getLineCount) === null || _this$diffEditorView19 === void 0 ? void 0 : _this$diffEditorView19.call(_this$diffEditorView18)) ?? null;
2995
3345
  if (previousVisibleLine != null && modelLineCount != null && previousVisibleLine + hiddenCount === modelLineCount) {
2996
3346
  showTopHandle = true;
2997
3347
  showBottomHandle = false;
@@ -3002,13 +3352,13 @@ var DiffEditorManager = class DiffEditorManager {
3002
3352
  };
3003
3353
  }
3004
3354
  resolveDiffUnchangedMergeRole(node) {
3005
- var _this$diffEditorView19, _this$diffEditorView20, _this$diffEditorView21, _this$diffEditorView22, _this$diffEditorView23, _this$diffEditorView24;
3355
+ var _this$diffEditorView20, _this$diffEditorView21, _this$diffEditorView22, _this$diffEditorView23, _this$diffEditorView24, _this$diffEditorView25;
3006
3356
  const diffRoot = node.closest(".monaco-diff-editor.side-by-side");
3007
3357
  if (!(diffRoot instanceof HTMLElement)) return "none";
3008
3358
  const nodeRect = node.getBoundingClientRect();
3009
3359
  const nodeCenter = nodeRect.left + nodeRect.width / 2;
3010
- const originalHost = (_this$diffEditorView19 = this.diffEditorView) === null || _this$diffEditorView19 === void 0 || (_this$diffEditorView21 = (_this$diffEditorView20 = _this$diffEditorView19.getOriginalEditor()).getContainerDomNode) === null || _this$diffEditorView21 === void 0 ? void 0 : _this$diffEditorView21.call(_this$diffEditorView20);
3011
- const modifiedHost = (_this$diffEditorView22 = this.diffEditorView) === null || _this$diffEditorView22 === void 0 || (_this$diffEditorView24 = (_this$diffEditorView23 = _this$diffEditorView22.getModifiedEditor()).getContainerDomNode) === null || _this$diffEditorView24 === void 0 ? void 0 : _this$diffEditorView24.call(_this$diffEditorView23);
3360
+ const originalHost = (_this$diffEditorView20 = this.diffEditorView) === null || _this$diffEditorView20 === void 0 || (_this$diffEditorView22 = (_this$diffEditorView21 = _this$diffEditorView20.getOriginalEditor()).getContainerDomNode) === null || _this$diffEditorView22 === void 0 ? void 0 : _this$diffEditorView22.call(_this$diffEditorView21);
3361
+ const modifiedHost = (_this$diffEditorView23 = this.diffEditorView) === null || _this$diffEditorView23 === void 0 || (_this$diffEditorView25 = (_this$diffEditorView24 = _this$diffEditorView23.getModifiedEditor()).getContainerDomNode) === null || _this$diffEditorView25 === void 0 ? void 0 : _this$diffEditorView25.call(_this$diffEditorView24);
3012
3362
  if (originalHost instanceof HTMLElement && modifiedHost instanceof HTMLElement) {
3013
3363
  const originalRect = originalHost.getBoundingClientRect();
3014
3364
  const modifiedRect = modifiedHost.getBoundingClientRect();
@@ -3048,6 +3398,11 @@ var DiffEditorManager = class DiffEditorManager {
3048
3398
  action.tabIndex = shouldUseMergedSecondary ? -1 : 0;
3049
3399
  if (action.dataset.streamMonacoExpandPatched !== "true") {
3050
3400
  action.dataset.streamMonacoExpandPatched = "true";
3401
+ const handleCaptureExpand = () => {
3402
+ this.capturePreviousDiffUnchangedState();
3403
+ };
3404
+ action.addEventListener("click", handleCaptureExpand, { capture: true });
3405
+ this.diffUnchangedRegionDisposables.push({ dispose: () => action.removeEventListener("click", handleCaptureExpand, true) });
3051
3406
  this.createDomDisposable(this.diffUnchangedRegionDisposables, action, "click", () => {
3052
3407
  this.hideAllDiffUnchangedBridgeEntries();
3053
3408
  this.scheduleCapturePersistedDiffUnchangedState(1);
@@ -3060,7 +3415,10 @@ var DiffEditorManager = class DiffEditorManager {
3060
3415
  this.bindFocusWithinClass(this.diffUnchangedRegionDisposables, node, "stream-monaco-focus-within");
3061
3416
  const activate = () => {
3062
3417
  const action$1 = node.querySelector("a");
3063
- if (action$1 instanceof HTMLElement) action$1.click();
3418
+ if (action$1 instanceof HTMLElement) {
3419
+ this.capturePreviousDiffUnchangedState();
3420
+ action$1.click();
3421
+ }
3064
3422
  };
3065
3423
  this.createDomDisposable(this.diffUnchangedRegionDisposables, node, "click", (event) => {
3066
3424
  const mouseEvent = event;
@@ -3154,6 +3512,7 @@ var DiffEditorManager = class DiffEditorManager {
3154
3512
  entry.activate = () => {
3155
3513
  const action = primaryNode.querySelector("a, button") ?? secondaryNode.querySelector("a, button");
3156
3514
  if (action instanceof HTMLElement) {
3515
+ this.capturePreviousDiffUnchangedState();
3157
3516
  action.click();
3158
3517
  this.scheduleCapturePersistedDiffUnchangedState(1);
3159
3518
  }
@@ -3172,10 +3531,22 @@ var DiffEditorManager = class DiffEditorManager {
3172
3531
  node.title = node.title || "Collapse unchanged lines";
3173
3532
  this.bindFocusVisibleClass(this.diffUnchangedRegionDisposables, node);
3174
3533
  this.bindPersistOnMouseRelease(this.diffUnchangedRegionDisposables, node);
3534
+ this.createDomDisposable(this.diffUnchangedRegionDisposables, node, "mouseup", (event) => {
3535
+ const mouseEvent = event;
3536
+ if (mouseEvent.button !== 0) return;
3537
+ if (!this.restorePreviousDiffUnchangedState()) return;
3538
+ event.preventDefault();
3539
+ event.stopPropagation();
3540
+ this.schedulePatchDiffUnchangedRegionsAfterInteraction();
3541
+ });
3175
3542
  this.createDomDisposable(this.diffUnchangedRegionDisposables, node, "keydown", (event) => {
3176
3543
  const keyboardEvent = event;
3177
3544
  if (keyboardEvent.key !== "Enter" && keyboardEvent.key !== " ") return;
3178
3545
  keyboardEvent.preventDefault();
3546
+ if (this.restorePreviousDiffUnchangedState()) {
3547
+ this.schedulePatchDiffUnchangedRegionsAfterInteraction();
3548
+ return;
3549
+ }
3179
3550
  this.dispatchSyntheticMouseDown(node);
3180
3551
  this.scheduleCapturePersistedDiffUnchangedState(1);
3181
3552
  });
@@ -3185,6 +3556,11 @@ var DiffEditorManager = class DiffEditorManager {
3185
3556
  this.applyDiffRootAppearanceClass();
3186
3557
  const viewZoneHeightsChanged = this.syncDiffUnchangedViewZoneHeights();
3187
3558
  const centers = this.lastContainer.querySelectorAll(".diff-hidden-lines .center");
3559
+ const modifiedHiddenSummaryMidpoints = Array.from(this.lastContainer.querySelectorAll(".editor.modified .diff-hidden-lines .center")).map((node) => {
3560
+ const rect = node.getBoundingClientRect();
3561
+ if (rect.width <= 0 || rect.height <= 0) return null;
3562
+ return rect.top + rect.height / 2;
3563
+ }).filter((value) => value !== null);
3188
3564
  Array.from(centers).sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top).forEach((node, index) => this.patchDiffUnchangedCenter(node, index));
3189
3565
  const partialRevealHandles = this.lastContainer.querySelectorAll(".diff-hidden-lines .top, .diff-hidden-lines .bottom");
3190
3566
  partialRevealHandles.forEach((node) => {
@@ -3209,7 +3585,13 @@ var DiffEditorManager = class DiffEditorManager {
3209
3585
  this.pruneDiffUnchangedBridgeEntries(visibleKeys);
3210
3586
  this.syncDiffUnchangedOverlayScrollBaseline();
3211
3587
  const foldGlyphs = this.lastContainer.querySelectorAll(".fold-unchanged");
3212
- foldGlyphs.forEach((node) => this.patchDiffUnchangedFoldGlyph(node));
3588
+ foldGlyphs.forEach((node) => {
3589
+ const rect = node.getBoundingClientRect();
3590
+ const midpoint = rect.top + rect.height / 2;
3591
+ const overlapsHiddenSummary = modifiedHiddenSummaryMidpoints.some((summaryMidpoint) => Math.abs(summaryMidpoint - midpoint) <= 8);
3592
+ node.classList.toggle("stream-monaco-fold-unchanged-hidden", overlapsHiddenSummary);
3593
+ this.patchDiffUnchangedFoldGlyph(node);
3594
+ });
3213
3595
  if (viewZoneHeightsChanged) this.schedulePatchDiffUnchangedRegions();
3214
3596
  }
3215
3597
  schedulePatchDiffUnchangedRegions() {
@@ -3222,12 +3604,12 @@ var DiffEditorManager = class DiffEditorManager {
3222
3604
  this.schedulePatchDiffUnchangedRegions();
3223
3605
  }
3224
3606
  setupDiffUnchangedRegionEnhancements() {
3225
- var _globalThis$getComput, _globalThis;
3607
+ var _globalThis$getComput2, _globalThis2;
3226
3608
  this.disposeDiffUnchangedRegionEnhancements();
3227
3609
  if (!this.diffEditorView || !this.lastContainer) return;
3228
3610
  if (typeof document === "undefined") return;
3229
3611
  this.ensureDiffUiStyle();
3230
- const containerStyle = (_globalThis$getComput = (_globalThis = globalThis).getComputedStyle) === null || _globalThis$getComput === void 0 ? void 0 : _globalThis$getComput.call(_globalThis, this.lastContainer);
3612
+ const containerStyle = (_globalThis$getComput2 = (_globalThis2 = globalThis).getComputedStyle) === null || _globalThis$getComput2 === void 0 ? void 0 : _globalThis$getComput2.call(_globalThis2, this.lastContainer);
3231
3613
  if (!containerStyle || containerStyle.position === "static") this.lastContainer.style.position = "relative";
3232
3614
  this.applyDiffRootAppearanceClass();
3233
3615
  this.schedulePatchDiffUnchangedRegions();
@@ -3255,6 +3637,20 @@ var DiffEditorManager = class DiffEditorManager {
3255
3637
  this.applyDiffRootAppearanceClass();
3256
3638
  this.schedulePatchDiffUnchangedRegions();
3257
3639
  };
3640
+ const handleFoldMouseUp = (event) => {
3641
+ var _event$event, _event$target, _event$event2, _event$event2$prevent, _event$event3, _event$event3$stopPro;
3642
+ if (event === null || event === void 0 || (_event$event = event.event) === null || _event$event === void 0 ? void 0 : _event$event.rightButton) return;
3643
+ const targetElement = event === null || event === void 0 || (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.element;
3644
+ const className = typeof (targetElement === null || targetElement === void 0 ? void 0 : targetElement.className) === "string" ? targetElement.className : "";
3645
+ if (!className.includes("fold-unchanged")) return;
3646
+ if (!this.diffPreviousUnchangedModelState) return;
3647
+ event === null || event === void 0 || (_event$event2 = event.event) === null || _event$event2 === void 0 || (_event$event2$prevent = _event$event2.preventDefault) === null || _event$event2$prevent === void 0 || _event$event2$prevent.call(_event$event2);
3648
+ event === null || event === void 0 || (_event$event3 = event.event) === null || _event$event3 === void 0 || (_event$event3$stopPro = _event$event3.stopPropagation) === null || _event$event3$stopPro === void 0 || _event$event3$stopPro.call(_event$event3);
3649
+ requestAnimationFrame(() => {
3650
+ if (!this.restorePreviousDiffUnchangedState()) return;
3651
+ this.schedulePatchDiffUnchangedRegionsAfterInteraction();
3652
+ });
3653
+ };
3258
3654
  this.diffUnchangedRegionDisposables.push(this.diffEditorView.onDidUpdateDiff(() => {
3259
3655
  repatch();
3260
3656
  this.scheduleRestorePersistedDiffUnchangedState();
@@ -3263,16 +3659,18 @@ var DiffEditorManager = class DiffEditorManager {
3263
3659
  this.diffUnchangedRegionDisposables.push(modifiedEditor.onDidLayoutChange(repatch));
3264
3660
  this.diffUnchangedRegionDisposables.push(originalEditor.onDidScrollChange(() => this.schedulePatchDiffUnchangedRegionsAfterScroll()));
3265
3661
  this.diffUnchangedRegionDisposables.push(modifiedEditor.onDidScrollChange(() => this.schedulePatchDiffUnchangedRegionsAfterScroll()));
3662
+ this.diffUnchangedRegionDisposables.push(originalEditor.onMouseUp(handleFoldMouseUp));
3663
+ this.diffUnchangedRegionDisposables.push(modifiedEditor.onMouseUp(handleFoldMouseUp));
3266
3664
  this.createDomDisposable(this.diffUnchangedRegionDisposables, this.lastContainer, "scroll", () => this.schedulePatchDiffUnchangedRegionsAfterScroll());
3267
3665
  }
3268
3666
  setupDiffHunkInteractions() {
3269
- var _globalThis$getComput2, _globalThis2;
3667
+ var _globalThis$getComput3, _globalThis3;
3270
3668
  this.disposeDiffHunkInteractions();
3271
3669
  if (!this.diffEditorView || !this.lastContainer) return;
3272
3670
  if (this.options.diffHunkActionsOnHover !== true) return;
3273
3671
  if (typeof document === "undefined") return;
3274
3672
  this.ensureDiffUiStyle();
3275
- const containerStyle = (_globalThis$getComput2 = (_globalThis2 = globalThis).getComputedStyle) === null || _globalThis$getComput2 === void 0 ? void 0 : _globalThis$getComput2.call(_globalThis2, this.lastContainer);
3673
+ const containerStyle = (_globalThis$getComput3 = (_globalThis3 = globalThis).getComputedStyle) === null || _globalThis$getComput3 === void 0 ? void 0 : _globalThis$getComput3.call(_globalThis3, this.lastContainer);
3276
3674
  if (!containerStyle || containerStyle.position === "static") this.lastContainer.style.position = "relative";
3277
3675
  const overlay = document.createElement("div");
3278
3676
  overlay.className = "stream-monaco-diff-hunk-overlay";
@@ -3390,9 +3788,9 @@ var DiffEditorManager = class DiffEditorManager {
3390
3788
  return !info || info.width < 24;
3391
3789
  }
3392
3790
  isDiffInlineMode() {
3393
- var _this$lastContainer2;
3394
- const diffRoot = (_this$lastContainer2 = this.lastContainer) === null || _this$lastContainer2 === void 0 ? void 0 : _this$lastContainer2.querySelector(".monaco-diff-editor");
3395
- if (diffRoot instanceof HTMLElement) return !diffRoot.classList.contains("side-by-side");
3791
+ var _this$lastContainer8, _this$lastContainer9;
3792
+ const diffRoot = typeof ((_this$lastContainer8 = this.lastContainer) === null || _this$lastContainer8 === void 0 ? void 0 : _this$lastContainer8.querySelector) === "function" ? (_this$lastContainer9 = this.lastContainer) === null || _this$lastContainer9 === void 0 ? void 0 : _this$lastContainer9.querySelector(".monaco-diff-editor") : null;
3793
+ if (typeof HTMLElement !== "undefined" && diffRoot instanceof HTMLElement) return !diffRoot.classList.contains("side-by-side");
3396
3794
  return this.isOriginalEditorCollapsed();
3397
3795
  }
3398
3796
  getEditorBySide(side) {
@@ -3440,8 +3838,8 @@ var DiffEditorManager = class DiffEditorManager {
3440
3838
  if (!this.diffEditorView || !viewState) return;
3441
3839
  const restore = () => {
3442
3840
  try {
3443
- var _this$diffEditorView25;
3444
- (_this$diffEditorView25 = this.diffEditorView) === null || _this$diffEditorView25 === void 0 || _this$diffEditorView25.restoreViewState(viewState);
3841
+ var _this$diffEditorView26;
3842
+ (_this$diffEditorView26 = this.diffEditorView) === null || _this$diffEditorView26 === void 0 || _this$diffEditorView26.restoreViewState(viewState);
3445
3843
  } catch {}
3446
3844
  };
3447
3845
  restore();
@@ -3459,7 +3857,7 @@ var DiffEditorManager = class DiffEditorManager {
3459
3857
  this.pendingPreparedDiffViewModel = null;
3460
3858
  }
3461
3859
  syncDiffKnownValues() {
3462
- var _this$diffEditorView26, _this$diffEditorView27, _this$diffEditorView28, _this$diffHeightManag2;
3860
+ var _this$diffEditorView27, _this$diffEditorView28, _this$diffEditorView29, _this$diffHeightManag4;
3463
3861
  if (this.originalModel) this.lastKnownOriginalCode = this.originalModel.getValue();
3464
3862
  if (this.modifiedModel) {
3465
3863
  this.lastKnownModifiedCode = this.modifiedModel.getValue();
@@ -3468,8 +3866,8 @@ var DiffEditorManager = class DiffEditorManager {
3468
3866
  this.lastKnownModifiedDirty = false;
3469
3867
  this._hasScrollBar = false;
3470
3868
  this.cachedComputedHeightDiff = this.computedHeight();
3471
- this.cachedScrollHeightDiff = ((_this$diffEditorView26 = this.diffEditorView) === null || _this$diffEditorView26 === void 0 || (_this$diffEditorView28 = (_this$diffEditorView27 = _this$diffEditorView26.getModifiedEditor()).getScrollHeight) === null || _this$diffEditorView28 === void 0 ? void 0 : _this$diffEditorView28.call(_this$diffEditorView27)) ?? this.cachedScrollHeightDiff;
3472
- (_this$diffHeightManag2 = this.diffHeightManager) === null || _this$diffHeightManag2 === void 0 || _this$diffHeightManag2.update();
3869
+ this.cachedScrollHeightDiff = ((_this$diffEditorView27 = this.diffEditorView) === null || _this$diffEditorView27 === void 0 || (_this$diffEditorView29 = (_this$diffEditorView28 = _this$diffEditorView27.getModifiedEditor()).getScrollHeight) === null || _this$diffEditorView29 === void 0 ? void 0 : _this$diffEditorView29.call(_this$diffEditorView28)) ?? this.cachedScrollHeightDiff;
3870
+ (_this$diffHeightManag4 = this.diffHeightManager) === null || _this$diffHeightManag4 === void 0 || _this$diffHeightManag4.update();
3473
3871
  }
3474
3872
  applyDefaultDiffHunkAction(context) {
3475
3873
  const { action, side, lineChange } = context;
@@ -3653,24 +4051,49 @@ var DiffEditorManager = class DiffEditorManager {
3653
4051
  this.preserveNativeDiffDecorationsOnStaleAppend = true;
3654
4052
  this.appendToModel(this.originalModel, text);
3655
4053
  }
3656
- computedHeight() {
3657
- var _originalEditor$getMo, _modifiedEditor$getMo, _originalEditor$getSc5, _modifiedEditor$getSc10;
4054
+ computeRawHeight() {
4055
+ var _originalEditor$getMo, _modifiedEditor$getMo2, _originalEditor$getSc5, _modifiedEditor$getSc10;
3658
4056
  if (!this.diffEditorView) return Math.min(1 * 18 + padding, this.maxHeightValue);
3659
4057
  const modifiedEditor = this.diffEditorView.getModifiedEditor();
3660
4058
  const originalEditor = this.diffEditorView.getOriginalEditor();
3661
4059
  const lineHeight = modifiedEditor.getOption(monaco_shim_exports.editor.EditorOption.lineHeight);
3662
4060
  const oCount = ((_originalEditor$getMo = originalEditor.getModel()) === null || _originalEditor$getMo === void 0 ? void 0 : _originalEditor$getMo.getLineCount()) ?? 1;
3663
- const mCount = ((_modifiedEditor$getMo = modifiedEditor.getModel()) === null || _modifiedEditor$getMo === void 0 ? void 0 : _modifiedEditor$getMo.getLineCount()) ?? 1;
4061
+ const mCount = ((_modifiedEditor$getMo2 = modifiedEditor.getModel()) === null || _modifiedEditor$getMo2 === void 0 ? void 0 : _modifiedEditor$getMo2.getLineCount()) ?? 1;
3664
4062
  const lineCount = Math.max(oCount, mCount);
3665
4063
  const fromLines = lineCount * lineHeight + padding;
3666
4064
  const scrollH = Math.max(((_originalEditor$getSc5 = originalEditor.getScrollHeight) === null || _originalEditor$getSc5 === void 0 ? void 0 : _originalEditor$getSc5.call(originalEditor)) ?? 0, ((_modifiedEditor$getSc10 = modifiedEditor.getScrollHeight) === null || _modifiedEditor$getSc10 === void 0 ? void 0 : _modifiedEditor$getSc10.call(modifiedEditor)) ?? 0);
3667
4065
  const desired = Math.max(fromLines, scrollH);
3668
4066
  return Math.min(desired, this.maxHeightValue);
3669
4067
  }
4068
+ computedHeight() {
4069
+ const rawHeight = this.computeRawHeight();
4070
+ if (!this.isDiffInlineMode()) return rawHeight;
4071
+ if (!this.inlineDiffStreamingPresentationActive && this.inlineDiffStreamingHeightFloor <= 0) return rawHeight;
4072
+ const lockedHeight = Math.max(rawHeight, this.inlineDiffStreamingHeightFloor);
4073
+ this.inlineDiffStreamingHeightFloor = lockedHeight;
4074
+ return lockedHeight;
4075
+ }
4076
+ eagerlyGrowDiffContainerHeight() {
4077
+ var _this$lastContainer$g, _this$lastContainer10;
4078
+ if (!this.lastContainer) return;
4079
+ const next = this.computedHeight();
4080
+ if (!Number.isFinite(next) || next <= 0) return;
4081
+ const applied = Number.parseFloat(this.lastContainer.style.height || "0") || 0;
4082
+ const measured = ((_this$lastContainer$g = (_this$lastContainer10 = this.lastContainer).getBoundingClientRect) === null || _this$lastContainer$g === void 0 ? void 0 : _this$lastContainer$g.call(_this$lastContainer10).height) ?? this.lastContainer.clientHeight ?? 0;
4083
+ const baseline = Math.max(applied, measured);
4084
+ if (next <= baseline + 1) return;
4085
+ this.lastContainer.style.height = `${next}px`;
4086
+ this.cachedComputedHeightDiff = next;
4087
+ this.scheduleSyncDiffEditorLayoutToContainer();
4088
+ }
3670
4089
  isOverflowAutoDiff() {
3671
4090
  if (!this.lastContainer) return false;
3672
4091
  return this.computedHeight() >= this.maxHeightValue - 1;
3673
4092
  }
4093
+ shouldAvoidOptimisticMaxHeightWriteDiff() {
4094
+ const hideUnchangedRegions = this.diffHideUnchangedRegionsResolved;
4095
+ return this.isDiffInlineMode() && (hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled) === true && !this.diffHideUnchangedRegionsDeferred;
4096
+ }
3674
4097
  shouldPerformImmediateRevealDiff() {
3675
4098
  return this.autoScrollOnUpdate && this.shouldAutoScrollDiff && !this.diffHideUnchangedRegionsDeferred && this.hasVerticalScrollbarModified() && this.isOverflowAutoDiff();
3676
4099
  }
@@ -3815,8 +4238,8 @@ var DiffEditorManager = class DiffEditorManager {
3815
4238
  lastRevealLineDiff: this.lastRevealLineDiff
3816
4239
  });
3817
4240
  try {
3818
- var _this$diffEditorView29, _this$diffEditorView30, _this$diffEditorView31;
3819
- this.lastScrollTopDiff = ((_this$diffEditorView29 = this.diffEditorView) === null || _this$diffEditorView29 === void 0 || (_this$diffEditorView31 = (_this$diffEditorView30 = _this$diffEditorView29.getModifiedEditor()).getScrollTop) === null || _this$diffEditorView31 === void 0 ? void 0 : _this$diffEditorView31.call(_this$diffEditorView30)) ?? this.lastScrollTopDiff;
4241
+ var _this$diffEditorView30, _this$diffEditorView31, _this$diffEditorView32;
4242
+ this.lastScrollTopDiff = ((_this$diffEditorView30 = this.diffEditorView) === null || _this$diffEditorView30 === void 0 || (_this$diffEditorView32 = (_this$diffEditorView31 = _this$diffEditorView30.getModifiedEditor()).getScrollTop) === null || _this$diffEditorView32 === void 0 ? void 0 : _this$diffEditorView32.call(_this$diffEditorView31)) ?? this.lastScrollTopDiff;
3820
4243
  } catch {}
3821
4244
  });
3822
4245
  }
@@ -3842,6 +4265,7 @@ var DiffEditorManager = class DiffEditorManager {
3842
4265
  if (target !== -1 && this.diffHeightManager) {
3843
4266
  if (this.lastContainer) this.lastContainer.style.height = `${target}px`;
3844
4267
  await this.waitForHeightAppliedDiff(target);
4268
+ this.syncDiffEditorLayoutToContainer();
3845
4269
  }
3846
4270
  this.performImmediateRevealDiff(line, ticket);
3847
4271
  });
@@ -3865,11 +4289,19 @@ var DiffEditorManager = class DiffEditorManager {
3865
4289
  });
3866
4290
  }
3867
4291
  async createDiffEditor(container, originalCode, modifiedCode, language, currentTheme) {
3868
- var _me$getScrollHeight2, _me$getOption, _oEditor$onDidContent, _mEditor$onDidContent;
4292
+ var _me$getScrollHeight2, _me$getOption, _oEditor$onDidLayoutC, _mEditor$onDidLayoutC, _oEditor$onDidContent, _mEditor$onDidContent;
3869
4293
  this.cleanup();
3870
4294
  this.lastContainer = container;
3871
4295
  container.style.overflow = "hidden";
3872
4296
  container.style.maxHeight = this.maxHeightCSS;
4297
+ container.innerHTML = "";
4298
+ const editorMount = typeof document !== "undefined" ? document.createElement("div") : container;
4299
+ if (editorMount !== container) {
4300
+ editorMount.style.width = "100%";
4301
+ editorMount.style.height = "100%";
4302
+ editorMount.style.overflow = "hidden";
4303
+ container.append(editorMount);
4304
+ }
3873
4305
  const lang = processedLanguage(language) || language;
3874
4306
  this.originalModel = monaco_shim_exports.editor.createModel(originalCode, lang);
3875
4307
  this.modifiedModel = monaco_shim_exports.editor.createModel(modifiedCode, lang);
@@ -3878,7 +4310,7 @@ var DiffEditorManager = class DiffEditorManager {
3878
4310
  const hideUnchangedRegions = this.resolveDiffHideUnchangedRegionsOption();
3879
4311
  this.diffHideUnchangedRegionsResolved = hideUnchangedRegions;
3880
4312
  this.diffHideUnchangedRegionsDeferred = false;
3881
- this.diffEditorView = monaco_shim_exports.editor.createDiffEditor(container, {
4313
+ this.diffEditorView = monaco_shim_exports.editor.createDiffEditor(editorMount, {
3882
4314
  automaticLayout: true,
3883
4315
  scrollBeyondLastLine: false,
3884
4316
  renderSideBySide: true,
@@ -3892,6 +4324,7 @@ var DiffEditorManager = class DiffEditorManager {
3892
4324
  ...this.options.scrollbar || {}
3893
4325
  },
3894
4326
  ...this.options,
4327
+ glyphMargin: this.resolveDiffGlyphMarginOption(hideUnchangedRegions),
3895
4328
  hideUnchangedRegions
3896
4329
  });
3897
4330
  monaco_shim_exports.editor.setTheme(currentTheme);
@@ -3928,8 +4361,10 @@ var DiffEditorManager = class DiffEditorManager {
3928
4361
  autoScrollInitial: this.autoScrollInitial,
3929
4362
  diffAutoScroll: this.diffAutoScroll
3930
4363
  });
3931
- const MIN_VISIBLE_HEIGHT = Math.min(120, this.maxHeightValue);
3932
- container.style.minHeight = `${MIN_VISIBLE_HEIGHT}px`;
4364
+ const minVisibleHeight = this.shouldDeferTailAppendForInlineStreaming() ? 0 : Math.min(120, this.maxHeightValue);
4365
+ if (minVisibleHeight > 0) container.style.minHeight = `${minVisibleHeight}px`;
4366
+ else if (typeof container.style.removeProperty === "function") container.style.removeProperty("min-height");
4367
+ else delete container.style.minHeight;
3933
4368
  if (this.diffHeightManager) {
3934
4369
  this.diffHeightManager.dispose();
3935
4370
  this.diffHeightManager = null;
@@ -3948,6 +4383,7 @@ var DiffEditorManager = class DiffEditorManager {
3948
4383
  this.diffComputedVersions = null;
3949
4384
  this.diffPresentationDisposables.push(this.diffEditorView.onDidUpdateDiff(() => {
3950
4385
  this.diffComputedVersions = this.captureCurrentDiffVersions();
4386
+ this.syncDiffEditorLayoutToContainer();
3951
4387
  this.scheduleSyncDiffPresentationDecorations();
3952
4388
  }));
3953
4389
  this.diffPresentationDisposables.push(oEditor.onDidChangeModelContent(() => {
@@ -3956,16 +4392,46 @@ var DiffEditorManager = class DiffEditorManager {
3956
4392
  this.diffPresentationDisposables.push(mEditor.onDidChangeModelContent(() => {
3957
4393
  this.scheduleSyncDiffPresentationDecorations();
3958
4394
  }));
4395
+ const originalLayoutDisposable = (_oEditor$onDidLayoutC = oEditor.onDidLayoutChange) === null || _oEditor$onDidLayoutC === void 0 ? void 0 : _oEditor$onDidLayoutC.call(oEditor, () => {
4396
+ this.scheduleSyncDiffPresentationDecorations();
4397
+ });
4398
+ if (originalLayoutDisposable) this.diffPresentationDisposables.push(originalLayoutDisposable);
4399
+ const modifiedLayoutDisposable = (_mEditor$onDidLayoutC = mEditor.onDidLayoutChange) === null || _mEditor$onDidLayoutC === void 0 ? void 0 : _mEditor$onDidLayoutC.call(mEditor, () => {
4400
+ this.scheduleSyncDiffPresentationDecorations();
4401
+ });
4402
+ if (modifiedLayoutDisposable) this.diffPresentationDisposables.push(modifiedLayoutDisposable);
4403
+ if (typeof MutationObserver !== "undefined" && this.lastContainer) {
4404
+ this.diffPresentationObserver = new MutationObserver((mutations) => {
4405
+ const shouldSync = mutations.some((mutation) => {
4406
+ if (mutation.type !== "childList") return false;
4407
+ const nodes = Array.from(mutation.addedNodes).concat(Array.from(mutation.removedNodes));
4408
+ return nodes.some((node) => {
4409
+ if (!(node instanceof HTMLElement)) return false;
4410
+ return node.matches(".line-delete, .inline-deleted-text, .inline-deleted-margin-view-zone") || !!node.querySelector(".line-delete, .inline-deleted-text, .inline-deleted-margin-view-zone") || !!node.closest(".editor.modified .view-zones, .editor.modified .margin-view-zones");
4411
+ });
4412
+ });
4413
+ if (shouldSync) this.scheduleSyncDiffPresentationDecorations();
4414
+ });
4415
+ this.diffPresentationObserver.observe(this.lastContainer, {
4416
+ childList: true,
4417
+ subtree: true
4418
+ });
4419
+ }
3959
4420
  (_oEditor$onDidContent = oEditor.onDidContentSizeChange) === null || _oEditor$onDidContent === void 0 || _oEditor$onDidContent.call(oEditor, () => {
3960
4421
  this._hasScrollBar = false;
3961
4422
  this.rafScheduler.schedule("content-size-change-diff", () => {
3962
- var _oEditor$getScrollHei, _oEditor$getOption, _this$diffHeightManag3, _this$diffHeightManag4;
4423
+ var _oEditor$getScrollHei, _oEditor$getOption, _this$diffHeightManag5, _this$diffHeightManag6;
3963
4424
  this.cachedScrollHeightDiff = ((_oEditor$getScrollHei = oEditor.getScrollHeight) === null || _oEditor$getScrollHei === void 0 ? void 0 : _oEditor$getScrollHei.call(oEditor)) ?? this.cachedScrollHeightDiff;
3964
4425
  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;
3965
4426
  this.cachedComputedHeightDiff = this.computedHeight();
3966
- if ((_this$diffHeightManag3 = this.diffHeightManager) === null || _this$diffHeightManag3 === void 0 ? void 0 : _this$diffHeightManag3.isSuppressed()) return;
3967
- (_this$diffHeightManag4 = this.diffHeightManager) === null || _this$diffHeightManag4 === void 0 || _this$diffHeightManag4.update();
3968
- const computed$1 = this.computedHeight();
4427
+ if (this.lastContainer) {
4428
+ const applied = Number.parseFloat(this.lastContainer.style.height || "0") || 0;
4429
+ if (this.cachedComputedHeightDiff > applied + 1 && (this.cachedComputedHeightDiff < this.maxHeightValue - 1 || !this.shouldAvoidOptimisticMaxHeightWriteDiff())) this.lastContainer.style.height = `${this.cachedComputedHeightDiff}px`;
4430
+ }
4431
+ if ((_this$diffHeightManag5 = this.diffHeightManager) === null || _this$diffHeightManag5 === void 0 ? void 0 : _this$diffHeightManag5.isSuppressed()) return;
4432
+ (_this$diffHeightManag6 = this.diffHeightManager) === null || _this$diffHeightManag6 === void 0 || _this$diffHeightManag6.update();
4433
+ this.scheduleSyncDiffEditorLayoutToContainer();
4434
+ const computed$1 = this.cachedComputedHeightDiff;
3969
4435
  if (this.lastContainer) {
3970
4436
  this.lastContainer.style.overflow = "hidden";
3971
4437
  if (computed$1 >= this.maxHeightValue - 1 && this.shouldAutoScrollDiff && !this.diffHideUnchangedRegionsDeferred) {
@@ -3978,13 +4444,18 @@ var DiffEditorManager = class DiffEditorManager {
3978
4444
  (_mEditor$onDidContent = mEditor.onDidContentSizeChange) === null || _mEditor$onDidContent === void 0 || _mEditor$onDidContent.call(mEditor, () => {
3979
4445
  this._hasScrollBar = false;
3980
4446
  this.rafScheduler.schedule("content-size-change-diff", () => {
3981
- var _mEditor$getScrollHei, _mEditor$getOption, _this$diffHeightManag5, _this$diffHeightManag6;
4447
+ var _mEditor$getScrollHei, _mEditor$getOption, _this$diffHeightManag7, _this$diffHeightManag8;
3982
4448
  this.cachedScrollHeightDiff = ((_mEditor$getScrollHei = mEditor.getScrollHeight) === null || _mEditor$getScrollHei === void 0 ? void 0 : _mEditor$getScrollHei.call(mEditor)) ?? this.cachedScrollHeightDiff;
3983
4449
  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;
3984
4450
  this.cachedComputedHeightDiff = this.computedHeight();
3985
- if ((_this$diffHeightManag5 = this.diffHeightManager) === null || _this$diffHeightManag5 === void 0 ? void 0 : _this$diffHeightManag5.isSuppressed()) return;
3986
- (_this$diffHeightManag6 = this.diffHeightManager) === null || _this$diffHeightManag6 === void 0 || _this$diffHeightManag6.update();
3987
- const computed$1 = this.computedHeight();
4451
+ if (this.lastContainer) {
4452
+ const applied = Number.parseFloat(this.lastContainer.style.height || "0") || 0;
4453
+ if (this.cachedComputedHeightDiff > applied + 1 && (this.cachedComputedHeightDiff < this.maxHeightValue - 1 || !this.shouldAvoidOptimisticMaxHeightWriteDiff())) this.lastContainer.style.height = `${this.cachedComputedHeightDiff}px`;
4454
+ }
4455
+ if ((_this$diffHeightManag7 = this.diffHeightManager) === null || _this$diffHeightManag7 === void 0 ? void 0 : _this$diffHeightManag7.isSuppressed()) return;
4456
+ (_this$diffHeightManag8 = this.diffHeightManager) === null || _this$diffHeightManag8 === void 0 || _this$diffHeightManag8.update();
4457
+ this.scheduleSyncDiffEditorLayoutToContainer();
4458
+ const computed$1 = this.cachedComputedHeightDiff;
3988
4459
  if (this.lastContainer) {
3989
4460
  this.lastContainer.style.overflow = "hidden";
3990
4461
  if (computed$1 >= this.maxHeightValue - 1 && this.shouldAutoScrollDiff && !this.diffHideUnchangedRegionsDeferred) {
@@ -4025,13 +4496,14 @@ var DiffEditorManager = class DiffEditorManager {
4025
4496
  const modifiedTailAppend = modifiedCode !== prevM && modifiedCode.startsWith(prevM) && prevM.length < modifiedCode.length;
4026
4497
  const hasContentChange = originalCode !== prevO || modifiedCode !== prevM;
4027
4498
  if (originalCode !== prevO || modifiedCode !== prevM) this.markDiffStreamingActivity();
4499
+ const deferTailAppendForInline = this.shouldDeferTailAppendForInlineStreaming();
4028
4500
  let didImmediate = false;
4029
- if (originalTailAppend) {
4501
+ if (originalTailAppend && !deferTailAppendForInline) {
4030
4502
  this.appendOriginal(originalCode.slice(prevO.length));
4031
4503
  this.lastKnownOriginalCode = originalCode;
4032
4504
  didImmediate = true;
4033
4505
  }
4034
- if (modifiedTailAppend) {
4506
+ if (modifiedTailAppend && !deferTailAppendForInline) {
4035
4507
  this.appendModified(modifiedCode.slice(prevM.length));
4036
4508
  this.lastKnownModifiedCode = modifiedCode;
4037
4509
  didImmediate = true;
@@ -4045,6 +4517,16 @@ var DiffEditorManager = class DiffEditorManager {
4045
4517
  this.rafScheduler.schedule("diff", () => this.flushPendingDiffUpdate());
4046
4518
  } else if (didImmediate) {}
4047
4519
  }
4520
+ shouldDeferTailAppendForInlineStreaming() {
4521
+ var _this$lastContainer11, _this$lastContainer12, _this$lastContainer13;
4522
+ const renderSideBySide = this.options.renderSideBySide ?? true;
4523
+ if (renderSideBySide === false) return true;
4524
+ const useInlineViewWhenSpaceIsLimited = this.options.useInlineViewWhenSpaceIsLimited ?? true;
4525
+ if (!useInlineViewWhenSpaceIsLimited) return false;
4526
+ const breakpoint = this.options.renderSideBySideInlineBreakpoint ?? 900;
4527
+ const width = ((_this$lastContainer11 = this.lastContainer) === null || _this$lastContainer11 === void 0 || (_this$lastContainer12 = _this$lastContainer11.getBoundingClientRect) === null || _this$lastContainer12 === void 0 ? void 0 : _this$lastContainer12.call(_this$lastContainer11).width) ?? ((_this$lastContainer13 = this.lastContainer) === null || _this$lastContainer13 === void 0 ? void 0 : _this$lastContainer13.clientWidth) ?? 0;
4528
+ return width > 0 && width <= breakpoint;
4529
+ }
4048
4530
  updateOriginal(newCode, codeLanguage) {
4049
4531
  if (!this.diffEditorView || !this.originalModel) return;
4050
4532
  if (codeLanguage) {
@@ -4082,10 +4564,11 @@ var DiffEditorManager = class DiffEditorManager {
4082
4564
  this.applyMinimalEditToModel(this.modifiedModel, prevAfterFlush, newCode);
4083
4565
  const newLine = this.modifiedModel.getLineCount();
4084
4566
  if (newLine !== prevLine) {
4567
+ this.eagerlyGrowDiffContainerHeight();
4085
4568
  const shouldImmediate = this.shouldPerformImmediateRevealDiff();
4086
4569
  if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
4087
4570
  const computed$1 = this.computedHeight();
4088
- if (computed$1 >= this.maxHeightValue - 1 && this.lastContainer) {
4571
+ if (computed$1 >= this.maxHeightValue - 1 && this.lastContainer && !this.shouldAvoidOptimisticMaxHeightWriteDiff()) {
4089
4572
  this.lastContainer.style.height = `${this.maxHeightValue}px`;
4090
4573
  this.lastContainer.style.overflow = "hidden";
4091
4574
  }
@@ -4184,14 +4667,15 @@ var DiffEditorManager = class DiffEditorManager {
4184
4667
  const currentOriginal = this.originalModel;
4185
4668
  const currentModified = this.modifiedModel;
4186
4669
  const shouldRestorePersistedUnchangedState = preserveViewState && !sameContent;
4670
+ const shouldRestoreSavedModelState = options.preserveModelState ?? true;
4187
4671
  const preservedScrollPosition = preserveViewState ? this.captureDiffScrollPosition() : null;
4188
4672
  const preservedViewportAnchor = preserveViewState && sameContent ? this.captureModifiedViewportAnchor() : null;
4189
- const viewState = preserveViewState ? this.diffEditorView.saveViewState() : null;
4673
+ const viewState = preserveViewState && shouldRestoreSavedModelState ? this.diffEditorView.saveViewState() : null;
4190
4674
  this.queuePendingDiffScrollRestore(preservedScrollPosition, shouldRestorePersistedUnchangedState ? 2 : 0);
4191
4675
  if (shouldRestorePersistedUnchangedState) this.capturePersistedDiffUnchangedState();
4192
4676
  const applyModelSwap = () => {
4193
- var _this$diffEditorView32;
4194
- (_this$diffEditorView32 = this.diffEditorView) === null || _this$diffEditorView32 === void 0 || _this$diffEditorView32.setModel(nextModelTarget);
4677
+ var _this$diffEditorView33;
4678
+ (_this$diffEditorView33 = this.diffEditorView) === null || _this$diffEditorView33 === void 0 || _this$diffEditorView33.setModel(nextModelTarget);
4195
4679
  };
4196
4680
  if (preserveViewState) this.withLockedDiffScrollPosition(applyModelSwap);
4197
4681
  else applyModelSwap();
@@ -4270,6 +4754,7 @@ var DiffEditorManager = class DiffEditorManager {
4270
4754
  this.revealTicketDiff = 0;
4271
4755
  this.lastRevealLineDiff = null;
4272
4756
  this.diffPersistedUnchangedModelState = null;
4757
+ this.diffPreviousUnchangedModelState = null;
4273
4758
  this.pendingDiffScrollRestorePosition = null;
4274
4759
  this.pendingDiffScrollRestoreBudget = 0;
4275
4760
  this.diffHideUnchangedRegionsResolved = null;
@@ -4297,7 +4782,11 @@ var DiffEditorManager = class DiffEditorManager {
4297
4782
  this.revealTicketDiff = 0;
4298
4783
  this.lastRevealLineDiff = null;
4299
4784
  this.diffPersistedUnchangedModelState = null;
4785
+ this.diffPreviousUnchangedModelState = null;
4300
4786
  this.diffHideUnchangedRegionsDeferred = false;
4787
+ this.clearInlineDiffStreamingPresentationIdleTimer();
4788
+ this.inlineDiffStreamingPresentationActive = false;
4789
+ this.resetInlineDiffStreamingHeightFloor();
4301
4790
  }
4302
4791
  syncLastKnownModified() {
4303
4792
  if (!this.diffEditorView || !this.lastKnownModifiedDirty) return;
@@ -4353,10 +4842,11 @@ var DiffEditorManager = class DiffEditorManager {
4353
4842
  this.lastKnownModifiedCode = modified;
4354
4843
  const newMLineCount = m.getLineCount();
4355
4844
  if (newMLineCount !== prevMLineCount) {
4845
+ this.eagerlyGrowDiffContainerHeight();
4356
4846
  const shouldImmediate = this.shouldPerformImmediateRevealDiff();
4357
4847
  if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
4358
4848
  const computed$1 = this.computedHeight();
4359
- if (computed$1 >= this.maxHeightValue - 1 && this.lastContainer) {
4849
+ if (computed$1 >= this.maxHeightValue - 1 && this.lastContainer && !this.shouldAvoidOptimisticMaxHeightWriteDiff()) {
4360
4850
  this.lastContainer.style.height = `${this.maxHeightValue}px`;
4361
4851
  this.lastContainer.style.overflow = "hidden";
4362
4852
  }
@@ -4446,6 +4936,7 @@ var DiffEditorManager = class DiffEditorManager {
4446
4936
  const newLine$1 = model.getLineCount();
4447
4937
  this.lastKnownModifiedLineCount = newLine$1;
4448
4938
  await new Promise((resolve) => typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame(resolve) : setTimeout(resolve, 0));
4939
+ this.eagerlyGrowDiffContainerHeight();
4449
4940
  const shouldImmediate$1 = this.shouldPerformImmediateRevealDiff();
4450
4941
  log("diff", "flushAppendBufferDiff chunk metrics", {
4451
4942
  idx,
@@ -4455,7 +4946,7 @@ var DiffEditorManager = class DiffEditorManager {
4455
4946
  });
4456
4947
  if (shouldImmediate$1) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
4457
4948
  const computed$2 = this.computedHeight();
4458
- if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) {
4949
+ if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer && !this.shouldAvoidOptimisticMaxHeightWriteDiff()) {
4459
4950
  this.lastContainer.style.height = `${this.maxHeightValue}px`;
4460
4951
  this.lastContainer.style.overflow = "hidden";
4461
4952
  }
@@ -4484,16 +4975,17 @@ var DiffEditorManager = class DiffEditorManager {
4484
4975
  this.lastKnownModifiedCode = model.getValue();
4485
4976
  const newLine = model.getLineCount();
4486
4977
  this.lastKnownModifiedLineCount = newLine;
4978
+ this.eagerlyGrowDiffContainerHeight();
4487
4979
  const shouldImmediate = this.shouldPerformImmediateRevealDiff();
4488
4980
  if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
4489
4981
  const computed$1 = this.computedHeight();
4490
- if (computed$1 >= this.maxHeightValue - 1 && this.lastContainer) this.lastContainer.style.height = `${this.maxHeightValue}px`;
4982
+ if (computed$1 >= this.maxHeightValue - 1 && this.lastContainer && !this.shouldAvoidOptimisticMaxHeightWriteDiff()) this.lastContainer.style.height = `${this.maxHeightValue}px`;
4491
4983
  if (shouldImmediate) this.scheduleImmediateRevealAfterLayoutDiff(newLine);
4492
4984
  else this.maybeScrollDiffToBottom(newLine, prevLine);
4493
4985
  if (suppressedByFlush) watcherApi.setSuppressed(false);
4494
4986
  try {
4495
- var _this$diffEditorView33, _this$diffEditorView34, _this$diffEditorView35;
4496
- this.lastScrollTopDiff = ((_this$diffEditorView33 = this.diffEditorView) === null || _this$diffEditorView33 === void 0 || (_this$diffEditorView35 = (_this$diffEditorView34 = _this$diffEditorView33.getModifiedEditor()).getScrollTop) === null || _this$diffEditorView35 === void 0 ? void 0 : _this$diffEditorView35.call(_this$diffEditorView34)) ?? this.lastScrollTopDiff;
4987
+ var _this$diffEditorView34, _this$diffEditorView35, _this$diffEditorView36;
4988
+ this.lastScrollTopDiff = ((_this$diffEditorView34 = this.diffEditorView) === null || _this$diffEditorView34 === void 0 || (_this$diffEditorView36 = (_this$diffEditorView35 = _this$diffEditorView34.getModifiedEditor()).getScrollTop) === null || _this$diffEditorView36 === void 0 ? void 0 : _this$diffEditorView36.call(_this$diffEditorView35)) ?? this.lastScrollTopDiff;
4497
4989
  } catch {}
4498
4990
  }
4499
4991
  applyMinimalEditToModel(model, prev, next) {