stream-monaco 0.0.20 → 0.0.21

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.
@@ -553,6 +553,7 @@ var DiffEditorManager = class DiffEditorManager {
553
553
  diffHunkFallbackVersions = null;
554
554
  diffHunkActionInFlight = false;
555
555
  diffComputedVersions = null;
556
+ preserveNativeDiffDecorationsOnStaleAppend = false;
556
557
  diffPresentationDisposables = [];
557
558
  fallbackOriginalDecorationIds = [];
558
559
  fallbackModifiedDecorationIds = [];
@@ -569,6 +570,52 @@ var DiffEditorManager = class DiffEditorManager {
569
570
  diffRootAppearanceSignature = null;
570
571
  diffPersistedUnchangedModelState = null;
571
572
  pendingPreparedDiffViewModel = null;
573
+ cancelRafs() {
574
+ this.rafScheduler.cancel("sync-diff-presentation");
575
+ this.rafScheduler.cancel("capture-diff-unchanged-state");
576
+ this.rafScheduler.cancel("restore-diff-unchanged-state");
577
+ this.rafScheduler.cancel("patch-diff-unchanged-regions");
578
+ this.rafScheduler.cancel("maybe-scroll-diff");
579
+ this.rafScheduler.cancel("revealDiff");
580
+ this.rafScheduler.cancel("immediate-reveal-diff");
581
+ this.rafScheduler.cancel("maybe-resume-diff");
582
+ this.rafScheduler.cancel("content-size-change-diff");
583
+ this.rafScheduler.cancel("sync-last-known-modified");
584
+ this.rafScheduler.cancel("diff");
585
+ this.rafScheduler.cancel("appendDiff");
586
+ }
587
+ clearRevealTimers() {
588
+ if (this.revealDebounceIdDiff != null) {
589
+ clearTimeout(this.revealDebounceIdDiff);
590
+ this.revealDebounceIdDiff = null;
591
+ }
592
+ if (this.revealIdleTimerIdDiff != null) {
593
+ clearTimeout(this.revealIdleTimerIdDiff);
594
+ this.revealIdleTimerIdDiff = null;
595
+ }
596
+ }
597
+ resetAppendState() {
598
+ this.appendBufferDiffScheduled = false;
599
+ this.appendBufferOriginalDiff.length = 0;
600
+ this.appendBufferModifiedDiff.length = 0;
601
+ if (this.appendFlushThrottleTimerDiff != null) {
602
+ clearTimeout(this.appendFlushThrottleTimerDiff);
603
+ this.appendFlushThrottleTimerDiff = null;
604
+ }
605
+ }
606
+ clearAsyncWork() {
607
+ this.cancelRafs();
608
+ this.pendingDiffUpdate = null;
609
+ this.lastKnownModifiedDirty = false;
610
+ this.resetAppendState();
611
+ this.clearRevealTimers();
612
+ if (this.diffScrollWatcherSuppressionTimer != null) {
613
+ clearTimeout(this.diffScrollWatcherSuppressionTimer);
614
+ this.diffScrollWatcherSuppressionTimer = null;
615
+ }
616
+ this.cancelScheduledHideDiffHunkActions();
617
+ this.clearPendingDiffThemeSync();
618
+ }
572
619
  diffModelTransitionRequestId = 0;
573
620
  pendingDiffScrollRestorePosition = null;
574
621
  pendingDiffScrollRestoreBudget = 0;
@@ -952,15 +999,16 @@ var DiffEditorManager = class DiffEditorManager {
952
999
  marginClassName: removed ? "stream-monaco-fallback-gutter-delete" : "stream-monaco-fallback-gutter-insert",
953
1000
  linesDecorationsClassName: removed ? "stream-monaco-fallback-lines-delete" : "stream-monaco-fallback-lines-insert",
954
1001
  lineNumberClassName: removed ? "stream-monaco-fallback-line-number-delete" : "stream-monaco-fallback-line-number-insert",
955
- description: removed ? "stream-monaco-fallback-line-delete" : "stream-monaco-fallback-line-insert",
956
1002
  zIndex: 5
957
1003
  }
958
1004
  };
959
1005
  }
960
1006
  syncDiffPresentationDecorations() {
1007
+ var _this$diffEditorView$3, _this$lastContainer$q, _this$lastContainer;
961
1008
  if (!this.diffEditorView || !this.lastContainer) return;
962
1009
  const nativeFresh = this.hasFreshNativeDiffResult();
963
- this.lastContainer.classList.toggle("stream-monaco-diff-native-stale", !nativeFresh);
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")));
1011
+ this.lastContainer.classList.toggle("stream-monaco-diff-native-stale", !nativeFresh && !keepNativeDecorationsWhileStale);
964
1012
  if (nativeFresh) {
965
1013
  this.clearFallbackDiffDecorations();
966
1014
  return;
@@ -3336,14 +3384,14 @@ var DiffEditorManager = class DiffEditorManager {
3336
3384
  this.repositionDiffHunkNodes();
3337
3385
  }
3338
3386
  isOriginalEditorCollapsed() {
3339
- var _this$diffEditorView$3, _this$diffEditorView$4;
3387
+ var _this$diffEditorView$4, _this$diffEditorView$5;
3340
3388
  if (!this.diffEditorView) return true;
3341
- const info = (_this$diffEditorView$3 = (_this$diffEditorView$4 = this.diffEditorView.getOriginalEditor()).getLayoutInfo) === null || _this$diffEditorView$3 === void 0 ? void 0 : _this$diffEditorView$3.call(_this$diffEditorView$4);
3389
+ const info = (_this$diffEditorView$4 = (_this$diffEditorView$5 = this.diffEditorView.getOriginalEditor()).getLayoutInfo) === null || _this$diffEditorView$4 === void 0 ? void 0 : _this$diffEditorView$4.call(_this$diffEditorView$5);
3342
3390
  return !info || info.width < 24;
3343
3391
  }
3344
3392
  isDiffInlineMode() {
3345
- var _this$lastContainer;
3346
- const diffRoot = (_this$lastContainer = this.lastContainer) === null || _this$lastContainer === void 0 ? void 0 : _this$lastContainer.querySelector(".monaco-diff-editor");
3393
+ var _this$lastContainer2;
3394
+ const diffRoot = (_this$lastContainer2 = this.lastContainer) === null || _this$lastContainer2 === void 0 ? void 0 : _this$lastContainer2.querySelector(".monaco-diff-editor");
3347
3395
  if (diffRoot instanceof HTMLElement) return !diffRoot.classList.contains("side-by-side");
3348
3396
  return this.isOriginalEditorCollapsed();
3349
3397
  }
@@ -3602,6 +3650,7 @@ var DiffEditorManager = class DiffEditorManager {
3602
3650
  const text = this.appendBufferOriginalDiff.join("");
3603
3651
  this.appendBufferOriginalDiff.length = 0;
3604
3652
  if (!text) return;
3653
+ this.preserveNativeDiffDecorationsOnStaleAppend = true;
3605
3654
  this.appendToModel(this.originalModel, text);
3606
3655
  }
3607
3656
  computedHeight() {
@@ -3767,7 +3816,6 @@ var DiffEditorManager = class DiffEditorManager {
3767
3816
  });
3768
3817
  try {
3769
3818
  var _this$diffEditorView29, _this$diffEditorView30, _this$diffEditorView31;
3770
- this.shouldAutoScrollDiff = true;
3771
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;
3772
3820
  } catch {}
3773
3821
  });
@@ -3786,11 +3834,6 @@ var DiffEditorManager = class DiffEditorManager {
3786
3834
  line,
3787
3835
  ticket
3788
3836
  });
3789
- try {
3790
- var _this$diffEditorView32, _this$diffEditorView33, _this$diffEditorView34;
3791
- this.shouldAutoScrollDiff = true;
3792
- this.lastScrollTopDiff = ((_this$diffEditorView32 = this.diffEditorView) === null || _this$diffEditorView32 === void 0 || (_this$diffEditorView34 = (_this$diffEditorView33 = _this$diffEditorView32.getModifiedEditor()).getScrollTop) === null || _this$diffEditorView34 === void 0 ? void 0 : _this$diffEditorView34.call(_this$diffEditorView33)) ?? this.lastScrollTopDiff;
3793
- } catch {}
3794
3837
  }
3795
3838
  scheduleImmediateRevealAfterLayoutDiff(line) {
3796
3839
  const ticket = ++this.revealTicketDiff;
@@ -3978,18 +4021,22 @@ var DiffEditorManager = class DiffEditorManager {
3978
4021
  if (this.lastKnownModifiedCode == null) this.lastKnownModifiedCode = this.modifiedModel.getValue();
3979
4022
  const prevO = this.lastKnownOriginalCode;
3980
4023
  const prevM = this.lastKnownModifiedCode;
4024
+ const originalTailAppend = originalCode !== prevO && originalCode.startsWith(prevO) && prevO.length < originalCode.length;
4025
+ const modifiedTailAppend = modifiedCode !== prevM && modifiedCode.startsWith(prevM) && prevM.length < modifiedCode.length;
4026
+ const hasContentChange = originalCode !== prevO || modifiedCode !== prevM;
3981
4027
  if (originalCode !== prevO || modifiedCode !== prevM) this.markDiffStreamingActivity();
3982
4028
  let didImmediate = false;
3983
- if (originalCode !== prevO && originalCode.startsWith(prevO)) {
4029
+ if (originalTailAppend) {
3984
4030
  this.appendOriginal(originalCode.slice(prevO.length));
3985
4031
  this.lastKnownOriginalCode = originalCode;
3986
4032
  didImmediate = true;
3987
4033
  }
3988
- if (modifiedCode !== prevM && modifiedCode.startsWith(prevM)) {
4034
+ if (modifiedTailAppend) {
3989
4035
  this.appendModified(modifiedCode.slice(prevM.length));
3990
4036
  this.lastKnownModifiedCode = modifiedCode;
3991
4037
  didImmediate = true;
3992
4038
  }
4039
+ if (hasContentChange) this.preserveNativeDiffDecorationsOnStaleAppend = (originalCode === prevO || originalTailAppend) && (modifiedCode === prevM || modifiedTailAppend);
3993
4040
  if (originalCode !== this.lastKnownOriginalCode || modifiedCode !== this.lastKnownModifiedCode) {
3994
4041
  this.pendingDiffUpdate = {
3995
4042
  original: originalCode,
@@ -4006,8 +4053,10 @@ var DiffEditorManager = class DiffEditorManager {
4006
4053
  }
4007
4054
  const prev = this.lastKnownOriginalCode ?? this.originalModel.getValue();
4008
4055
  if (prev === newCode) return;
4056
+ const tailAppend = newCode.startsWith(prev) && prev.length < newCode.length;
4009
4057
  this.markDiffStreamingActivity();
4010
- if (newCode.startsWith(prev) && prev.length < newCode.length) this.appendOriginal(newCode.slice(prev.length), codeLanguage);
4058
+ this.preserveNativeDiffDecorationsOnStaleAppend = tailAppend;
4059
+ if (tailAppend) this.appendOriginal(newCode.slice(prev.length), codeLanguage);
4011
4060
  else {
4012
4061
  this.flushOriginalAppendBufferSync();
4013
4062
  this.applyMinimalEditToModel(this.originalModel, prev, newCode);
@@ -4022,8 +4071,10 @@ var DiffEditorManager = class DiffEditorManager {
4022
4071
  }
4023
4072
  const prev = this.lastKnownModifiedCode ?? this.modifiedModel.getValue();
4024
4073
  if (prev === newCode) return;
4074
+ const tailAppend = newCode.startsWith(prev) && prev.length < newCode.length;
4025
4075
  this.markDiffStreamingActivity();
4026
- if (newCode.startsWith(prev) && prev.length < newCode.length) this.appendModified(newCode.slice(prev.length), codeLanguage);
4076
+ this.preserveNativeDiffDecorationsOnStaleAppend = tailAppend;
4077
+ if (tailAppend) this.appendModified(newCode.slice(prev.length), codeLanguage);
4027
4078
  else {
4028
4079
  this.flushModifiedAppendBufferSync();
4029
4080
  const prevAfterFlush = this.modifiedModel.getValue();
@@ -4047,6 +4098,7 @@ var DiffEditorManager = class DiffEditorManager {
4047
4098
  appendOriginal(appendText, codeLanguage) {
4048
4099
  if (!this.diffEditorView || !this.originalModel || !appendText) return;
4049
4100
  this.markDiffStreamingActivity();
4101
+ this.preserveNativeDiffDecorationsOnStaleAppend = true;
4050
4102
  if (codeLanguage) {
4051
4103
  const lang = processedLanguage(codeLanguage);
4052
4104
  if (lang && this.originalModel.getLanguageId() !== lang) monaco_shim_exports.editor.setModelLanguage(this.originalModel, lang);
@@ -4057,6 +4109,7 @@ var DiffEditorManager = class DiffEditorManager {
4057
4109
  appendModified(appendText, codeLanguage) {
4058
4110
  if (!this.diffEditorView || !this.modifiedModel || !appendText) return;
4059
4111
  this.markDiffStreamingActivity();
4112
+ this.preserveNativeDiffDecorationsOnStaleAppend = true;
4060
4113
  if (codeLanguage) {
4061
4114
  const lang = processedLanguage(codeLanguage);
4062
4115
  if (lang && this.modifiedModel.getLanguageId() !== lang) monaco_shim_exports.editor.setModelLanguage(this.modifiedModel, lang);
@@ -4073,9 +4126,10 @@ var DiffEditorManager = class DiffEditorManager {
4073
4126
  if (this.modifiedModel && this.modifiedModel.getLanguageId() !== language) monaco_shim_exports.editor.setModelLanguage(this.modifiedModel, language);
4074
4127
  }
4075
4128
  async setDiffModels(models, options = {}) {
4076
- var _this$originalModel2, _this$modifiedModel5, _this$diffEditorView$5, _this$diffEditorView$6, _this$diffEditorView$7, _this$diffEditorView$8;
4129
+ var _this$originalModel2, _this$modifiedModel5, _this$diffEditorView$6, _this$diffEditorView$7, _this$diffEditorView$8, _this$diffEditorView$9;
4077
4130
  if (!this.diffEditorView) return;
4078
4131
  const transitionRequestId = ++this.diffModelTransitionRequestId;
4132
+ this.preserveNativeDiffDecorationsOnStaleAppend = false;
4079
4133
  this.disposePendingPreparedDiffViewModel();
4080
4134
  const nextOriginal = models.original;
4081
4135
  const nextModified = models.modified;
@@ -4126,6 +4180,7 @@ var DiffEditorManager = class DiffEditorManager {
4126
4180
  this.pendingDiffUpdate = null;
4127
4181
  this.flushOriginalAppendBufferSync();
4128
4182
  this.flushModifiedAppendBufferSync();
4183
+ this.preserveNativeDiffDecorationsOnStaleAppend = false;
4129
4184
  const currentOriginal = this.originalModel;
4130
4185
  const currentModified = this.modifiedModel;
4131
4186
  const shouldRestorePersistedUnchangedState = preserveViewState && !sameContent;
@@ -4135,8 +4190,8 @@ var DiffEditorManager = class DiffEditorManager {
4135
4190
  this.queuePendingDiffScrollRestore(preservedScrollPosition, shouldRestorePersistedUnchangedState ? 2 : 0);
4136
4191
  if (shouldRestorePersistedUnchangedState) this.capturePersistedDiffUnchangedState();
4137
4192
  const applyModelSwap = () => {
4138
- var _this$diffEditorView35;
4139
- (_this$diffEditorView35 = this.diffEditorView) === null || _this$diffEditorView35 === void 0 || _this$diffEditorView35.setModel(nextModelTarget);
4193
+ var _this$diffEditorView32;
4194
+ (_this$diffEditorView32 = this.diffEditorView) === null || _this$diffEditorView32 === void 0 || _this$diffEditorView32.setModel(nextModelTarget);
4140
4195
  };
4141
4196
  if (preserveViewState) this.withLockedDiffScrollPosition(applyModelSwap);
4142
4197
  else applyModelSwap();
@@ -4151,8 +4206,8 @@ var DiffEditorManager = class DiffEditorManager {
4151
4206
  this.lastKnownModifiedLineCount = nextModified.getLineCount();
4152
4207
  this.lastKnownModifiedDirty = false;
4153
4208
  this._hasScrollBar = false;
4154
- this.cachedScrollHeightDiff = ((_this$diffEditorView$5 = (_this$diffEditorView$6 = this.diffEditorView.getModifiedEditor()).getScrollHeight) === null || _this$diffEditorView$5 === void 0 ? void 0 : _this$diffEditorView$5.call(_this$diffEditorView$6)) ?? null;
4155
- this.cachedLineHeightDiff = ((_this$diffEditorView$7 = (_this$diffEditorView$8 = this.diffEditorView.getModifiedEditor()).getOption) === null || _this$diffEditorView$7 === void 0 ? void 0 : _this$diffEditorView$7.call(_this$diffEditorView$8, monaco_shim_exports.editor.EditorOption.lineHeight)) ?? null;
4209
+ this.cachedScrollHeightDiff = ((_this$diffEditorView$6 = (_this$diffEditorView$7 = this.diffEditorView.getModifiedEditor()).getScrollHeight) === null || _this$diffEditorView$6 === void 0 ? void 0 : _this$diffEditorView$6.call(_this$diffEditorView$7)) ?? null;
4210
+ this.cachedLineHeightDiff = ((_this$diffEditorView$8 = (_this$diffEditorView$9 = this.diffEditorView.getModifiedEditor()).getOption) === null || _this$diffEditorView$8 === void 0 ? void 0 : _this$diffEditorView$8.call(_this$diffEditorView$9, monaco_shim_exports.editor.EditorOption.lineHeight)) ?? null;
4156
4211
  this.cachedComputedHeightDiff = this.computedHeight();
4157
4212
  this.diffHunkLineChanges = this.getEffectiveLineChanges();
4158
4213
  this.hideDiffHunkActions();
@@ -4179,19 +4234,9 @@ var DiffEditorManager = class DiffEditorManager {
4179
4234
  }
4180
4235
  cleanup() {
4181
4236
  this.diffModelTransitionRequestId += 1;
4237
+ this.preserveNativeDiffDecorationsOnStaleAppend = false;
4182
4238
  this.disposePendingPreparedDiffViewModel();
4183
- this.rafScheduler.cancel("diff");
4184
- this.pendingDiffUpdate = null;
4185
- this.rafScheduler.cancel("appendDiff");
4186
- this.appendBufferDiffScheduled = false;
4187
- this.appendBufferOriginalDiff.length = 0;
4188
- this.appendBufferModifiedDiff.length = 0;
4189
- if (this.appendFlushThrottleTimerDiff != null) {
4190
- clearTimeout(this.appendFlushThrottleTimerDiff);
4191
- this.appendFlushThrottleTimerDiff = null;
4192
- }
4193
- this.rafScheduler.cancel("content-size-change-diff");
4194
- this.rafScheduler.cancel("sync-last-known-modified");
4239
+ this.clearAsyncWork();
4195
4240
  this.disposeDiffHunkInteractions();
4196
4241
  this.disposeDiffUnchangedRegionEnhancements();
4197
4242
  this.disposeDiffPresentationTracking();
@@ -4222,18 +4267,6 @@ var DiffEditorManager = class DiffEditorManager {
4222
4267
  this.lastContainer.innerHTML = "";
4223
4268
  this.lastContainer = null;
4224
4269
  }
4225
- if (this.revealDebounceIdDiff != null) {
4226
- clearTimeout(this.revealDebounceIdDiff);
4227
- this.revealDebounceIdDiff = null;
4228
- }
4229
- if (this.revealIdleTimerIdDiff != null) {
4230
- clearTimeout(this.revealIdleTimerIdDiff);
4231
- this.revealIdleTimerIdDiff = null;
4232
- }
4233
- if (this.diffScrollWatcherSuppressionTimer != null) {
4234
- clearTimeout(this.diffScrollWatcherSuppressionTimer);
4235
- this.diffScrollWatcherSuppressionTimer = null;
4236
- }
4237
4270
  this.revealTicketDiff = 0;
4238
4271
  this.lastRevealLineDiff = null;
4239
4272
  this.diffPersistedUnchangedModelState = null;
@@ -4241,23 +4274,13 @@ var DiffEditorManager = class DiffEditorManager {
4241
4274
  this.pendingDiffScrollRestoreBudget = 0;
4242
4275
  this.diffHideUnchangedRegionsResolved = null;
4243
4276
  this.diffHideUnchangedRegionsDeferred = false;
4244
- this.clearPendingDiffThemeSync();
4245
4277
  }
4246
4278
  safeClean() {
4247
4279
  this.diffModelTransitionRequestId += 1;
4280
+ this.preserveNativeDiffDecorationsOnStaleAppend = false;
4248
4281
  this.disposePendingPreparedDiffViewModel();
4249
- this.rafScheduler.cancel("diff");
4250
- this.pendingDiffUpdate = null;
4251
- this.rafScheduler.cancel("appendDiff");
4252
- this.appendBufferDiffScheduled = false;
4253
- this.appendBufferOriginalDiff.length = 0;
4254
- this.appendBufferModifiedDiff.length = 0;
4255
- if (this.appendFlushThrottleTimerDiff != null) {
4256
- clearTimeout(this.appendFlushThrottleTimerDiff);
4257
- this.appendFlushThrottleTimerDiff = null;
4258
- }
4282
+ this.clearAsyncWork();
4259
4283
  this.hideDiffHunkActions();
4260
- this.cancelScheduledHideDiffHunkActions();
4261
4284
  this.disposeDiffUnchangedRegionEnhancements();
4262
4285
  this.disposeDiffPresentationTracking();
4263
4286
  if (this.diffScrollWatcher) {
@@ -4271,25 +4294,10 @@ var DiffEditorManager = class DiffEditorManager {
4271
4294
  this.diffHeightManager.dispose();
4272
4295
  this.diffHeightManager = null;
4273
4296
  }
4274
- if (this.revealDebounceIdDiff != null) {
4275
- clearTimeout(this.revealDebounceIdDiff);
4276
- this.revealDebounceIdDiff = null;
4277
- }
4278
- if (this.revealIdleTimerIdDiff != null) {
4279
- clearTimeout(this.revealIdleTimerIdDiff);
4280
- this.revealIdleTimerIdDiff = null;
4281
- }
4282
- if (this.diffScrollWatcherSuppressionTimer != null) {
4283
- clearTimeout(this.diffScrollWatcherSuppressionTimer);
4284
- this.diffScrollWatcherSuppressionTimer = null;
4285
- }
4286
4297
  this.revealTicketDiff = 0;
4287
4298
  this.lastRevealLineDiff = null;
4288
4299
  this.diffPersistedUnchangedModelState = null;
4289
4300
  this.diffHideUnchangedRegionsDeferred = false;
4290
- this.clearPendingDiffThemeSync();
4291
- this.rafScheduler.cancel("content-size-change-diff");
4292
- this.rafScheduler.cancel("sync-last-known-modified");
4293
4301
  }
4294
4302
  syncLastKnownModified() {
4295
4303
  if (!this.diffEditorView || !this.lastKnownModifiedDirty) return;
@@ -4328,15 +4336,19 @@ var DiffEditorManager = class DiffEditorManager {
4328
4336
  if (this.lastKnownOriginalCode == null) this.lastKnownOriginalCode = o.getValue();
4329
4337
  if (this.lastKnownModifiedCode == null) this.lastKnownModifiedCode = m.getValue();
4330
4338
  const prevO = this.lastKnownOriginalCode;
4339
+ const originalTailAppend = prevO !== original && original.startsWith(prevO) && prevO.length < original.length;
4331
4340
  if (prevO !== original) {
4332
- if (original.startsWith(prevO) && prevO.length < original.length) this.appendToModel(o, original.slice(prevO.length));
4341
+ if (originalTailAppend) this.appendToModel(o, original.slice(prevO.length));
4333
4342
  else this.applyMinimalEditToModel(o, prevO, original);
4334
4343
  this.lastKnownOriginalCode = original;
4335
4344
  }
4336
4345
  const prevM = m.getValue();
4337
4346
  const prevMLineCount = m.getLineCount();
4347
+ const modifiedTailAppend = prevM !== modified && modified.startsWith(prevM) && prevM.length < modified.length;
4348
+ const hasContentChange = prevO !== original || prevM !== modified;
4349
+ if (hasContentChange) this.preserveNativeDiffDecorationsOnStaleAppend = (prevO === original || originalTailAppend) && (prevM === modified || modifiedTailAppend);
4338
4350
  if (prevM !== modified) {
4339
- if (modified.startsWith(prevM) && prevM.length < modified.length) this.appendToModel(m, modified.slice(prevM.length));
4351
+ if (modifiedTailAppend) this.appendToModel(m, modified.slice(prevM.length));
4340
4352
  else this.applyMinimalEditToModel(m, prevM, modified);
4341
4353
  this.lastKnownModifiedCode = modified;
4342
4354
  const newMLineCount = m.getLineCount();
@@ -4361,6 +4373,7 @@ var DiffEditorManager = class DiffEditorManager {
4361
4373
  const text = this.appendBufferModifiedDiff.join("");
4362
4374
  this.appendBufferModifiedDiff.length = 0;
4363
4375
  if (!text) return;
4376
+ this.preserveNativeDiffDecorationsOnStaleAppend = true;
4364
4377
  this.appendToModel(this.modifiedModel, text);
4365
4378
  }
4366
4379
  async flushAppendBufferDiff() {
@@ -4371,7 +4384,10 @@ var DiffEditorManager = class DiffEditorManager {
4371
4384
  if (this.originalModel && this.appendBufferOriginalDiff.length > 0) {
4372
4385
  const oText = this.appendBufferOriginalDiff.join("");
4373
4386
  this.appendBufferOriginalDiff.length = 0;
4374
- if (oText) this.appendToModel(this.originalModel, oText);
4387
+ if (oText) {
4388
+ this.preserveNativeDiffDecorationsOnStaleAppend = true;
4389
+ this.appendToModel(this.originalModel, oText);
4390
+ }
4375
4391
  }
4376
4392
  const me = this.diffEditorView.getModifiedEditor();
4377
4393
  const model = me.getModel();
@@ -4420,6 +4436,7 @@ var DiffEditorManager = class DiffEditorManager {
4420
4436
  });
4421
4437
  const lastColumn$1 = model.getLineMaxColumn(prevLine);
4422
4438
  const range$1 = new monaco_shim_exports.Range(prevLine, lastColumn$1, prevLine, lastColumn$1);
4439
+ this.preserveNativeDiffDecorationsOnStaleAppend = true;
4423
4440
  model.applyEdits([{
4424
4441
  range: range$1,
4425
4442
  text: part,
@@ -4458,6 +4475,7 @@ var DiffEditorManager = class DiffEditorManager {
4458
4475
  prevLine = model.getLineCount();
4459
4476
  const lastColumn = model.getLineMaxColumn(prevLine);
4460
4477
  const range = new monaco_shim_exports.Range(prevLine, lastColumn, prevLine, lastColumn);
4478
+ this.preserveNativeDiffDecorationsOnStaleAppend = true;
4461
4479
  model.applyEdits([{
4462
4480
  range,
4463
4481
  text,
@@ -4474,9 +4492,8 @@ var DiffEditorManager = class DiffEditorManager {
4474
4492
  else this.maybeScrollDiffToBottom(newLine, prevLine);
4475
4493
  if (suppressedByFlush) watcherApi.setSuppressed(false);
4476
4494
  try {
4477
- var _this$diffEditorView36, _this$diffEditorView37, _this$diffEditorView38;
4478
- this.shouldAutoScrollDiff = true;
4479
- this.lastScrollTopDiff = ((_this$diffEditorView36 = this.diffEditorView) === null || _this$diffEditorView36 === void 0 || (_this$diffEditorView38 = (_this$diffEditorView37 = _this$diffEditorView36.getModifiedEditor()).getScrollTop) === null || _this$diffEditorView38 === void 0 ? void 0 : _this$diffEditorView38.call(_this$diffEditorView37)) ?? this.lastScrollTopDiff;
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;
4480
4497
  } catch {}
4481
4498
  }
4482
4499
  applyMinimalEditToModel(model, prev, next) {
@@ -4524,6 +4541,9 @@ var EditorManager = class {
4524
4541
  lastKnownCode = null;
4525
4542
  pendingUpdate = null;
4526
4543
  _hasScrollBar = false;
4544
+ updateThrottleMs = 50;
4545
+ lastUpdateFlushTime = 0;
4546
+ updateThrottleTimer = null;
4527
4547
  shouldAutoScroll = true;
4528
4548
  scrollWatcher = null;
4529
4549
  scrollWatcherSuppressionTimer = null;
@@ -4533,6 +4553,7 @@ var EditorManager = class {
4533
4553
  cachedComputedHeight = null;
4534
4554
  cachedLineCount = null;
4535
4555
  lastKnownCodeDirty = false;
4556
+ programmaticContentChangeDepth = 0;
4536
4557
  debug = false;
4537
4558
  measureViewport() {
4538
4559
  var _this$editorView$getL, _this$editorView, _this$editorView$getS, _this$editorView2, _this$editorView$getS2, _this$editorView3;
@@ -4565,7 +4586,7 @@ var EditorManager = class {
4565
4586
  revealStrategyOption;
4566
4587
  revealBatchOnIdleMsOption;
4567
4588
  scrollWatcherSuppressionMs = 500;
4568
- constructor(options, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, revealDebounceMsOption) {
4589
+ constructor(options, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, revealDebounceMsOption, updateThrottleMsOption) {
4569
4590
  this.options = options;
4570
4591
  this.maxHeightValue = maxHeightValue;
4571
4592
  this.maxHeightCSS = maxHeightCSS;
@@ -4574,6 +4595,47 @@ var EditorManager = class {
4574
4595
  this.autoScrollThresholdPx = autoScrollThresholdPx;
4575
4596
  this.autoScrollThresholdLines = autoScrollThresholdLines;
4576
4597
  this.revealDebounceMsOption = revealDebounceMsOption;
4598
+ this.updateThrottleMsOption = updateThrottleMsOption;
4599
+ this.updateThrottleMs = this.updateThrottleMsOption ?? this.options.updateThrottleMs ?? 50;
4600
+ }
4601
+ cancelRafs() {
4602
+ this.rafScheduler.cancel("update");
4603
+ this.rafScheduler.cancel("sync-last-known");
4604
+ this.rafScheduler.cancel("content-size-change");
4605
+ this.rafScheduler.cancel("maybe-scroll");
4606
+ this.rafScheduler.cancel("reveal");
4607
+ this.rafScheduler.cancel("immediate-reveal");
4608
+ this.rafScheduler.cancel("maybe-resume");
4609
+ this.rafScheduler.cancel("append");
4610
+ }
4611
+ clearRevealTimers() {
4612
+ if (this.revealDebounceId != null) {
4613
+ clearTimeout(this.revealDebounceId);
4614
+ this.revealDebounceId = null;
4615
+ }
4616
+ if (this.revealIdleTimerId != null) {
4617
+ clearTimeout(this.revealIdleTimerId);
4618
+ this.revealIdleTimerId = null;
4619
+ }
4620
+ }
4621
+ resetAppendState() {
4622
+ this.appendBufferScheduled = false;
4623
+ this.appendBuffer.length = 0;
4624
+ }
4625
+ clearAsyncWork() {
4626
+ this.cancelRafs();
4627
+ this.pendingUpdate = null;
4628
+ this.lastKnownCodeDirty = false;
4629
+ this.resetAppendState();
4630
+ this.clearRevealTimers();
4631
+ if (this.scrollWatcherSuppressionTimer != null) {
4632
+ clearTimeout(this.scrollWatcherSuppressionTimer);
4633
+ this.scrollWatcherSuppressionTimer = null;
4634
+ }
4635
+ if (this.updateThrottleTimer != null) {
4636
+ clearTimeout(this.updateThrottleTimer);
4637
+ this.updateThrottleTimer = null;
4638
+ }
4577
4639
  }
4578
4640
  initDebugFlag() {
4579
4641
  if (typeof window !== "undefined" && window.__STREAM_MONACO_DEBUG__ !== void 0) {
@@ -4590,6 +4652,14 @@ var EditorManager = class {
4590
4652
  if (!this.debug) return;
4591
4653
  log("EditorManager", ...args);
4592
4654
  }
4655
+ runAsProgrammaticContentChange(fn) {
4656
+ this.programmaticContentChangeDepth += 1;
4657
+ try {
4658
+ return fn();
4659
+ } finally {
4660
+ this.programmaticContentChangeDepth -= 1;
4661
+ }
4662
+ }
4593
4663
  hasVerticalScrollbar() {
4594
4664
  if (!this.editorView) return false;
4595
4665
  if (this._hasScrollBar) return true;
@@ -4816,6 +4886,7 @@ var EditorManager = class {
4816
4886
  });
4817
4887
  });
4818
4888
  this.editorView.onDidChangeModelContent(() => {
4889
+ if (this.programmaticContentChangeDepth > 0) return;
4819
4890
  this.lastKnownCodeDirty = true;
4820
4891
  this.rafScheduler.schedule("sync-last-known", () => this.syncLastKnownCode());
4821
4892
  });
@@ -4910,7 +4981,24 @@ var EditorManager = class {
4910
4981
  code: newCode,
4911
4982
  lang: codeLanguage
4912
4983
  };
4913
- this.rafScheduler.schedule("update", () => this.flushPendingUpdate());
4984
+ this.rafScheduler.schedule("update", () => {
4985
+ if (!this.updateThrottleMs) {
4986
+ this.flushPendingUpdate();
4987
+ return;
4988
+ }
4989
+ const now = Date.now();
4990
+ const since = now - this.lastUpdateFlushTime;
4991
+ if (since >= this.updateThrottleMs) {
4992
+ this.flushPendingUpdate();
4993
+ return;
4994
+ }
4995
+ if (this.updateThrottleTimer != null) return;
4996
+ const wait = this.updateThrottleMs - since;
4997
+ this.updateThrottleTimer = setTimeout(() => {
4998
+ this.updateThrottleTimer = null;
4999
+ this.rafScheduler.schedule("update", () => this.flushPendingUpdate());
5000
+ }, wait);
5001
+ });
4914
5002
  }
4915
5003
  flushPendingUpdate() {
4916
5004
  if (!this.pendingUpdate || !this.editorView) return;
@@ -4918,12 +5006,15 @@ var EditorManager = class {
4918
5006
  if (!model) return;
4919
5007
  const { code: newCode, lang: codeLanguage } = this.pendingUpdate;
4920
5008
  this.pendingUpdate = null;
5009
+ this.lastUpdateFlushTime = Date.now();
4921
5010
  const processedCodeLanguage = processedLanguage(codeLanguage);
4922
5011
  const languageId = model.getLanguageId();
4923
5012
  if (languageId !== processedCodeLanguage) {
4924
5013
  if (processedCodeLanguage) monaco_shim_exports.editor.setModelLanguage(model, processedCodeLanguage);
4925
5014
  const prevLineCount$1 = model.getLineCount();
4926
- model.setValue(newCode);
5015
+ this.runAsProgrammaticContentChange(() => {
5016
+ model.setValue(newCode);
5017
+ });
4927
5018
  this.lastKnownCode = newCode;
4928
5019
  const newLineCount$1 = model.getLineCount();
4929
5020
  this.cachedLineCount = newLineCount$1;
@@ -4936,8 +5027,21 @@ var EditorManager = class {
4936
5027
  }
4937
5028
  return;
4938
5029
  }
4939
- const buffered = this.appendBuffer.length > 0 ? this.appendBuffer.join("") : "";
4940
- const prevCode = this.appendBuffer.length > 0 ? this.editorView.getValue() + buffered : this.lastKnownCode ?? this.editorView.getValue();
5030
+ let prevCode;
5031
+ if (this.appendBuffer.length > 0) {
5032
+ this.resetAppendState();
5033
+ this.rafScheduler.cancel("append");
5034
+ try {
5035
+ prevCode = model.getValue();
5036
+ this.lastKnownCode = prevCode;
5037
+ } catch {
5038
+ prevCode = this.lastKnownCode ?? "";
5039
+ }
5040
+ } else if (this.lastKnownCode != null) prevCode = this.lastKnownCode;
5041
+ else {
5042
+ prevCode = this.editorView.getValue();
5043
+ this.lastKnownCode = prevCode;
5044
+ }
4941
5045
  if (prevCode === newCode) return;
4942
5046
  if (newCode.startsWith(prevCode) && prevCode.length < newCode.length) {
4943
5047
  const suffix = newCode.slice(prevCode.length);
@@ -4981,7 +5085,9 @@ var EditorManager = class {
4981
5085
  const changeRatio = maxLen > 0 ? Math.abs(next.length - prev.length) / maxLen : 0;
4982
5086
  if (prev.length + next.length > maxChars || changeRatio > ratio) {
4983
5087
  const prevLineCount = model.getLineCount();
4984
- model.setValue(next);
5088
+ this.runAsProgrammaticContentChange(() => {
5089
+ model.setValue(next);
5090
+ });
4985
5091
  this.lastKnownCode = next;
4986
5092
  const newLineCount = model.getLineCount();
4987
5093
  this.cachedLineCount = newLineCount;
@@ -5000,8 +5106,10 @@ var EditorManager = class {
5000
5106
  text: replaceText,
5001
5107
  forceMoveMarkers: true
5002
5108
  }];
5003
- if (isReadOnly) model.applyEdits(edit);
5004
- else this.editorView.executeEdits("minimal-replace", edit);
5109
+ this.runAsProgrammaticContentChange(() => {
5110
+ if (isReadOnly) model.applyEdits(edit);
5111
+ else this.editorView.executeEdits("minimal-replace", edit);
5112
+ });
5005
5113
  }
5006
5114
  flushAppendBuffer() {
5007
5115
  if (!this.editorView) return;
@@ -5018,19 +5126,20 @@ var EditorManager = class {
5018
5126
  const lastColumn = model.getLineMaxColumn(lastLine);
5019
5127
  const range = new monaco_shim_exports.Range(lastLine, lastColumn, lastLine, lastColumn);
5020
5128
  const isReadOnly = this.editorView.getOption(monaco_shim_exports.editor.EditorOption.readOnly);
5021
- if (isReadOnly) model.applyEdits([{
5022
- range,
5023
- text,
5024
- forceMoveMarkers: true
5025
- }]);
5026
- else this.editorView.executeEdits("append", [{
5027
- range,
5028
- text,
5029
- forceMoveMarkers: true
5030
- }]);
5031
- try {
5032
- this.lastKnownCode = model.getValue();
5033
- } catch {}
5129
+ this.runAsProgrammaticContentChange(() => {
5130
+ if (isReadOnly) model.applyEdits([{
5131
+ range,
5132
+ text,
5133
+ forceMoveMarkers: true
5134
+ }]);
5135
+ else this.editorView.executeEdits("append", [{
5136
+ range,
5137
+ text,
5138
+ forceMoveMarkers: true
5139
+ }]);
5140
+ });
5141
+ if (this.lastKnownCode != null) this.lastKnownCode = this.lastKnownCode + text;
5142
+ else this.lastKnownCode = model.getValue();
5034
5143
  const newLineCount = model.getLineCount();
5035
5144
  if (lastLine !== newLineCount) {
5036
5145
  this.cachedLineCount = newLineCount;
@@ -5055,30 +5164,19 @@ var EditorManager = class {
5055
5164
  getEditorView() {
5056
5165
  return this.editorView;
5057
5166
  }
5058
- cleanup() {
5059
- this.rafScheduler.cancel("update");
5060
- this.rafScheduler.cancel("sync-last-known");
5061
- this.rafScheduler.cancel("content-size-change");
5062
- this.rafScheduler.cancel("maybe-scroll");
5063
- this.rafScheduler.cancel("reveal");
5064
- this.rafScheduler.cancel("immediate-reveal");
5065
- this.rafScheduler.cancel("maybe-resume");
5066
- this.pendingUpdate = null;
5067
- this.rafScheduler.cancel("append");
5068
- this.appendBufferScheduled = false;
5069
- this.appendBuffer.length = 0;
5070
- if (this.revealDebounceId != null) {
5071
- clearTimeout(this.revealDebounceId);
5072
- this.revealDebounceId = null;
5073
- }
5074
- if (this.revealIdleTimerId != null) {
5075
- clearTimeout(this.revealIdleTimerId);
5076
- this.revealIdleTimerId = null;
5077
- }
5078
- if (this.scrollWatcherSuppressionTimer != null) {
5079
- clearTimeout(this.scrollWatcherSuppressionTimer);
5080
- this.scrollWatcherSuppressionTimer = null;
5167
+ setUpdateThrottleMs(ms) {
5168
+ this.updateThrottleMs = ms;
5169
+ if (!this.updateThrottleMs && this.updateThrottleTimer != null) {
5170
+ clearTimeout(this.updateThrottleTimer);
5171
+ this.updateThrottleTimer = null;
5172
+ this.rafScheduler.schedule("update", () => this.flushPendingUpdate());
5081
5173
  }
5174
+ }
5175
+ getUpdateThrottleMs() {
5176
+ return this.updateThrottleMs;
5177
+ }
5178
+ cleanup() {
5179
+ this.clearAsyncWork();
5082
5180
  if (this.editorView) {
5083
5181
  this.editorView.dispose();
5084
5182
  this.editorView = null;
@@ -5099,31 +5197,13 @@ var EditorManager = class {
5099
5197
  }
5100
5198
  }
5101
5199
  safeClean() {
5102
- this.rafScheduler.cancel("update");
5103
- this.pendingUpdate = null;
5104
- this.rafScheduler.cancel("sync-last-known");
5200
+ this.clearAsyncWork();
5105
5201
  if (this.scrollWatcher) {
5106
5202
  try {
5107
5203
  this.scrollWatcher.dispose();
5108
5204
  } catch {}
5109
5205
  this.scrollWatcher = null;
5110
5206
  }
5111
- if (this.revealDebounceId != null) {
5112
- clearTimeout(this.revealDebounceId);
5113
- this.revealDebounceId = null;
5114
- }
5115
- if (this.revealIdleTimerId != null) {
5116
- clearTimeout(this.revealIdleTimerId);
5117
- this.revealIdleTimerId = null;
5118
- }
5119
- if (this.scrollWatcherSuppressionTimer != null) {
5120
- clearTimeout(this.scrollWatcherSuppressionTimer);
5121
- this.scrollWatcherSuppressionTimer = null;
5122
- }
5123
- this.rafScheduler.cancel("maybe-scroll");
5124
- this.rafScheduler.cancel("reveal");
5125
- this.rafScheduler.cancel("immediate-reveal");
5126
- this.rafScheduler.cancel("maybe-resume");
5127
5207
  this._hasScrollBar = false;
5128
5208
  this.shouldAutoScroll = !!this.autoScrollInitial;
5129
5209
  this.lastScrollTop = 0;
@@ -5662,7 +5742,7 @@ function useMonaco(monacoOptions = {}) {
5662
5742
  }
5663
5743
  const initialThemeName = monacoOptions.theme ?? requestedThemeName ?? globalRequestedThemeName ?? currentTheme.value;
5664
5744
  await ensureThemeRegistered(initialThemeName);
5665
- editorMgr = new EditorManager(monacoOptions, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, monacoOptions.revealDebounceMs);
5745
+ editorMgr = new EditorManager(monacoOptions, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, monacoOptions.revealDebounceMs, updateThrottleMs);
5666
5746
  editorView = await editorMgr.createEditor(container, code, language, initialThemeName);
5667
5747
  if (pendingUpdate && editorMgr) {
5668
5748
  const { code: queuedCode, lang: queuedLang } = pendingUpdate;
@@ -5704,6 +5784,23 @@ function useMonaco(monacoOptions = {}) {
5704
5784
  modifiedModel = models.modified;
5705
5785
  return diffEditorView;
5706
5786
  }
5787
+ function clearFallbackAsyncWork() {
5788
+ rafScheduler.cancel("update");
5789
+ rafScheduler.cancel("append");
5790
+ rafScheduler.cancel("reveal");
5791
+ pendingUpdate = null;
5792
+ appendBufferScheduled = false;
5793
+ appendBuffer.length = 0;
5794
+ if (revealDebounceId != null) {
5795
+ clearTimeout(revealDebounceId);
5796
+ revealDebounceId = null;
5797
+ }
5798
+ if (updateThrottleTimer != null) {
5799
+ clearTimeout(updateThrottleTimer);
5800
+ updateThrottleTimer = null;
5801
+ }
5802
+ lastFlushTime = 0;
5803
+ }
5707
5804
  function cleanupEditor() {
5708
5805
  if (editorMgr) {
5709
5806
  editorMgr.cleanup();
@@ -5713,11 +5810,7 @@ function useMonaco(monacoOptions = {}) {
5713
5810
  diffMgr.cleanup();
5714
5811
  diffMgr = null;
5715
5812
  }
5716
- rafScheduler.cancel("update");
5717
- pendingUpdate = null;
5718
- rafScheduler.cancel("append");
5719
- appendBufferScheduled = false;
5720
- appendBuffer.length = 0;
5813
+ clearFallbackAsyncWork();
5721
5814
  if (!editorMgr && editorView) {
5722
5815
  editorView.dispose();
5723
5816
  editorView = null;
@@ -5731,10 +5824,6 @@ function useMonaco(monacoOptions = {}) {
5731
5824
  themeWatcher();
5732
5825
  themeWatcher = null;
5733
5826
  }
5734
- if (updateThrottleTimer != null) {
5735
- clearTimeout(updateThrottleTimer);
5736
- updateThrottleTimer = null;
5737
- }
5738
5827
  diffEditorView = null;
5739
5828
  originalModel = null;
5740
5829
  modifiedModel = null;
@@ -5800,13 +5889,17 @@ function useMonaco(monacoOptions = {}) {
5800
5889
  pendingUpdate = null;
5801
5890
  const processedCodeLanguage = processedLanguage(codeLanguage);
5802
5891
  let prevCode = null;
5803
- if (appendBuffer.length > 0) try {
5804
- prevCode = model.getValue();
5805
- lastKnownCode = prevCode;
5806
- } catch {
5807
- prevCode = "";
5808
- }
5809
- else {
5892
+ if (appendBuffer.length > 0) {
5893
+ appendBuffer.length = 0;
5894
+ appendBufferScheduled = false;
5895
+ rafScheduler.cancel("append");
5896
+ try {
5897
+ prevCode = model.getValue();
5898
+ lastKnownCode = prevCode;
5899
+ } catch {
5900
+ prevCode = lastKnownCode ?? "";
5901
+ }
5902
+ } else {
5810
5903
  prevCode = lastKnownCode;
5811
5904
  if (prevCode == null) try {
5812
5905
  prevCode = model.getValue();
@@ -5923,9 +6016,10 @@ function useMonaco(monacoOptions = {}) {
5923
6016
  }
5924
6017
  function setUpdateThrottleMs(ms) {
5925
6018
  updateThrottleMs = ms;
6019
+ editorMgr === null || editorMgr === void 0 || editorMgr.setUpdateThrottleMs(ms);
5926
6020
  }
5927
6021
  function getUpdateThrottleMs() {
5928
- return updateThrottleMs;
6022
+ return (editorMgr === null || editorMgr === void 0 ? void 0 : editorMgr.getUpdateThrottleMs()) ?? updateThrottleMs;
5929
6023
  }
5930
6024
  function updateDiff(originalCode, modifiedCode, codeLanguage) {
5931
6025
  if (diffMgr) diffMgr.updateDiff(originalCode, modifiedCode, codeLanguage);
@@ -5957,8 +6051,7 @@ function useMonaco(monacoOptions = {}) {
5957
6051
  createDiffEditor,
5958
6052
  cleanupEditor,
5959
6053
  safeClean() {
5960
- rafScheduler.cancel("update");
5961
- pendingUpdate = null;
6054
+ clearFallbackAsyncWork();
5962
6055
  if (editorMgr) try {
5963
6056
  editorMgr.safeClean();
5964
6057
  } catch {}