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.
@@ -550,8 +550,14 @@ var DiffEditorManager = class DiffEditorManager {
550
550
  diffComputedVersions = null;
551
551
  preserveNativeDiffDecorationsOnStaleAppend = false;
552
552
  diffPresentationDisposables = [];
553
+ diffPresentationObserver = null;
553
554
  fallbackOriginalDecorationIds = [];
554
555
  fallbackModifiedDecorationIds = [];
556
+ fallbackInlineDeletedZoneIds = [];
557
+ fallbackInlineDeletedZoneSignature = null;
558
+ inlineDiffStreamingPresentationActive = false;
559
+ inlineDiffStreamingPresentationIdleTimer = null;
560
+ inlineDiffStreamingHeightFloor = 0;
555
561
  diffHunkHideTimer = null;
556
562
  diffUnchangedRegionDisposables = [];
557
563
  diffUnchangedRegionObserver = null;
@@ -564,9 +570,11 @@ var DiffEditorManager = class DiffEditorManager {
564
570
  diffUnchangedOverlayScrollLeft = 0;
565
571
  diffRootAppearanceSignature = null;
566
572
  diffPersistedUnchangedModelState = null;
573
+ diffPreviousUnchangedModelState = null;
567
574
  pendingPreparedDiffViewModel = null;
568
575
  cancelRafs() {
569
576
  this.rafScheduler.cancel("sync-diff-presentation");
577
+ this.rafScheduler.cancel("sync-diff-layout");
570
578
  this.rafScheduler.cancel("capture-diff-unchanged-state");
571
579
  this.rafScheduler.cancel("restore-diff-unchanged-state");
572
580
  this.rafScheduler.cancel("patch-diff-unchanged-regions");
@@ -653,6 +661,9 @@ var DiffEditorManager = class DiffEditorManager {
653
661
  revealLineCount: 5
654
662
  };
655
663
  }
664
+ resolveDiffGlyphMarginOption(hideUnchangedRegions = this.resolveDiffHideUnchangedRegionsOption()) {
665
+ return (hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled) ? true : this.options.glyphMargin;
666
+ }
656
667
  resolveDiffLineStyleOption() {
657
668
  return this.options.diffLineStyle === "bar" ? "bar" : "background";
658
669
  }
@@ -982,6 +993,220 @@ var DiffEditorManager = class DiffEditorManager {
982
993
  else this.fallbackOriginalDecorationIds = [];
983
994
  if (modifiedEditor && this.fallbackModifiedDecorationIds.length > 0) this.fallbackModifiedDecorationIds = modifiedEditor.deltaDecorations(this.fallbackModifiedDecorationIds, []);
984
995
  else this.fallbackModifiedDecorationIds = [];
996
+ this.clearFallbackInlineDeletedZones();
997
+ }
998
+ clearFallbackInlineDeletedZones() {
999
+ var _this$diffEditorView13;
1000
+ const modifiedEditor = (_this$diffEditorView13 = this.diffEditorView) === null || _this$diffEditorView13 === void 0 ? void 0 : _this$diffEditorView13.getModifiedEditor();
1001
+ if (modifiedEditor && this.fallbackInlineDeletedZoneIds.length > 0) try {
1002
+ var _modifiedEditor$chang;
1003
+ (_modifiedEditor$chang = modifiedEditor.changeViewZones) === null || _modifiedEditor$chang === void 0 || _modifiedEditor$chang.call(modifiedEditor, (accessor) => {
1004
+ for (const id of this.fallbackInlineDeletedZoneIds) accessor.removeZone(id);
1005
+ });
1006
+ } catch {}
1007
+ this.fallbackInlineDeletedZoneIds = [];
1008
+ this.clearFallbackInlineDeletedZoneWrapperContent();
1009
+ this.fallbackInlineDeletedZoneSignature = null;
1010
+ }
1011
+ clearFallbackInlineDeletedZoneWrapperContent() {
1012
+ var _this$lastContainer, _this$lastContainer2, _node$parentElement;
1013
+ 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;
1014
+ if (!querySelectorAll) return;
1015
+ 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\"]") ?? []);
1016
+ for (const node of nodes) (_node$parentElement = node.parentElement) === null || _node$parentElement === void 0 || _node$parentElement.removeChild(node);
1017
+ }
1018
+ clearInlineDiffStreamingPresentationIdleTimer() {
1019
+ if (this.inlineDiffStreamingPresentationIdleTimer != null) {
1020
+ clearTimeout(this.inlineDiffStreamingPresentationIdleTimer);
1021
+ this.inlineDiffStreamingPresentationIdleTimer = null;
1022
+ }
1023
+ }
1024
+ resetInlineDiffStreamingHeightFloor() {
1025
+ this.inlineDiffStreamingHeightFloor = 0;
1026
+ }
1027
+ syncDiffEditorLayoutToContainer() {
1028
+ if (!this.diffEditorView || !this.lastContainer) return;
1029
+ const width = this.lastContainer.clientWidth || this.lastContainer.getBoundingClientRect().width;
1030
+ const height = this.lastContainer.clientHeight || this.lastContainer.getBoundingClientRect().height;
1031
+ if (!(width > 0) || !(height > 0)) return;
1032
+ try {
1033
+ var _layout, _ref;
1034
+ (_layout = (_ref = this.diffEditorView).layout) === null || _layout === void 0 || _layout.call(_ref, {
1035
+ width: Math.round(width),
1036
+ height: Math.round(height)
1037
+ });
1038
+ } catch {
1039
+ try {
1040
+ var _layout2, _ref2;
1041
+ (_layout2 = (_ref2 = this.diffEditorView).layout) === null || _layout2 === void 0 || _layout2.call(_ref2);
1042
+ } catch {}
1043
+ }
1044
+ }
1045
+ scheduleSyncDiffEditorLayoutToContainer() {
1046
+ this.rafScheduler.schedule("sync-diff-layout", () => {
1047
+ this.syncDiffEditorLayoutToContainer();
1048
+ });
1049
+ }
1050
+ readModelLineContent(model, lineNumber) {
1051
+ const direct = model.getLineContent;
1052
+ if (typeof direct === "function") return direct.call(model, lineNumber);
1053
+ return model.getValue().split(/\r?\n/)[lineNumber - 1] ?? "";
1054
+ }
1055
+ hasVisibleNativeInlineDeleteNodes() {
1056
+ if (!this.lastContainer) return false;
1057
+ const querySelectorAll = typeof this.lastContainer.querySelectorAll === "function" ? this.lastContainer.querySelectorAll.bind(this.lastContainer) : null;
1058
+ if (!querySelectorAll) return false;
1059
+ const nodes = Array.from(querySelectorAll(".editor.modified .view-zones .line-delete, .editor.modified .inline-deleted-text, .editor.modified .inline-deleted-margin-view-zone") ?? []);
1060
+ return nodes.some((node) => {
1061
+ var _node$getBoundingClie, _globalThis$getComput, _globalThis;
1062
+ if (!(node instanceof HTMLElement)) return false;
1063
+ const rect = (_node$getBoundingClie = node.getBoundingClientRect) === null || _node$getBoundingClie === void 0 ? void 0 : _node$getBoundingClie.call(node);
1064
+ const style = (_globalThis$getComput = (_globalThis = globalThis).getComputedStyle) === null || _globalThis$getComput === void 0 ? void 0 : _globalThis$getComput.call(_globalThis, node);
1065
+ 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;
1066
+ });
1067
+ }
1068
+ countNativeInlineDeleteZoneNodes() {
1069
+ if (!this.lastContainer) return 0;
1070
+ const querySelectorAll = typeof this.lastContainer.querySelectorAll === "function" ? this.lastContainer.querySelectorAll.bind(this.lastContainer) : null;
1071
+ if (!querySelectorAll) return 0;
1072
+ const nodes = Array.from(querySelectorAll(".editor.modified .view-zones [monaco-view-zone], .editor.modified .margin-view-zones [monaco-view-zone]") ?? []);
1073
+ return nodes.filter((node) => {
1074
+ if (!(node instanceof HTMLElement)) return false;
1075
+ 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");
1076
+ }).length;
1077
+ }
1078
+ syncFallbackInlineDeletedZones(lineChanges) {
1079
+ var _modifiedEditor$getMo, _EditorOption, _modifiedEditor$getOp, _this$lastContainer3, _this$lastContainer3$, _this$lastContainer4, _this$lastContainer4$;
1080
+ if (typeof document === "undefined" || !this.diffEditorView || !this.originalModel || !this.isDiffInlineMode()) {
1081
+ this.clearFallbackInlineDeletedZones();
1082
+ return;
1083
+ }
1084
+ const modifiedEditor = this.diffEditorView.getModifiedEditor();
1085
+ const modifiedModel = modifiedEditor === null || modifiedEditor === void 0 || (_modifiedEditor$getMo = modifiedEditor.getModel) === null || _modifiedEditor$getMo === void 0 ? void 0 : _modifiedEditor$getMo.call(modifiedEditor);
1086
+ const originalModel = this.originalModel;
1087
+ if (!modifiedEditor || !modifiedModel || !originalModel) {
1088
+ this.fallbackInlineDeletedZoneIds = [];
1089
+ return;
1090
+ }
1091
+ const lineHeightOption = (_EditorOption = monaco_shim_exports.editor.EditorOption) === null || _EditorOption === void 0 ? void 0 : _EditorOption.lineHeight;
1092
+ const lineHeight = ((_modifiedEditor$getOp = modifiedEditor.getOption) === null || _modifiedEditor$getOp === void 0 ? void 0 : _modifiedEditor$getOp.call(modifiedEditor, lineHeightOption)) ?? 20;
1093
+ const relevantChanges = lineChanges.filter((change) => this.hasOriginalLines(change));
1094
+ 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) => {
1095
+ return node instanceof HTMLElement && !!node.querySelector(".view-lines.line-delete");
1096
+ });
1097
+ 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) => {
1098
+ return node instanceof HTMLElement && !!node.querySelector(".inline-deleted-margin-view-zone");
1099
+ });
1100
+ const nativePairs = nativeViewWrappers.map((viewWrapper) => {
1101
+ const id = viewWrapper.getAttribute("monaco-view-zone");
1102
+ if (!id) return null;
1103
+ const marginWrapper = nativeMarginWrappers.find((candidate) => candidate.getAttribute("monaco-view-zone") === id);
1104
+ return {
1105
+ id,
1106
+ top: Number.parseFloat(viewWrapper.style.top || "NaN"),
1107
+ viewWrapper,
1108
+ marginWrapper: marginWrapper ?? null
1109
+ };
1110
+ }).filter((entry) => !!entry && Number.isFinite(entry.top)).sort((left, right) => left.top - right.top);
1111
+ if (nativePairs.length >= relevantChanges.length && relevantChanges.length > 0) {
1112
+ const nextSignature$1 = nativePairs.slice(0, relevantChanges.length).map((pair, index) => {
1113
+ const change = relevantChanges[index];
1114
+ const text = Array.from({ length: change.originalEndLineNumber - change.originalStartLineNumber + 1 }, (_, offset) => this.readModelLineContent(originalModel, change.originalStartLineNumber + offset)).join("\n");
1115
+ return `${pair.id}:${text}`;
1116
+ }).join("|");
1117
+ if (nextSignature$1 && this.fallbackInlineDeletedZoneSignature === nextSignature$1 && this.fallbackInlineDeletedZoneIds.length === 0) return;
1118
+ if (this.fallbackInlineDeletedZoneIds.length > 0) {
1119
+ try {
1120
+ var _modifiedEditor$chang2;
1121
+ (_modifiedEditor$chang2 = modifiedEditor.changeViewZones) === null || _modifiedEditor$chang2 === void 0 || _modifiedEditor$chang2.call(modifiedEditor, (accessor) => {
1122
+ for (const id of this.fallbackInlineDeletedZoneIds) accessor.removeZone(id);
1123
+ });
1124
+ } catch {}
1125
+ this.fallbackInlineDeletedZoneIds = [];
1126
+ }
1127
+ this.clearFallbackInlineDeletedZoneWrapperContent();
1128
+ relevantChanges.forEach((change, index) => {
1129
+ var _modifiedEditor$apply;
1130
+ const pair = nativePairs[index];
1131
+ const domNode = document.createElement("div");
1132
+ domNode.className = "stream-monaco-fallback-inline-delete-zone";
1133
+ domNode.setAttribute("aria-hidden", "true");
1134
+ domNode.setAttribute("data-stream-monaco-native-wrapper", "true");
1135
+ (_modifiedEditor$apply = modifiedEditor.applyFontInfo) === null || _modifiedEditor$apply === void 0 || _modifiedEditor$apply.call(modifiedEditor, domNode);
1136
+ for (let line = change.originalStartLineNumber; line <= change.originalEndLineNumber; line++) {
1137
+ const lineNode = document.createElement("div");
1138
+ lineNode.className = "stream-monaco-fallback-inline-delete-line";
1139
+ lineNode.textContent = this.readModelLineContent(originalModel, line);
1140
+ lineNode.style.height = `${lineHeight}px`;
1141
+ lineNode.style.lineHeight = `${lineHeight}px`;
1142
+ domNode.append(lineNode);
1143
+ }
1144
+ pair.viewWrapper.append(domNode);
1145
+ if (pair.marginWrapper) {
1146
+ var _modifiedEditor$apply2;
1147
+ const marginDomNode = document.createElement("div");
1148
+ marginDomNode.className = "stream-monaco-fallback-inline-delete-margin";
1149
+ marginDomNode.setAttribute("aria-hidden", "true");
1150
+ marginDomNode.setAttribute("data-stream-monaco-native-wrapper", "true");
1151
+ marginDomNode.style.height = "100%";
1152
+ (_modifiedEditor$apply2 = modifiedEditor.applyFontInfo) === null || _modifiedEditor$apply2 === void 0 || _modifiedEditor$apply2.call(modifiedEditor, marginDomNode);
1153
+ pair.marginWrapper.append(marginDomNode);
1154
+ }
1155
+ });
1156
+ this.fallbackInlineDeletedZoneSignature = nextSignature$1 || null;
1157
+ return;
1158
+ }
1159
+ this.clearFallbackInlineDeletedZoneWrapperContent();
1160
+ const nextZones = relevantChanges.map((change) => {
1161
+ var _modifiedEditor$apply3, _modifiedEditor$apply4;
1162
+ const lineCount = change.originalEndLineNumber - change.originalStartLineNumber + 1;
1163
+ if (lineCount < 1) return null;
1164
+ const domNode = document.createElement("div");
1165
+ domNode.className = "stream-monaco-fallback-inline-delete-zone";
1166
+ domNode.setAttribute("aria-hidden", "true");
1167
+ (_modifiedEditor$apply3 = modifiedEditor.applyFontInfo) === null || _modifiedEditor$apply3 === void 0 || _modifiedEditor$apply3.call(modifiedEditor, domNode);
1168
+ for (let line = change.originalStartLineNumber; line <= change.originalEndLineNumber; line++) {
1169
+ const lineNode = document.createElement("div");
1170
+ lineNode.className = "stream-monaco-fallback-inline-delete-line";
1171
+ lineNode.textContent = this.readModelLineContent(originalModel, line);
1172
+ lineNode.style.height = `${lineHeight}px`;
1173
+ lineNode.style.lineHeight = `${lineHeight}px`;
1174
+ domNode.append(lineNode);
1175
+ }
1176
+ const marginDomNode = document.createElement("div");
1177
+ marginDomNode.className = "stream-monaco-fallback-inline-delete-margin";
1178
+ marginDomNode.setAttribute("aria-hidden", "true");
1179
+ (_modifiedEditor$apply4 = modifiedEditor.applyFontInfo) === null || _modifiedEditor$apply4 === void 0 || _modifiedEditor$apply4.call(modifiedEditor, marginDomNode);
1180
+ const anchorLine = Math.max(0, Math.min(modifiedModel.getLineCount(), (change.modifiedStartLineNumber || 1) - 1));
1181
+ return {
1182
+ afterLineNumber: anchorLine,
1183
+ heightInLines: lineCount,
1184
+ domNode,
1185
+ marginDomNode
1186
+ };
1187
+ }).filter(Boolean);
1188
+ const nextSignature = nextZones.map((zone) => {
1189
+ var _zone$domNode;
1190
+ const text = typeof ((_zone$domNode = zone.domNode) === null || _zone$domNode === void 0 ? void 0 : _zone$domNode.textContent) === "string" ? zone.domNode.textContent : "";
1191
+ return `${zone.afterLineNumber}:${zone.heightInLines}:${text}`;
1192
+ }).join("|");
1193
+ if (nextSignature && this.fallbackInlineDeletedZoneSignature === nextSignature && this.fallbackInlineDeletedZoneIds.length === nextZones.length) return;
1194
+ try {
1195
+ var _modifiedEditor$chang3;
1196
+ (_modifiedEditor$chang3 = modifiedEditor.changeViewZones) === null || _modifiedEditor$chang3 === void 0 || _modifiedEditor$chang3.call(modifiedEditor, (accessor) => {
1197
+ for (const id of this.fallbackInlineDeletedZoneIds) accessor.removeZone(id);
1198
+ this.fallbackInlineDeletedZoneIds = nextZones.map((zone) => accessor.addZone(zone));
1199
+ });
1200
+ this.fallbackInlineDeletedZoneSignature = nextSignature || null;
1201
+ } catch {
1202
+ this.fallbackInlineDeletedZoneIds = [];
1203
+ this.fallbackInlineDeletedZoneSignature = null;
1204
+ }
1205
+ try {
1206
+ var _modifiedEditor$layou, _render;
1207
+ (_modifiedEditor$layou = modifiedEditor.layout) === null || _modifiedEditor$layou === void 0 || _modifiedEditor$layou.call(modifiedEditor);
1208
+ (_render = modifiedEditor.render) === null || _render === void 0 || _render.call(modifiedEditor, true);
1209
+ } catch {}
985
1210
  }
986
1211
  toWholeLineDecoration(side, startLineNumber, endLineNumber) {
987
1212
  if (endLineNumber < startLineNumber || startLineNumber < 1) return null;
@@ -999,26 +1224,45 @@ var DiffEditorManager = class DiffEditorManager {
999
1224
  };
1000
1225
  }
1001
1226
  syncDiffPresentationDecorations() {
1002
- var _this$diffEditorView$3, _this$lastContainer$q, _this$lastContainer;
1227
+ var _this$diffEditorView$3, _this$lastContainer$q, _this$lastContainer5;
1003
1228
  if (!this.diffEditorView || !this.lastContainer) return;
1004
1229
  const nativeFresh = this.hasFreshNativeDiffResult();
1005
- 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")));
1230
+ const useInlineMode = this.isDiffInlineMode();
1231
+ const lineChanges = this.getEffectiveLineChanges();
1232
+ const nativeInlineDeleteZoneCount = useInlineMode ? this.countNativeInlineDeleteZoneNodes() : 0;
1233
+ const hasNativeInlineDeleteZoneNodes = nativeInlineDeleteZoneCount > 0;
1234
+ const hasNativeInlineDeleteNodes = useInlineMode && this.hasVisibleNativeInlineDeleteNodes();
1235
+ const shouldKeepInlineFallback = useInlineMode && lineChanges.some((change) => this.hasOriginalLines(change)) && !hasNativeInlineDeleteZoneNodes;
1236
+ const useInlineStaleFallback = shouldKeepInlineFallback;
1237
+ this.lastContainer.classList.toggle("stream-monaco-diff-inline-native-ready", useInlineMode && !shouldKeepInlineFallback && (nativeFresh || hasNativeInlineDeleteNodes || hasNativeInlineDeleteZoneNodes));
1238
+ 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")));
1006
1239
  this.lastContainer.classList.toggle("stream-monaco-diff-native-stale", !nativeFresh && !keepNativeDecorationsWhileStale);
1007
- if (nativeFresh) {
1240
+ if (nativeFresh && !shouldKeepInlineFallback) {
1008
1241
  this.clearFallbackDiffDecorations();
1009
1242
  return;
1010
1243
  }
1011
1244
  const originalEditor = this.diffEditorView.getOriginalEditor();
1012
1245
  const modifiedEditor = this.diffEditorView.getModifiedEditor();
1013
- const lineChanges = this.getEffectiveLineChanges();
1014
1246
  const originalDecorations = lineChanges.map((change) => this.toWholeLineDecoration("original", change.originalStartLineNumber, change.originalEndLineNumber)).filter(Boolean);
1015
1247
  const modifiedDecorations = lineChanges.map((change) => this.toWholeLineDecoration("modified", change.modifiedStartLineNumber, change.modifiedEndLineNumber)).filter(Boolean);
1016
1248
  this.fallbackOriginalDecorationIds = originalEditor.deltaDecorations(this.fallbackOriginalDecorationIds, originalDecorations);
1017
1249
  this.fallbackModifiedDecorationIds = modifiedEditor.deltaDecorations(this.fallbackModifiedDecorationIds, modifiedDecorations);
1250
+ if (useInlineStaleFallback) this.syncFallbackInlineDeletedZones(lineChanges);
1251
+ else this.clearFallbackInlineDeletedZones();
1018
1252
  }
1019
1253
  disposeDiffPresentationTracking() {
1020
1254
  this.clearFallbackDiffDecorations();
1021
- if (this.lastContainer) this.lastContainer.classList.remove("stream-monaco-diff-native-stale");
1255
+ if (this.diffPresentationObserver) {
1256
+ this.diffPresentationObserver.disconnect();
1257
+ this.diffPresentationObserver = null;
1258
+ }
1259
+ this.clearInlineDiffStreamingPresentationIdleTimer();
1260
+ this.inlineDiffStreamingPresentationActive = false;
1261
+ this.resetInlineDiffStreamingHeightFloor();
1262
+ if (this.lastContainer) {
1263
+ this.lastContainer.classList.remove("stream-monaco-diff-native-stale");
1264
+ this.lastContainer.classList.remove("stream-monaco-diff-inline-native-ready");
1265
+ }
1022
1266
  this.diffComputedVersions = null;
1023
1267
  this.diffPresentationDisposables.forEach((disposable) => disposable.dispose());
1024
1268
  this.diffPresentationDisposables = [];
@@ -1369,6 +1613,31 @@ var DiffEditorManager = class DiffEditorManager {
1369
1613
  border: 0 !important;
1370
1614
  box-shadow: var(--stream-monaco-removed-line-shadow);
1371
1615
  }
1616
+ .stream-monaco-diff-root .monaco-editor .stream-monaco-fallback-inline-delete-zone {
1617
+ box-sizing: border-box;
1618
+ width: 100%;
1619
+ pointer-events: none;
1620
+ }
1621
+ .stream-monaco-diff-root .monaco-editor .stream-monaco-fallback-inline-delete-line {
1622
+ box-sizing: border-box;
1623
+ width: 100%;
1624
+ overflow: hidden;
1625
+ white-space: pre;
1626
+ color: inherit;
1627
+ background: var(--stream-monaco-removed-line-fill);
1628
+ box-shadow: var(--stream-monaco-removed-line-shadow);
1629
+ }
1630
+ .stream-monaco-diff-root .monaco-editor .stream-monaco-fallback-inline-delete-margin {
1631
+ box-sizing: border-box;
1632
+ width: 100%;
1633
+ background: var(--stream-monaco-removed-gutter);
1634
+ pointer-events: none;
1635
+ }
1636
+ .stream-monaco-diff-root.stream-monaco-diff-inline-native-ready .stream-monaco-fallback-inline-delete-zone,
1637
+ .stream-monaco-diff-root.stream-monaco-diff-inline-native-ready .stream-monaco-fallback-inline-delete-line,
1638
+ .stream-monaco-diff-root.stream-monaco-diff-inline-native-ready .stream-monaco-fallback-inline-delete-margin {
1639
+ display: none !important;
1640
+ }
1372
1641
  .stream-monaco-diff-root .monaco-editor .stream-monaco-fallback-gutter-insert,
1373
1642
  .stream-monaco-diff-root .monaco-diff-editor .stream-monaco-fallback-gutter-insert {
1374
1643
  background: var(--stream-monaco-added-gutter) !important;
@@ -1498,6 +1767,9 @@ var DiffEditorManager = class DiffEditorManager {
1498
1767
  }
1499
1768
  .stream-monaco-diff-root .monaco-diff-editor .editor.original .current-line {
1500
1769
  width: var(--stream-monaco-original-margin-width, auto) !important;
1770
+ display: none !important;
1771
+ opacity: 0 !important;
1772
+ pointer-events: none !important;
1501
1773
  }
1502
1774
  .stream-monaco-diff-root .monaco-diff-editor .editor.original .monaco-scrollable-element.editor-scrollable {
1503
1775
  left: var(--stream-monaco-original-scrollable-left, auto) !important;
@@ -1510,6 +1782,9 @@ var DiffEditorManager = class DiffEditorManager {
1510
1782
  }
1511
1783
  .stream-monaco-diff-root .monaco-diff-editor .editor.modified .current-line {
1512
1784
  width: var(--stream-monaco-modified-margin-width) !important;
1785
+ display: none !important;
1786
+ opacity: 0 !important;
1787
+ pointer-events: none !important;
1513
1788
  }
1514
1789
  .stream-monaco-diff-root .monaco-diff-editor .editor.modified .monaco-scrollable-element.editor-scrollable {
1515
1790
  left: var(--stream-monaco-modified-scrollable-left, var(--stream-monaco-modified-margin-width)) !important;
@@ -1540,15 +1815,39 @@ var DiffEditorManager = class DiffEditorManager {
1540
1815
  border: 0 !important;
1541
1816
  overflow: hidden !important;
1542
1817
  }
1818
+ .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .monaco-editor,
1819
+ .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .monaco-editor-background,
1820
+ .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .lines-content {
1821
+ width: 0 !important;
1822
+ min-width: 0 !important;
1823
+ background: transparent !important;
1824
+ opacity: 0 !important;
1825
+ pointer-events: none !important;
1826
+ }
1543
1827
  .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .monaco-scrollable-element.editor-scrollable {
1544
1828
  left: 0 !important;
1545
1829
  width: 0 !important;
1546
1830
  }
1831
+ .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .margin,
1832
+ .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .margin-view-overlays,
1833
+ .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .margin-view-zones,
1834
+ .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .overflow-guard {
1835
+ display: none !important;
1836
+ width: 0 !important;
1837
+ min-width: 0 !important;
1838
+ }
1547
1839
  .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.modified {
1548
1840
  left: 0 !important;
1549
1841
  width: 100% !important;
1550
1842
  border-left: 0 !important;
1551
1843
  }
1844
+ .stream-monaco-diff-root.stream-monaco-diff-inline.stream-monaco-diff-native-stale .monaco-diff-editor .editor.modified .view-lines.line-delete,
1845
+ .stream-monaco-diff-root.stream-monaco-diff-inline.stream-monaco-diff-native-stale .monaco-diff-editor .editor.modified .inline-deleted-margin-view-zone {
1846
+ display: none !important;
1847
+ height: 0 !important;
1848
+ min-height: 0 !important;
1849
+ overflow: hidden !important;
1850
+ }
1552
1851
  .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .gutter-delete,
1553
1852
  .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .gutter-insert,
1554
1853
  .stream-monaco-diff-root.stream-monaco-diff-inline .monaco-diff-editor .editor.original .line-delete,
@@ -2138,6 +2437,9 @@ var DiffEditorManager = class DiffEditorManager {
2138
2437
  opacity: 0.92 !important;
2139
2438
  transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.14s ease, opacity 0.14s ease, box-shadow 0.14s ease;
2140
2439
  }
2440
+ .stream-monaco-diff-root .monaco-editor .fold-unchanged.stream-monaco-fold-unchanged-hidden {
2441
+ display: none !important;
2442
+ }
2141
2443
  .stream-monaco-diff-root .monaco-editor .fold-unchanged:hover,
2142
2444
  .stream-monaco-diff-root .monaco-editor .fold-unchanged.stream-monaco-focus-visible {
2143
2445
  opacity: 1 !important;
@@ -2235,6 +2537,8 @@ var DiffEditorManager = class DiffEditorManager {
2235
2537
  }
2236
2538
  capturePersistedDiffUnchangedState() {
2237
2539
  if (!this.diffEditorView) return;
2540
+ const hideUnchangedRegions = this.diffHideUnchangedRegionsResolved ?? this.resolveDiffHideUnchangedRegionsOption();
2541
+ if (!(hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled) || this.diffHideUnchangedRegionsDeferred) return;
2238
2542
  const state = this.diffEditorView.saveViewState();
2239
2543
  if (!(state === null || state === void 0 ? void 0 : state.modelState)) {
2240
2544
  this.diffPersistedUnchangedModelState = null;
@@ -2242,6 +2546,14 @@ var DiffEditorManager = class DiffEditorManager {
2242
2546
  }
2243
2547
  this.diffPersistedUnchangedModelState = this.cloneSerializableValue(state.modelState);
2244
2548
  }
2549
+ capturePreviousDiffUnchangedState() {
2550
+ if (!this.diffEditorView) return;
2551
+ const hideUnchangedRegions = this.diffHideUnchangedRegionsResolved ?? this.resolveDiffHideUnchangedRegionsOption();
2552
+ if (!(hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled) || this.diffHideUnchangedRegionsDeferred) return;
2553
+ const state = this.diffEditorView.saveViewState();
2554
+ if (!(state === null || state === void 0 ? void 0 : state.modelState)) return;
2555
+ this.diffPreviousUnchangedModelState = this.cloneSerializableValue(state.modelState);
2556
+ }
2245
2557
  scheduleCapturePersistedDiffUnchangedState(frames = 1) {
2246
2558
  this.rafScheduler.schedule("capture-diff-unchanged-state", () => {
2247
2559
  let remaining = Math.max(0, frames);
@@ -2267,6 +2579,20 @@ var DiffEditorManager = class DiffEditorManager {
2267
2579
  });
2268
2580
  this.applyPendingDiffScrollRestore();
2269
2581
  }
2582
+ restorePreviousDiffUnchangedState() {
2583
+ if (!this.diffEditorView || !this.diffPreviousUnchangedModelState) return false;
2584
+ const current = this.diffEditorView.saveViewState();
2585
+ if (!current) return false;
2586
+ const previous = this.cloneSerializableValue(this.diffPreviousUnchangedModelState);
2587
+ this.diffEditorView.restoreViewState({
2588
+ original: current.original,
2589
+ modified: current.modified,
2590
+ modelState: previous
2591
+ });
2592
+ this.diffPersistedUnchangedModelState = this.cloneSerializableValue(previous);
2593
+ this.applyPendingDiffScrollRestore();
2594
+ return true;
2595
+ }
2270
2596
  scheduleRestorePersistedDiffUnchangedState() {
2271
2597
  if (this.diffHideUnchangedRegionsDeferred) return;
2272
2598
  if (!this.diffPersistedUnchangedModelState) return;
@@ -2430,7 +2756,7 @@ var DiffEditorManager = class DiffEditorManager {
2430
2756
  readOnly: this.options.readOnly ?? true,
2431
2757
  lineDecorationsWidth: this.options.lineDecorationsWidth,
2432
2758
  lineNumbersMinChars: this.options.lineNumbersMinChars,
2433
- glyphMargin: this.options.glyphMargin,
2759
+ glyphMargin: this.resolveDiffGlyphMarginOption(hideUnchangedRegions),
2434
2760
  fontFamily: this.options.fontFamily,
2435
2761
  fontSize: this.options.fontSize,
2436
2762
  lineHeight: this.options.lineHeight,
@@ -2450,9 +2776,10 @@ var DiffEditorManager = class DiffEditorManager {
2450
2776
  };
2451
2777
  }
2452
2778
  refreshDiffPresentation() {
2453
- var _this$diffHeightManag;
2779
+ var _this$diffHideUnchang, _this$diffHeightManag;
2454
2780
  if (!this.diffEditorView) return;
2455
2781
  const hideUnchangedRegions = this.resolveDiffHideUnchangedRegionsOption();
2782
+ const shouldRecomputeDiffViewModelForUnchangedRegions = !this.diffHideUnchangedRegionsDeferred && (hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled) === true && ((_this$diffHideUnchang = this.diffHideUnchangedRegionsResolved) === null || _this$diffHideUnchang === void 0 ? void 0 : _this$diffHideUnchang.enabled) === false && !!this.originalModel && !!this.modifiedModel;
2456
2783
  const presentationOptions = this.resolveDiffPresentationEditorOptions(hideUnchangedRegions);
2457
2784
  this.diffHideUnchangedRegionsResolved = hideUnchangedRegions;
2458
2785
  this.diffUpdateThrottleMs = this.resolveDiffStreamingThrottleMs();
@@ -2462,13 +2789,20 @@ var DiffEditorManager = class DiffEditorManager {
2462
2789
  this.lastContainer.style.removeProperty("--stream-monaco-editor-fg");
2463
2790
  }
2464
2791
  this.withLockedDiffScrollPosition(() => {
2465
- var _this$diffEditorView13;
2466
- (_this$diffEditorView13 = this.diffEditorView) === null || _this$diffEditorView13 === void 0 || _this$diffEditorView13.updateOptions(presentationOptions);
2792
+ var _this$diffEditorView14;
2793
+ (_this$diffEditorView14 = this.diffEditorView) === null || _this$diffEditorView14 === void 0 || _this$diffEditorView14.updateOptions(presentationOptions);
2467
2794
  });
2468
2795
  (_this$diffHeightManag = this.diffHeightManager) === null || _this$diffHeightManag === void 0 || _this$diffHeightManag.update();
2469
2796
  this.applyDiffRootAppearanceClass();
2470
2797
  this.schedulePatchDiffUnchangedRegionsAfterInteraction(1);
2471
2798
  this.repositionDiffHunkNodes();
2799
+ if (shouldRecomputeDiffViewModelForUnchangedRegions) this.setDiffModels({
2800
+ original: this.originalModel,
2801
+ modified: this.modifiedModel
2802
+ }, {
2803
+ preserveViewState: true,
2804
+ preserveModelState: false
2805
+ });
2472
2806
  }
2473
2807
  restoreDeferredDiffUnchangedRegions() {
2474
2808
  this.clearDeferredDiffUnchangedRegionsIdleTimer();
@@ -2478,8 +2812,8 @@ var DiffEditorManager = class DiffEditorManager {
2478
2812
  if (!this.diffHideUnchangedRegionsDeferred) return;
2479
2813
  this.diffHideUnchangedRegionsDeferred = false;
2480
2814
  this.withLockedDiffScrollPosition(() => {
2481
- var _this$diffEditorView14;
2482
- (_this$diffEditorView14 = this.diffEditorView) === null || _this$diffEditorView14 === void 0 || _this$diffEditorView14.updateOptions({ hideUnchangedRegions });
2815
+ var _this$diffEditorView15;
2816
+ (_this$diffEditorView15 = this.diffEditorView) === null || _this$diffEditorView15 === void 0 || _this$diffEditorView15.updateOptions({ hideUnchangedRegions });
2483
2817
  });
2484
2818
  this.schedulePatchDiffUnchangedRegionsAfterInteraction(1);
2485
2819
  if (this.shouldAutoScrollDiff) {
@@ -2488,6 +2822,22 @@ var DiffEditorManager = class DiffEditorManager {
2488
2822
  }
2489
2823
  }
2490
2824
  markDiffStreamingActivity() {
2825
+ var _this$lastContainer6;
2826
+ (_this$lastContainer6 = this.lastContainer) === null || _this$lastContainer6 === void 0 || _this$lastContainer6.classList.remove("stream-monaco-diff-inline-native-ready");
2827
+ if (this.isDiffInlineMode()) {
2828
+ var _this$diffHeightManag2, _this$lastContainer7, _this$lastContainer7$;
2829
+ this.inlineDiffStreamingPresentationActive = true;
2830
+ 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);
2831
+ this.clearInlineDiffStreamingPresentationIdleTimer();
2832
+ this.inlineDiffStreamingPresentationIdleTimer = setTimeout(() => {
2833
+ var _this$diffHeightManag3;
2834
+ this.inlineDiffStreamingPresentationIdleTimer = null;
2835
+ this.inlineDiffStreamingPresentationActive = false;
2836
+ this.resetInlineDiffStreamingHeightFloor();
2837
+ this.scheduleSyncDiffPresentationDecorations();
2838
+ (_this$diffHeightManag3 = this.diffHeightManager) === null || _this$diffHeightManag3 === void 0 || _this$diffHeightManag3.update();
2839
+ }, 3e3);
2840
+ }
2491
2841
  const hideUnchangedRegions = this.diffHideUnchangedRegionsResolved;
2492
2842
  if (!this.diffEditorView || !(hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled)) return;
2493
2843
  this.clearDeferredDiffUnchangedRegionsIdleTimer();
@@ -2499,8 +2849,8 @@ var DiffEditorManager = class DiffEditorManager {
2499
2849
  this.diffHideUnchangedRegionsDeferred = true;
2500
2850
  this.hideAllDiffUnchangedBridgeEntries();
2501
2851
  this.withLockedDiffScrollPosition(() => {
2502
- var _this$diffEditorView15;
2503
- (_this$diffEditorView15 = this.diffEditorView) === null || _this$diffEditorView15 === void 0 || _this$diffEditorView15.updateOptions({ hideUnchangedRegions: {
2852
+ var _this$diffEditorView16;
2853
+ (_this$diffEditorView16 = this.diffEditorView) === null || _this$diffEditorView16 === void 0 || _this$diffEditorView16.updateOptions({ hideUnchangedRegions: {
2504
2854
  ...hideUnchangedRegions,
2505
2855
  enabled: false
2506
2856
  } });
@@ -2598,8 +2948,8 @@ var DiffEditorManager = class DiffEditorManager {
2598
2948
  return this.diffUnchangedBridgeOverlay;
2599
2949
  }
2600
2950
  readDiffUnchangedOverlayScrollState() {
2601
- var _this$diffEditorView16, _modifiedEditor$getSc6, _modifiedEditor$getSc7;
2602
- const modifiedEditor = (_this$diffEditorView16 = this.diffEditorView) === null || _this$diffEditorView16 === void 0 ? void 0 : _this$diffEditorView16.getModifiedEditor();
2951
+ var _this$diffEditorView17, _modifiedEditor$getSc6, _modifiedEditor$getSc7;
2952
+ const modifiedEditor = (_this$diffEditorView17 = this.diffEditorView) === null || _this$diffEditorView17 === void 0 ? void 0 : _this$diffEditorView17.getModifiedEditor();
2603
2953
  return {
2604
2954
  top: (modifiedEditor === null || modifiedEditor === void 0 || (_modifiedEditor$getSc6 = modifiedEditor.getScrollTop) === null || _modifiedEditor$getSc6 === void 0 ? void 0 : _modifiedEditor$getSc6.call(modifiedEditor)) ?? 0,
2605
2955
  left: (modifiedEditor === null || modifiedEditor === void 0 || (_modifiedEditor$getSc7 = modifiedEditor.getScrollLeft) === null || _modifiedEditor$getSc7 === void 0 ? void 0 : _modifiedEditor$getSc7.call(modifiedEditor)) ?? 0
@@ -2956,7 +3306,7 @@ var DiffEditorManager = class DiffEditorManager {
2956
3306
  this.scheduleCapturePersistedDiffUnchangedState(1);
2957
3307
  }
2958
3308
  resolveDiffUnchangedRevealLayout(primaryNode, countText, pairIndex, pairCount) {
2959
- var _this$diffEditorView17, _this$diffEditorView18;
3309
+ var _this$diffEditorView18, _this$diffEditorView19;
2960
3310
  let showTopHandle = pairCount === 1 || pairIndex > 0;
2961
3311
  let showBottomHandle = pairCount === 1 || pairIndex < pairCount - 1;
2962
3312
  const countMatch = countText.match(/\d+/);
@@ -2986,7 +3336,7 @@ var DiffEditorManager = class DiffEditorManager {
2986
3336
  showTopHandle = false;
2987
3337
  showBottomHandle = true;
2988
3338
  }
2989
- const modelLineCount = ((_this$diffEditorView17 = this.diffEditorView) === null || _this$diffEditorView17 === void 0 || (_this$diffEditorView17 = _this$diffEditorView17.getModifiedEditor().getModel()) === null || _this$diffEditorView17 === void 0 || (_this$diffEditorView18 = _this$diffEditorView17.getLineCount) === null || _this$diffEditorView18 === void 0 ? void 0 : _this$diffEditorView18.call(_this$diffEditorView17)) ?? null;
3339
+ 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;
2990
3340
  if (previousVisibleLine != null && modelLineCount != null && previousVisibleLine + hiddenCount === modelLineCount) {
2991
3341
  showTopHandle = true;
2992
3342
  showBottomHandle = false;
@@ -2997,13 +3347,13 @@ var DiffEditorManager = class DiffEditorManager {
2997
3347
  };
2998
3348
  }
2999
3349
  resolveDiffUnchangedMergeRole(node) {
3000
- var _this$diffEditorView19, _this$diffEditorView20, _this$diffEditorView21, _this$diffEditorView22, _this$diffEditorView23, _this$diffEditorView24;
3350
+ var _this$diffEditorView20, _this$diffEditorView21, _this$diffEditorView22, _this$diffEditorView23, _this$diffEditorView24, _this$diffEditorView25;
3001
3351
  const diffRoot = node.closest(".monaco-diff-editor.side-by-side");
3002
3352
  if (!(diffRoot instanceof HTMLElement)) return "none";
3003
3353
  const nodeRect = node.getBoundingClientRect();
3004
3354
  const nodeCenter = nodeRect.left + nodeRect.width / 2;
3005
- const originalHost = (_this$diffEditorView19 = this.diffEditorView) === null || _this$diffEditorView19 === void 0 || (_this$diffEditorView21 = (_this$diffEditorView20 = _this$diffEditorView19.getOriginalEditor()).getContainerDomNode) === null || _this$diffEditorView21 === void 0 ? void 0 : _this$diffEditorView21.call(_this$diffEditorView20);
3006
- const modifiedHost = (_this$diffEditorView22 = this.diffEditorView) === null || _this$diffEditorView22 === void 0 || (_this$diffEditorView24 = (_this$diffEditorView23 = _this$diffEditorView22.getModifiedEditor()).getContainerDomNode) === null || _this$diffEditorView24 === void 0 ? void 0 : _this$diffEditorView24.call(_this$diffEditorView23);
3355
+ 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);
3356
+ 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);
3007
3357
  if (originalHost instanceof HTMLElement && modifiedHost instanceof HTMLElement) {
3008
3358
  const originalRect = originalHost.getBoundingClientRect();
3009
3359
  const modifiedRect = modifiedHost.getBoundingClientRect();
@@ -3043,6 +3393,11 @@ var DiffEditorManager = class DiffEditorManager {
3043
3393
  action.tabIndex = shouldUseMergedSecondary ? -1 : 0;
3044
3394
  if (action.dataset.streamMonacoExpandPatched !== "true") {
3045
3395
  action.dataset.streamMonacoExpandPatched = "true";
3396
+ const handleCaptureExpand = () => {
3397
+ this.capturePreviousDiffUnchangedState();
3398
+ };
3399
+ action.addEventListener("click", handleCaptureExpand, { capture: true });
3400
+ this.diffUnchangedRegionDisposables.push({ dispose: () => action.removeEventListener("click", handleCaptureExpand, true) });
3046
3401
  this.createDomDisposable(this.diffUnchangedRegionDisposables, action, "click", () => {
3047
3402
  this.hideAllDiffUnchangedBridgeEntries();
3048
3403
  this.scheduleCapturePersistedDiffUnchangedState(1);
@@ -3055,7 +3410,10 @@ var DiffEditorManager = class DiffEditorManager {
3055
3410
  this.bindFocusWithinClass(this.diffUnchangedRegionDisposables, node, "stream-monaco-focus-within");
3056
3411
  const activate = () => {
3057
3412
  const action$1 = node.querySelector("a");
3058
- if (action$1 instanceof HTMLElement) action$1.click();
3413
+ if (action$1 instanceof HTMLElement) {
3414
+ this.capturePreviousDiffUnchangedState();
3415
+ action$1.click();
3416
+ }
3059
3417
  };
3060
3418
  this.createDomDisposable(this.diffUnchangedRegionDisposables, node, "click", (event) => {
3061
3419
  const mouseEvent = event;
@@ -3149,6 +3507,7 @@ var DiffEditorManager = class DiffEditorManager {
3149
3507
  entry.activate = () => {
3150
3508
  const action = primaryNode.querySelector("a, button") ?? secondaryNode.querySelector("a, button");
3151
3509
  if (action instanceof HTMLElement) {
3510
+ this.capturePreviousDiffUnchangedState();
3152
3511
  action.click();
3153
3512
  this.scheduleCapturePersistedDiffUnchangedState(1);
3154
3513
  }
@@ -3167,10 +3526,22 @@ var DiffEditorManager = class DiffEditorManager {
3167
3526
  node.title = node.title || "Collapse unchanged lines";
3168
3527
  this.bindFocusVisibleClass(this.diffUnchangedRegionDisposables, node);
3169
3528
  this.bindPersistOnMouseRelease(this.diffUnchangedRegionDisposables, node);
3529
+ this.createDomDisposable(this.diffUnchangedRegionDisposables, node, "mouseup", (event) => {
3530
+ const mouseEvent = event;
3531
+ if (mouseEvent.button !== 0) return;
3532
+ if (!this.restorePreviousDiffUnchangedState()) return;
3533
+ event.preventDefault();
3534
+ event.stopPropagation();
3535
+ this.schedulePatchDiffUnchangedRegionsAfterInteraction();
3536
+ });
3170
3537
  this.createDomDisposable(this.diffUnchangedRegionDisposables, node, "keydown", (event) => {
3171
3538
  const keyboardEvent = event;
3172
3539
  if (keyboardEvent.key !== "Enter" && keyboardEvent.key !== " ") return;
3173
3540
  keyboardEvent.preventDefault();
3541
+ if (this.restorePreviousDiffUnchangedState()) {
3542
+ this.schedulePatchDiffUnchangedRegionsAfterInteraction();
3543
+ return;
3544
+ }
3174
3545
  this.dispatchSyntheticMouseDown(node);
3175
3546
  this.scheduleCapturePersistedDiffUnchangedState(1);
3176
3547
  });
@@ -3180,6 +3551,11 @@ var DiffEditorManager = class DiffEditorManager {
3180
3551
  this.applyDiffRootAppearanceClass();
3181
3552
  const viewZoneHeightsChanged = this.syncDiffUnchangedViewZoneHeights();
3182
3553
  const centers = this.lastContainer.querySelectorAll(".diff-hidden-lines .center");
3554
+ const modifiedHiddenSummaryMidpoints = Array.from(this.lastContainer.querySelectorAll(".editor.modified .diff-hidden-lines .center")).map((node) => {
3555
+ const rect = node.getBoundingClientRect();
3556
+ if (rect.width <= 0 || rect.height <= 0) return null;
3557
+ return rect.top + rect.height / 2;
3558
+ }).filter((value) => value !== null);
3183
3559
  Array.from(centers).sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top).forEach((node, index) => this.patchDiffUnchangedCenter(node, index));
3184
3560
  const partialRevealHandles = this.lastContainer.querySelectorAll(".diff-hidden-lines .top, .diff-hidden-lines .bottom");
3185
3561
  partialRevealHandles.forEach((node) => {
@@ -3204,7 +3580,13 @@ var DiffEditorManager = class DiffEditorManager {
3204
3580
  this.pruneDiffUnchangedBridgeEntries(visibleKeys);
3205
3581
  this.syncDiffUnchangedOverlayScrollBaseline();
3206
3582
  const foldGlyphs = this.lastContainer.querySelectorAll(".fold-unchanged");
3207
- foldGlyphs.forEach((node) => this.patchDiffUnchangedFoldGlyph(node));
3583
+ foldGlyphs.forEach((node) => {
3584
+ const rect = node.getBoundingClientRect();
3585
+ const midpoint = rect.top + rect.height / 2;
3586
+ const overlapsHiddenSummary = modifiedHiddenSummaryMidpoints.some((summaryMidpoint) => Math.abs(summaryMidpoint - midpoint) <= 8);
3587
+ node.classList.toggle("stream-monaco-fold-unchanged-hidden", overlapsHiddenSummary);
3588
+ this.patchDiffUnchangedFoldGlyph(node);
3589
+ });
3208
3590
  if (viewZoneHeightsChanged) this.schedulePatchDiffUnchangedRegions();
3209
3591
  }
3210
3592
  schedulePatchDiffUnchangedRegions() {
@@ -3217,12 +3599,12 @@ var DiffEditorManager = class DiffEditorManager {
3217
3599
  this.schedulePatchDiffUnchangedRegions();
3218
3600
  }
3219
3601
  setupDiffUnchangedRegionEnhancements() {
3220
- var _globalThis$getComput, _globalThis;
3602
+ var _globalThis$getComput2, _globalThis2;
3221
3603
  this.disposeDiffUnchangedRegionEnhancements();
3222
3604
  if (!this.diffEditorView || !this.lastContainer) return;
3223
3605
  if (typeof document === "undefined") return;
3224
3606
  this.ensureDiffUiStyle();
3225
- const containerStyle = (_globalThis$getComput = (_globalThis = globalThis).getComputedStyle) === null || _globalThis$getComput === void 0 ? void 0 : _globalThis$getComput.call(_globalThis, this.lastContainer);
3607
+ const containerStyle = (_globalThis$getComput2 = (_globalThis2 = globalThis).getComputedStyle) === null || _globalThis$getComput2 === void 0 ? void 0 : _globalThis$getComput2.call(_globalThis2, this.lastContainer);
3226
3608
  if (!containerStyle || containerStyle.position === "static") this.lastContainer.style.position = "relative";
3227
3609
  this.applyDiffRootAppearanceClass();
3228
3610
  this.schedulePatchDiffUnchangedRegions();
@@ -3250,6 +3632,20 @@ var DiffEditorManager = class DiffEditorManager {
3250
3632
  this.applyDiffRootAppearanceClass();
3251
3633
  this.schedulePatchDiffUnchangedRegions();
3252
3634
  };
3635
+ const handleFoldMouseUp = (event) => {
3636
+ var _event$event, _event$target, _event$event2, _event$event2$prevent, _event$event3, _event$event3$stopPro;
3637
+ if (event === null || event === void 0 || (_event$event = event.event) === null || _event$event === void 0 ? void 0 : _event$event.rightButton) return;
3638
+ const targetElement = event === null || event === void 0 || (_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.element;
3639
+ const className = typeof (targetElement === null || targetElement === void 0 ? void 0 : targetElement.className) === "string" ? targetElement.className : "";
3640
+ if (!className.includes("fold-unchanged")) return;
3641
+ if (!this.diffPreviousUnchangedModelState) return;
3642
+ 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);
3643
+ 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);
3644
+ requestAnimationFrame(() => {
3645
+ if (!this.restorePreviousDiffUnchangedState()) return;
3646
+ this.schedulePatchDiffUnchangedRegionsAfterInteraction();
3647
+ });
3648
+ };
3253
3649
  this.diffUnchangedRegionDisposables.push(this.diffEditorView.onDidUpdateDiff(() => {
3254
3650
  repatch();
3255
3651
  this.scheduleRestorePersistedDiffUnchangedState();
@@ -3258,16 +3654,18 @@ var DiffEditorManager = class DiffEditorManager {
3258
3654
  this.diffUnchangedRegionDisposables.push(modifiedEditor.onDidLayoutChange(repatch));
3259
3655
  this.diffUnchangedRegionDisposables.push(originalEditor.onDidScrollChange(() => this.schedulePatchDiffUnchangedRegionsAfterScroll()));
3260
3656
  this.diffUnchangedRegionDisposables.push(modifiedEditor.onDidScrollChange(() => this.schedulePatchDiffUnchangedRegionsAfterScroll()));
3657
+ this.diffUnchangedRegionDisposables.push(originalEditor.onMouseUp(handleFoldMouseUp));
3658
+ this.diffUnchangedRegionDisposables.push(modifiedEditor.onMouseUp(handleFoldMouseUp));
3261
3659
  this.createDomDisposable(this.diffUnchangedRegionDisposables, this.lastContainer, "scroll", () => this.schedulePatchDiffUnchangedRegionsAfterScroll());
3262
3660
  }
3263
3661
  setupDiffHunkInteractions() {
3264
- var _globalThis$getComput2, _globalThis2;
3662
+ var _globalThis$getComput3, _globalThis3;
3265
3663
  this.disposeDiffHunkInteractions();
3266
3664
  if (!this.diffEditorView || !this.lastContainer) return;
3267
3665
  if (this.options.diffHunkActionsOnHover !== true) return;
3268
3666
  if (typeof document === "undefined") return;
3269
3667
  this.ensureDiffUiStyle();
3270
- const containerStyle = (_globalThis$getComput2 = (_globalThis2 = globalThis).getComputedStyle) === null || _globalThis$getComput2 === void 0 ? void 0 : _globalThis$getComput2.call(_globalThis2, this.lastContainer);
3668
+ const containerStyle = (_globalThis$getComput3 = (_globalThis3 = globalThis).getComputedStyle) === null || _globalThis$getComput3 === void 0 ? void 0 : _globalThis$getComput3.call(_globalThis3, this.lastContainer);
3271
3669
  if (!containerStyle || containerStyle.position === "static") this.lastContainer.style.position = "relative";
3272
3670
  const overlay = document.createElement("div");
3273
3671
  overlay.className = "stream-monaco-diff-hunk-overlay";
@@ -3385,9 +3783,9 @@ var DiffEditorManager = class DiffEditorManager {
3385
3783
  return !info || info.width < 24;
3386
3784
  }
3387
3785
  isDiffInlineMode() {
3388
- var _this$lastContainer2;
3389
- const diffRoot = (_this$lastContainer2 = this.lastContainer) === null || _this$lastContainer2 === void 0 ? void 0 : _this$lastContainer2.querySelector(".monaco-diff-editor");
3390
- if (diffRoot instanceof HTMLElement) return !diffRoot.classList.contains("side-by-side");
3786
+ var _this$lastContainer8, _this$lastContainer9;
3787
+ 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;
3788
+ if (typeof HTMLElement !== "undefined" && diffRoot instanceof HTMLElement) return !diffRoot.classList.contains("side-by-side");
3391
3789
  return this.isOriginalEditorCollapsed();
3392
3790
  }
3393
3791
  getEditorBySide(side) {
@@ -3435,8 +3833,8 @@ var DiffEditorManager = class DiffEditorManager {
3435
3833
  if (!this.diffEditorView || !viewState) return;
3436
3834
  const restore = () => {
3437
3835
  try {
3438
- var _this$diffEditorView25;
3439
- (_this$diffEditorView25 = this.diffEditorView) === null || _this$diffEditorView25 === void 0 || _this$diffEditorView25.restoreViewState(viewState);
3836
+ var _this$diffEditorView26;
3837
+ (_this$diffEditorView26 = this.diffEditorView) === null || _this$diffEditorView26 === void 0 || _this$diffEditorView26.restoreViewState(viewState);
3440
3838
  } catch {}
3441
3839
  };
3442
3840
  restore();
@@ -3454,7 +3852,7 @@ var DiffEditorManager = class DiffEditorManager {
3454
3852
  this.pendingPreparedDiffViewModel = null;
3455
3853
  }
3456
3854
  syncDiffKnownValues() {
3457
- var _this$diffEditorView26, _this$diffEditorView27, _this$diffEditorView28, _this$diffHeightManag2;
3855
+ var _this$diffEditorView27, _this$diffEditorView28, _this$diffEditorView29, _this$diffHeightManag4;
3458
3856
  if (this.originalModel) this.lastKnownOriginalCode = this.originalModel.getValue();
3459
3857
  if (this.modifiedModel) {
3460
3858
  this.lastKnownModifiedCode = this.modifiedModel.getValue();
@@ -3463,8 +3861,8 @@ var DiffEditorManager = class DiffEditorManager {
3463
3861
  this.lastKnownModifiedDirty = false;
3464
3862
  this._hasScrollBar = false;
3465
3863
  this.cachedComputedHeightDiff = this.computedHeight();
3466
- 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;
3467
- (_this$diffHeightManag2 = this.diffHeightManager) === null || _this$diffHeightManag2 === void 0 || _this$diffHeightManag2.update();
3864
+ 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;
3865
+ (_this$diffHeightManag4 = this.diffHeightManager) === null || _this$diffHeightManag4 === void 0 || _this$diffHeightManag4.update();
3468
3866
  }
3469
3867
  applyDefaultDiffHunkAction(context) {
3470
3868
  const { action, side, lineChange } = context;
@@ -3648,24 +4046,49 @@ var DiffEditorManager = class DiffEditorManager {
3648
4046
  this.preserveNativeDiffDecorationsOnStaleAppend = true;
3649
4047
  this.appendToModel(this.originalModel, text);
3650
4048
  }
3651
- computedHeight() {
3652
- var _originalEditor$getMo, _modifiedEditor$getMo, _originalEditor$getSc5, _modifiedEditor$getSc10;
4049
+ computeRawHeight() {
4050
+ var _originalEditor$getMo, _modifiedEditor$getMo2, _originalEditor$getSc5, _modifiedEditor$getSc10;
3653
4051
  if (!this.diffEditorView) return Math.min(1 * 18 + padding, this.maxHeightValue);
3654
4052
  const modifiedEditor = this.diffEditorView.getModifiedEditor();
3655
4053
  const originalEditor = this.diffEditorView.getOriginalEditor();
3656
4054
  const lineHeight = modifiedEditor.getOption(monaco_shim_exports.editor.EditorOption.lineHeight);
3657
4055
  const oCount = ((_originalEditor$getMo = originalEditor.getModel()) === null || _originalEditor$getMo === void 0 ? void 0 : _originalEditor$getMo.getLineCount()) ?? 1;
3658
- const mCount = ((_modifiedEditor$getMo = modifiedEditor.getModel()) === null || _modifiedEditor$getMo === void 0 ? void 0 : _modifiedEditor$getMo.getLineCount()) ?? 1;
4056
+ const mCount = ((_modifiedEditor$getMo2 = modifiedEditor.getModel()) === null || _modifiedEditor$getMo2 === void 0 ? void 0 : _modifiedEditor$getMo2.getLineCount()) ?? 1;
3659
4057
  const lineCount = Math.max(oCount, mCount);
3660
4058
  const fromLines = lineCount * lineHeight + padding;
3661
4059
  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);
3662
4060
  const desired = Math.max(fromLines, scrollH);
3663
4061
  return Math.min(desired, this.maxHeightValue);
3664
4062
  }
4063
+ computedHeight() {
4064
+ const rawHeight = this.computeRawHeight();
4065
+ if (!this.isDiffInlineMode()) return rawHeight;
4066
+ if (!this.inlineDiffStreamingPresentationActive && this.inlineDiffStreamingHeightFloor <= 0) return rawHeight;
4067
+ const lockedHeight = Math.max(rawHeight, this.inlineDiffStreamingHeightFloor);
4068
+ this.inlineDiffStreamingHeightFloor = lockedHeight;
4069
+ return lockedHeight;
4070
+ }
4071
+ eagerlyGrowDiffContainerHeight() {
4072
+ var _this$lastContainer$g, _this$lastContainer10;
4073
+ if (!this.lastContainer) return;
4074
+ const next = this.computedHeight();
4075
+ if (!Number.isFinite(next) || next <= 0) return;
4076
+ const applied = Number.parseFloat(this.lastContainer.style.height || "0") || 0;
4077
+ 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;
4078
+ const baseline = Math.max(applied, measured);
4079
+ if (next <= baseline + 1) return;
4080
+ this.lastContainer.style.height = `${next}px`;
4081
+ this.cachedComputedHeightDiff = next;
4082
+ this.scheduleSyncDiffEditorLayoutToContainer();
4083
+ }
3665
4084
  isOverflowAutoDiff() {
3666
4085
  if (!this.lastContainer) return false;
3667
4086
  return this.computedHeight() >= this.maxHeightValue - 1;
3668
4087
  }
4088
+ shouldAvoidOptimisticMaxHeightWriteDiff() {
4089
+ const hideUnchangedRegions = this.diffHideUnchangedRegionsResolved;
4090
+ return this.isDiffInlineMode() && (hideUnchangedRegions === null || hideUnchangedRegions === void 0 ? void 0 : hideUnchangedRegions.enabled) === true && !this.diffHideUnchangedRegionsDeferred;
4091
+ }
3669
4092
  shouldPerformImmediateRevealDiff() {
3670
4093
  return this.autoScrollOnUpdate && this.shouldAutoScrollDiff && !this.diffHideUnchangedRegionsDeferred && this.hasVerticalScrollbarModified() && this.isOverflowAutoDiff();
3671
4094
  }
@@ -3810,8 +4233,8 @@ var DiffEditorManager = class DiffEditorManager {
3810
4233
  lastRevealLineDiff: this.lastRevealLineDiff
3811
4234
  });
3812
4235
  try {
3813
- var _this$diffEditorView29, _this$diffEditorView30, _this$diffEditorView31;
3814
- 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;
4236
+ var _this$diffEditorView30, _this$diffEditorView31, _this$diffEditorView32;
4237
+ 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;
3815
4238
  } catch {}
3816
4239
  });
3817
4240
  }
@@ -3837,6 +4260,7 @@ var DiffEditorManager = class DiffEditorManager {
3837
4260
  if (target !== -1 && this.diffHeightManager) {
3838
4261
  if (this.lastContainer) this.lastContainer.style.height = `${target}px`;
3839
4262
  await this.waitForHeightAppliedDiff(target);
4263
+ this.syncDiffEditorLayoutToContainer();
3840
4264
  }
3841
4265
  this.performImmediateRevealDiff(line, ticket);
3842
4266
  });
@@ -3860,11 +4284,19 @@ var DiffEditorManager = class DiffEditorManager {
3860
4284
  });
3861
4285
  }
3862
4286
  async createDiffEditor(container, originalCode, modifiedCode, language, currentTheme) {
3863
- var _me$getScrollHeight2, _me$getOption, _oEditor$onDidContent, _mEditor$onDidContent;
4287
+ var _me$getScrollHeight2, _me$getOption, _oEditor$onDidLayoutC, _mEditor$onDidLayoutC, _oEditor$onDidContent, _mEditor$onDidContent;
3864
4288
  this.cleanup();
3865
4289
  this.lastContainer = container;
3866
4290
  container.style.overflow = "hidden";
3867
4291
  container.style.maxHeight = this.maxHeightCSS;
4292
+ container.innerHTML = "";
4293
+ const editorMount = typeof document !== "undefined" ? document.createElement("div") : container;
4294
+ if (editorMount !== container) {
4295
+ editorMount.style.width = "100%";
4296
+ editorMount.style.height = "100%";
4297
+ editorMount.style.overflow = "hidden";
4298
+ container.append(editorMount);
4299
+ }
3868
4300
  const lang = processedLanguage(language) || language;
3869
4301
  this.originalModel = monaco_shim_exports.editor.createModel(originalCode, lang);
3870
4302
  this.modifiedModel = monaco_shim_exports.editor.createModel(modifiedCode, lang);
@@ -3873,7 +4305,7 @@ var DiffEditorManager = class DiffEditorManager {
3873
4305
  const hideUnchangedRegions = this.resolveDiffHideUnchangedRegionsOption();
3874
4306
  this.diffHideUnchangedRegionsResolved = hideUnchangedRegions;
3875
4307
  this.diffHideUnchangedRegionsDeferred = false;
3876
- this.diffEditorView = monaco_shim_exports.editor.createDiffEditor(container, {
4308
+ this.diffEditorView = monaco_shim_exports.editor.createDiffEditor(editorMount, {
3877
4309
  automaticLayout: true,
3878
4310
  scrollBeyondLastLine: false,
3879
4311
  renderSideBySide: true,
@@ -3887,6 +4319,7 @@ var DiffEditorManager = class DiffEditorManager {
3887
4319
  ...this.options.scrollbar || {}
3888
4320
  },
3889
4321
  ...this.options,
4322
+ glyphMargin: this.resolveDiffGlyphMarginOption(hideUnchangedRegions),
3890
4323
  hideUnchangedRegions
3891
4324
  });
3892
4325
  monaco_shim_exports.editor.setTheme(currentTheme);
@@ -3923,8 +4356,10 @@ var DiffEditorManager = class DiffEditorManager {
3923
4356
  autoScrollInitial: this.autoScrollInitial,
3924
4357
  diffAutoScroll: this.diffAutoScroll
3925
4358
  });
3926
- const MIN_VISIBLE_HEIGHT = Math.min(120, this.maxHeightValue);
3927
- container.style.minHeight = `${MIN_VISIBLE_HEIGHT}px`;
4359
+ const minVisibleHeight = this.shouldDeferTailAppendForInlineStreaming() ? 0 : Math.min(120, this.maxHeightValue);
4360
+ if (minVisibleHeight > 0) container.style.minHeight = `${minVisibleHeight}px`;
4361
+ else if (typeof container.style.removeProperty === "function") container.style.removeProperty("min-height");
4362
+ else delete container.style.minHeight;
3928
4363
  if (this.diffHeightManager) {
3929
4364
  this.diffHeightManager.dispose();
3930
4365
  this.diffHeightManager = null;
@@ -3943,6 +4378,7 @@ var DiffEditorManager = class DiffEditorManager {
3943
4378
  this.diffComputedVersions = null;
3944
4379
  this.diffPresentationDisposables.push(this.diffEditorView.onDidUpdateDiff(() => {
3945
4380
  this.diffComputedVersions = this.captureCurrentDiffVersions();
4381
+ this.syncDiffEditorLayoutToContainer();
3946
4382
  this.scheduleSyncDiffPresentationDecorations();
3947
4383
  }));
3948
4384
  this.diffPresentationDisposables.push(oEditor.onDidChangeModelContent(() => {
@@ -3951,16 +4387,46 @@ var DiffEditorManager = class DiffEditorManager {
3951
4387
  this.diffPresentationDisposables.push(mEditor.onDidChangeModelContent(() => {
3952
4388
  this.scheduleSyncDiffPresentationDecorations();
3953
4389
  }));
4390
+ const originalLayoutDisposable = (_oEditor$onDidLayoutC = oEditor.onDidLayoutChange) === null || _oEditor$onDidLayoutC === void 0 ? void 0 : _oEditor$onDidLayoutC.call(oEditor, () => {
4391
+ this.scheduleSyncDiffPresentationDecorations();
4392
+ });
4393
+ if (originalLayoutDisposable) this.diffPresentationDisposables.push(originalLayoutDisposable);
4394
+ const modifiedLayoutDisposable = (_mEditor$onDidLayoutC = mEditor.onDidLayoutChange) === null || _mEditor$onDidLayoutC === void 0 ? void 0 : _mEditor$onDidLayoutC.call(mEditor, () => {
4395
+ this.scheduleSyncDiffPresentationDecorations();
4396
+ });
4397
+ if (modifiedLayoutDisposable) this.diffPresentationDisposables.push(modifiedLayoutDisposable);
4398
+ if (typeof MutationObserver !== "undefined" && this.lastContainer) {
4399
+ this.diffPresentationObserver = new MutationObserver((mutations) => {
4400
+ const shouldSync = mutations.some((mutation) => {
4401
+ if (mutation.type !== "childList") return false;
4402
+ const nodes = Array.from(mutation.addedNodes).concat(Array.from(mutation.removedNodes));
4403
+ return nodes.some((node) => {
4404
+ if (!(node instanceof HTMLElement)) return false;
4405
+ 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");
4406
+ });
4407
+ });
4408
+ if (shouldSync) this.scheduleSyncDiffPresentationDecorations();
4409
+ });
4410
+ this.diffPresentationObserver.observe(this.lastContainer, {
4411
+ childList: true,
4412
+ subtree: true
4413
+ });
4414
+ }
3954
4415
  (_oEditor$onDidContent = oEditor.onDidContentSizeChange) === null || _oEditor$onDidContent === void 0 || _oEditor$onDidContent.call(oEditor, () => {
3955
4416
  this._hasScrollBar = false;
3956
4417
  this.rafScheduler.schedule("content-size-change-diff", () => {
3957
- var _oEditor$getScrollHei, _oEditor$getOption, _this$diffHeightManag3, _this$diffHeightManag4;
4418
+ var _oEditor$getScrollHei, _oEditor$getOption, _this$diffHeightManag5, _this$diffHeightManag6;
3958
4419
  this.cachedScrollHeightDiff = ((_oEditor$getScrollHei = oEditor.getScrollHeight) === null || _oEditor$getScrollHei === void 0 ? void 0 : _oEditor$getScrollHei.call(oEditor)) ?? this.cachedScrollHeightDiff;
3959
4420
  this.cachedLineHeightDiff = ((_oEditor$getOption = oEditor.getOption) === null || _oEditor$getOption === void 0 ? void 0 : _oEditor$getOption.call(oEditor, monaco_shim_exports.editor.EditorOption.lineHeight)) ?? this.cachedLineHeightDiff;
3960
4421
  this.cachedComputedHeightDiff = this.computedHeight();
3961
- if ((_this$diffHeightManag3 = this.diffHeightManager) === null || _this$diffHeightManag3 === void 0 ? void 0 : _this$diffHeightManag3.isSuppressed()) return;
3962
- (_this$diffHeightManag4 = this.diffHeightManager) === null || _this$diffHeightManag4 === void 0 || _this$diffHeightManag4.update();
3963
- const computed$2 = this.computedHeight();
4422
+ if (this.lastContainer) {
4423
+ const applied = Number.parseFloat(this.lastContainer.style.height || "0") || 0;
4424
+ if (this.cachedComputedHeightDiff > applied + 1 && (this.cachedComputedHeightDiff < this.maxHeightValue - 1 || !this.shouldAvoidOptimisticMaxHeightWriteDiff())) this.lastContainer.style.height = `${this.cachedComputedHeightDiff}px`;
4425
+ }
4426
+ if ((_this$diffHeightManag5 = this.diffHeightManager) === null || _this$diffHeightManag5 === void 0 ? void 0 : _this$diffHeightManag5.isSuppressed()) return;
4427
+ (_this$diffHeightManag6 = this.diffHeightManager) === null || _this$diffHeightManag6 === void 0 || _this$diffHeightManag6.update();
4428
+ this.scheduleSyncDiffEditorLayoutToContainer();
4429
+ const computed$2 = this.cachedComputedHeightDiff;
3964
4430
  if (this.lastContainer) {
3965
4431
  this.lastContainer.style.overflow = "hidden";
3966
4432
  if (computed$2 >= this.maxHeightValue - 1 && this.shouldAutoScrollDiff && !this.diffHideUnchangedRegionsDeferred) {
@@ -3973,13 +4439,18 @@ var DiffEditorManager = class DiffEditorManager {
3973
4439
  (_mEditor$onDidContent = mEditor.onDidContentSizeChange) === null || _mEditor$onDidContent === void 0 || _mEditor$onDidContent.call(mEditor, () => {
3974
4440
  this._hasScrollBar = false;
3975
4441
  this.rafScheduler.schedule("content-size-change-diff", () => {
3976
- var _mEditor$getScrollHei, _mEditor$getOption, _this$diffHeightManag5, _this$diffHeightManag6;
4442
+ var _mEditor$getScrollHei, _mEditor$getOption, _this$diffHeightManag7, _this$diffHeightManag8;
3977
4443
  this.cachedScrollHeightDiff = ((_mEditor$getScrollHei = mEditor.getScrollHeight) === null || _mEditor$getScrollHei === void 0 ? void 0 : _mEditor$getScrollHei.call(mEditor)) ?? this.cachedScrollHeightDiff;
3978
4444
  this.cachedLineHeightDiff = ((_mEditor$getOption = mEditor.getOption) === null || _mEditor$getOption === void 0 ? void 0 : _mEditor$getOption.call(mEditor, monaco_shim_exports.editor.EditorOption.lineHeight)) ?? this.cachedLineHeightDiff;
3979
4445
  this.cachedComputedHeightDiff = this.computedHeight();
3980
- if ((_this$diffHeightManag5 = this.diffHeightManager) === null || _this$diffHeightManag5 === void 0 ? void 0 : _this$diffHeightManag5.isSuppressed()) return;
3981
- (_this$diffHeightManag6 = this.diffHeightManager) === null || _this$diffHeightManag6 === void 0 || _this$diffHeightManag6.update();
3982
- const computed$2 = this.computedHeight();
4446
+ if (this.lastContainer) {
4447
+ const applied = Number.parseFloat(this.lastContainer.style.height || "0") || 0;
4448
+ if (this.cachedComputedHeightDiff > applied + 1 && (this.cachedComputedHeightDiff < this.maxHeightValue - 1 || !this.shouldAvoidOptimisticMaxHeightWriteDiff())) this.lastContainer.style.height = `${this.cachedComputedHeightDiff}px`;
4449
+ }
4450
+ if ((_this$diffHeightManag7 = this.diffHeightManager) === null || _this$diffHeightManag7 === void 0 ? void 0 : _this$diffHeightManag7.isSuppressed()) return;
4451
+ (_this$diffHeightManag8 = this.diffHeightManager) === null || _this$diffHeightManag8 === void 0 || _this$diffHeightManag8.update();
4452
+ this.scheduleSyncDiffEditorLayoutToContainer();
4453
+ const computed$2 = this.cachedComputedHeightDiff;
3983
4454
  if (this.lastContainer) {
3984
4455
  this.lastContainer.style.overflow = "hidden";
3985
4456
  if (computed$2 >= this.maxHeightValue - 1 && this.shouldAutoScrollDiff && !this.diffHideUnchangedRegionsDeferred) {
@@ -4020,13 +4491,14 @@ var DiffEditorManager = class DiffEditorManager {
4020
4491
  const modifiedTailAppend = modifiedCode !== prevM && modifiedCode.startsWith(prevM) && prevM.length < modifiedCode.length;
4021
4492
  const hasContentChange = originalCode !== prevO || modifiedCode !== prevM;
4022
4493
  if (originalCode !== prevO || modifiedCode !== prevM) this.markDiffStreamingActivity();
4494
+ const deferTailAppendForInline = this.shouldDeferTailAppendForInlineStreaming();
4023
4495
  let didImmediate = false;
4024
- if (originalTailAppend) {
4496
+ if (originalTailAppend && !deferTailAppendForInline) {
4025
4497
  this.appendOriginal(originalCode.slice(prevO.length));
4026
4498
  this.lastKnownOriginalCode = originalCode;
4027
4499
  didImmediate = true;
4028
4500
  }
4029
- if (modifiedTailAppend) {
4501
+ if (modifiedTailAppend && !deferTailAppendForInline) {
4030
4502
  this.appendModified(modifiedCode.slice(prevM.length));
4031
4503
  this.lastKnownModifiedCode = modifiedCode;
4032
4504
  didImmediate = true;
@@ -4040,6 +4512,16 @@ var DiffEditorManager = class DiffEditorManager {
4040
4512
  this.rafScheduler.schedule("diff", () => this.flushPendingDiffUpdate());
4041
4513
  } else if (didImmediate) {}
4042
4514
  }
4515
+ shouldDeferTailAppendForInlineStreaming() {
4516
+ var _this$lastContainer11, _this$lastContainer12, _this$lastContainer13;
4517
+ const renderSideBySide = this.options.renderSideBySide ?? true;
4518
+ if (renderSideBySide === false) return true;
4519
+ const useInlineViewWhenSpaceIsLimited = this.options.useInlineViewWhenSpaceIsLimited ?? true;
4520
+ if (!useInlineViewWhenSpaceIsLimited) return false;
4521
+ const breakpoint = this.options.renderSideBySideInlineBreakpoint ?? 900;
4522
+ 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;
4523
+ return width > 0 && width <= breakpoint;
4524
+ }
4043
4525
  updateOriginal(newCode, codeLanguage) {
4044
4526
  if (!this.diffEditorView || !this.originalModel) return;
4045
4527
  if (codeLanguage) {
@@ -4077,10 +4559,11 @@ var DiffEditorManager = class DiffEditorManager {
4077
4559
  this.applyMinimalEditToModel(this.modifiedModel, prevAfterFlush, newCode);
4078
4560
  const newLine = this.modifiedModel.getLineCount();
4079
4561
  if (newLine !== prevLine) {
4562
+ this.eagerlyGrowDiffContainerHeight();
4080
4563
  const shouldImmediate = this.shouldPerformImmediateRevealDiff();
4081
4564
  if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
4082
4565
  const computed$2 = this.computedHeight();
4083
- if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) {
4566
+ if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer && !this.shouldAvoidOptimisticMaxHeightWriteDiff()) {
4084
4567
  this.lastContainer.style.height = `${this.maxHeightValue}px`;
4085
4568
  this.lastContainer.style.overflow = "hidden";
4086
4569
  }
@@ -4179,14 +4662,15 @@ var DiffEditorManager = class DiffEditorManager {
4179
4662
  const currentOriginal = this.originalModel;
4180
4663
  const currentModified = this.modifiedModel;
4181
4664
  const shouldRestorePersistedUnchangedState = preserveViewState && !sameContent;
4665
+ const shouldRestoreSavedModelState = options.preserveModelState ?? true;
4182
4666
  const preservedScrollPosition = preserveViewState ? this.captureDiffScrollPosition() : null;
4183
4667
  const preservedViewportAnchor = preserveViewState && sameContent ? this.captureModifiedViewportAnchor() : null;
4184
- const viewState = preserveViewState ? this.diffEditorView.saveViewState() : null;
4668
+ const viewState = preserveViewState && shouldRestoreSavedModelState ? this.diffEditorView.saveViewState() : null;
4185
4669
  this.queuePendingDiffScrollRestore(preservedScrollPosition, shouldRestorePersistedUnchangedState ? 2 : 0);
4186
4670
  if (shouldRestorePersistedUnchangedState) this.capturePersistedDiffUnchangedState();
4187
4671
  const applyModelSwap = () => {
4188
- var _this$diffEditorView32;
4189
- (_this$diffEditorView32 = this.diffEditorView) === null || _this$diffEditorView32 === void 0 || _this$diffEditorView32.setModel(nextModelTarget);
4672
+ var _this$diffEditorView33;
4673
+ (_this$diffEditorView33 = this.diffEditorView) === null || _this$diffEditorView33 === void 0 || _this$diffEditorView33.setModel(nextModelTarget);
4190
4674
  };
4191
4675
  if (preserveViewState) this.withLockedDiffScrollPosition(applyModelSwap);
4192
4676
  else applyModelSwap();
@@ -4265,6 +4749,7 @@ var DiffEditorManager = class DiffEditorManager {
4265
4749
  this.revealTicketDiff = 0;
4266
4750
  this.lastRevealLineDiff = null;
4267
4751
  this.diffPersistedUnchangedModelState = null;
4752
+ this.diffPreviousUnchangedModelState = null;
4268
4753
  this.pendingDiffScrollRestorePosition = null;
4269
4754
  this.pendingDiffScrollRestoreBudget = 0;
4270
4755
  this.diffHideUnchangedRegionsResolved = null;
@@ -4292,7 +4777,11 @@ var DiffEditorManager = class DiffEditorManager {
4292
4777
  this.revealTicketDiff = 0;
4293
4778
  this.lastRevealLineDiff = null;
4294
4779
  this.diffPersistedUnchangedModelState = null;
4780
+ this.diffPreviousUnchangedModelState = null;
4295
4781
  this.diffHideUnchangedRegionsDeferred = false;
4782
+ this.clearInlineDiffStreamingPresentationIdleTimer();
4783
+ this.inlineDiffStreamingPresentationActive = false;
4784
+ this.resetInlineDiffStreamingHeightFloor();
4296
4785
  }
4297
4786
  syncLastKnownModified() {
4298
4787
  if (!this.diffEditorView || !this.lastKnownModifiedDirty) return;
@@ -4348,10 +4837,11 @@ var DiffEditorManager = class DiffEditorManager {
4348
4837
  this.lastKnownModifiedCode = modified;
4349
4838
  const newMLineCount = m.getLineCount();
4350
4839
  if (newMLineCount !== prevMLineCount) {
4840
+ this.eagerlyGrowDiffContainerHeight();
4351
4841
  const shouldImmediate = this.shouldPerformImmediateRevealDiff();
4352
4842
  if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
4353
4843
  const computed$2 = this.computedHeight();
4354
- if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) {
4844
+ if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer && !this.shouldAvoidOptimisticMaxHeightWriteDiff()) {
4355
4845
  this.lastContainer.style.height = `${this.maxHeightValue}px`;
4356
4846
  this.lastContainer.style.overflow = "hidden";
4357
4847
  }
@@ -4441,6 +4931,7 @@ var DiffEditorManager = class DiffEditorManager {
4441
4931
  const newLine$1 = model.getLineCount();
4442
4932
  this.lastKnownModifiedLineCount = newLine$1;
4443
4933
  await new Promise((resolve) => typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame(resolve) : setTimeout(resolve, 0));
4934
+ this.eagerlyGrowDiffContainerHeight();
4444
4935
  const shouldImmediate$1 = this.shouldPerformImmediateRevealDiff();
4445
4936
  log("diff", "flushAppendBufferDiff chunk metrics", {
4446
4937
  idx,
@@ -4450,7 +4941,7 @@ var DiffEditorManager = class DiffEditorManager {
4450
4941
  });
4451
4942
  if (shouldImmediate$1) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
4452
4943
  const computed$3 = this.computedHeight();
4453
- if (computed$3 >= this.maxHeightValue - 1 && this.lastContainer) {
4944
+ if (computed$3 >= this.maxHeightValue - 1 && this.lastContainer && !this.shouldAvoidOptimisticMaxHeightWriteDiff()) {
4454
4945
  this.lastContainer.style.height = `${this.maxHeightValue}px`;
4455
4946
  this.lastContainer.style.overflow = "hidden";
4456
4947
  }
@@ -4479,16 +4970,17 @@ var DiffEditorManager = class DiffEditorManager {
4479
4970
  this.lastKnownModifiedCode = model.getValue();
4480
4971
  const newLine = model.getLineCount();
4481
4972
  this.lastKnownModifiedLineCount = newLine;
4973
+ this.eagerlyGrowDiffContainerHeight();
4482
4974
  const shouldImmediate = this.shouldPerformImmediateRevealDiff();
4483
4975
  if (shouldImmediate) this.suppressScrollWatcherDiff(this.scrollWatcherSuppressionMs + 800);
4484
4976
  const computed$2 = this.computedHeight();
4485
- if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer) this.lastContainer.style.height = `${this.maxHeightValue}px`;
4977
+ if (computed$2 >= this.maxHeightValue - 1 && this.lastContainer && !this.shouldAvoidOptimisticMaxHeightWriteDiff()) this.lastContainer.style.height = `${this.maxHeightValue}px`;
4486
4978
  if (shouldImmediate) this.scheduleImmediateRevealAfterLayoutDiff(newLine);
4487
4979
  else this.maybeScrollDiffToBottom(newLine, prevLine);
4488
4980
  if (suppressedByFlush) watcherApi.setSuppressed(false);
4489
4981
  try {
4490
- var _this$diffEditorView33, _this$diffEditorView34, _this$diffEditorView35;
4491
- 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;
4982
+ var _this$diffEditorView34, _this$diffEditorView35, _this$diffEditorView36;
4983
+ 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;
4492
4984
  } catch {}
4493
4985
  }
4494
4986
  applyMinimalEditToModel(model, prev, next) {