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.
@@ -548,6 +548,7 @@ var DiffEditorManager = class DiffEditorManager {
548
548
  diffHunkFallbackVersions = null;
549
549
  diffHunkActionInFlight = false;
550
550
  diffComputedVersions = null;
551
+ preserveNativeDiffDecorationsOnStaleAppend = false;
551
552
  diffPresentationDisposables = [];
552
553
  fallbackOriginalDecorationIds = [];
553
554
  fallbackModifiedDecorationIds = [];
@@ -564,6 +565,52 @@ var DiffEditorManager = class DiffEditorManager {
564
565
  diffRootAppearanceSignature = null;
565
566
  diffPersistedUnchangedModelState = null;
566
567
  pendingPreparedDiffViewModel = null;
568
+ cancelRafs() {
569
+ this.rafScheduler.cancel("sync-diff-presentation");
570
+ this.rafScheduler.cancel("capture-diff-unchanged-state");
571
+ this.rafScheduler.cancel("restore-diff-unchanged-state");
572
+ this.rafScheduler.cancel("patch-diff-unchanged-regions");
573
+ this.rafScheduler.cancel("maybe-scroll-diff");
574
+ this.rafScheduler.cancel("revealDiff");
575
+ this.rafScheduler.cancel("immediate-reveal-diff");
576
+ this.rafScheduler.cancel("maybe-resume-diff");
577
+ this.rafScheduler.cancel("content-size-change-diff");
578
+ this.rafScheduler.cancel("sync-last-known-modified");
579
+ this.rafScheduler.cancel("diff");
580
+ this.rafScheduler.cancel("appendDiff");
581
+ }
582
+ clearRevealTimers() {
583
+ if (this.revealDebounceIdDiff != null) {
584
+ clearTimeout(this.revealDebounceIdDiff);
585
+ this.revealDebounceIdDiff = null;
586
+ }
587
+ if (this.revealIdleTimerIdDiff != null) {
588
+ clearTimeout(this.revealIdleTimerIdDiff);
589
+ this.revealIdleTimerIdDiff = null;
590
+ }
591
+ }
592
+ resetAppendState() {
593
+ this.appendBufferDiffScheduled = false;
594
+ this.appendBufferOriginalDiff.length = 0;
595
+ this.appendBufferModifiedDiff.length = 0;
596
+ if (this.appendFlushThrottleTimerDiff != null) {
597
+ clearTimeout(this.appendFlushThrottleTimerDiff);
598
+ this.appendFlushThrottleTimerDiff = null;
599
+ }
600
+ }
601
+ clearAsyncWork() {
602
+ this.cancelRafs();
603
+ this.pendingDiffUpdate = null;
604
+ this.lastKnownModifiedDirty = false;
605
+ this.resetAppendState();
606
+ this.clearRevealTimers();
607
+ if (this.diffScrollWatcherSuppressionTimer != null) {
608
+ clearTimeout(this.diffScrollWatcherSuppressionTimer);
609
+ this.diffScrollWatcherSuppressionTimer = null;
610
+ }
611
+ this.cancelScheduledHideDiffHunkActions();
612
+ this.clearPendingDiffThemeSync();
613
+ }
567
614
  diffModelTransitionRequestId = 0;
568
615
  pendingDiffScrollRestorePosition = null;
569
616
  pendingDiffScrollRestoreBudget = 0;
@@ -947,15 +994,16 @@ var DiffEditorManager = class DiffEditorManager {
947
994
  marginClassName: removed ? "stream-monaco-fallback-gutter-delete" : "stream-monaco-fallback-gutter-insert",
948
995
  linesDecorationsClassName: removed ? "stream-monaco-fallback-lines-delete" : "stream-monaco-fallback-lines-insert",
949
996
  lineNumberClassName: removed ? "stream-monaco-fallback-line-number-delete" : "stream-monaco-fallback-line-number-insert",
950
- description: removed ? "stream-monaco-fallback-line-delete" : "stream-monaco-fallback-line-insert",
951
997
  zIndex: 5
952
998
  }
953
999
  };
954
1000
  }
955
1001
  syncDiffPresentationDecorations() {
1002
+ var _this$diffEditorView$3, _this$lastContainer$q, _this$lastContainer;
956
1003
  if (!this.diffEditorView || !this.lastContainer) return;
957
1004
  const nativeFresh = this.hasFreshNativeDiffResult();
958
- this.lastContainer.classList.toggle("stream-monaco-diff-native-stale", !nativeFresh);
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")));
1006
+ this.lastContainer.classList.toggle("stream-monaco-diff-native-stale", !nativeFresh && !keepNativeDecorationsWhileStale);
959
1007
  if (nativeFresh) {
960
1008
  this.clearFallbackDiffDecorations();
961
1009
  return;
@@ -3331,14 +3379,14 @@ var DiffEditorManager = class DiffEditorManager {
3331
3379
  this.repositionDiffHunkNodes();
3332
3380
  }
3333
3381
  isOriginalEditorCollapsed() {
3334
- var _this$diffEditorView$3, _this$diffEditorView$4;
3382
+ var _this$diffEditorView$4, _this$diffEditorView$5;
3335
3383
  if (!this.diffEditorView) return true;
3336
- 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);
3384
+ 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);
3337
3385
  return !info || info.width < 24;
3338
3386
  }
3339
3387
  isDiffInlineMode() {
3340
- var _this$lastContainer;
3341
- const diffRoot = (_this$lastContainer = this.lastContainer) === null || _this$lastContainer === void 0 ? void 0 : _this$lastContainer.querySelector(".monaco-diff-editor");
3388
+ var _this$lastContainer2;
3389
+ const diffRoot = (_this$lastContainer2 = this.lastContainer) === null || _this$lastContainer2 === void 0 ? void 0 : _this$lastContainer2.querySelector(".monaco-diff-editor");
3342
3390
  if (diffRoot instanceof HTMLElement) return !diffRoot.classList.contains("side-by-side");
3343
3391
  return this.isOriginalEditorCollapsed();
3344
3392
  }
@@ -3597,6 +3645,7 @@ var DiffEditorManager = class DiffEditorManager {
3597
3645
  const text = this.appendBufferOriginalDiff.join("");
3598
3646
  this.appendBufferOriginalDiff.length = 0;
3599
3647
  if (!text) return;
3648
+ this.preserveNativeDiffDecorationsOnStaleAppend = true;
3600
3649
  this.appendToModel(this.originalModel, text);
3601
3650
  }
3602
3651
  computedHeight() {
@@ -3762,7 +3811,6 @@ var DiffEditorManager = class DiffEditorManager {
3762
3811
  });
3763
3812
  try {
3764
3813
  var _this$diffEditorView29, _this$diffEditorView30, _this$diffEditorView31;
3765
- this.shouldAutoScrollDiff = true;
3766
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;
3767
3815
  } catch {}
3768
3816
  });
@@ -3781,11 +3829,6 @@ var DiffEditorManager = class DiffEditorManager {
3781
3829
  line,
3782
3830
  ticket
3783
3831
  });
3784
- try {
3785
- var _this$diffEditorView32, _this$diffEditorView33, _this$diffEditorView34;
3786
- this.shouldAutoScrollDiff = true;
3787
- 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;
3788
- } catch {}
3789
3832
  }
3790
3833
  scheduleImmediateRevealAfterLayoutDiff(line) {
3791
3834
  const ticket = ++this.revealTicketDiff;
@@ -3973,18 +4016,22 @@ var DiffEditorManager = class DiffEditorManager {
3973
4016
  if (this.lastKnownModifiedCode == null) this.lastKnownModifiedCode = this.modifiedModel.getValue();
3974
4017
  const prevO = this.lastKnownOriginalCode;
3975
4018
  const prevM = this.lastKnownModifiedCode;
4019
+ const originalTailAppend = originalCode !== prevO && originalCode.startsWith(prevO) && prevO.length < originalCode.length;
4020
+ const modifiedTailAppend = modifiedCode !== prevM && modifiedCode.startsWith(prevM) && prevM.length < modifiedCode.length;
4021
+ const hasContentChange = originalCode !== prevO || modifiedCode !== prevM;
3976
4022
  if (originalCode !== prevO || modifiedCode !== prevM) this.markDiffStreamingActivity();
3977
4023
  let didImmediate = false;
3978
- if (originalCode !== prevO && originalCode.startsWith(prevO)) {
4024
+ if (originalTailAppend) {
3979
4025
  this.appendOriginal(originalCode.slice(prevO.length));
3980
4026
  this.lastKnownOriginalCode = originalCode;
3981
4027
  didImmediate = true;
3982
4028
  }
3983
- if (modifiedCode !== prevM && modifiedCode.startsWith(prevM)) {
4029
+ if (modifiedTailAppend) {
3984
4030
  this.appendModified(modifiedCode.slice(prevM.length));
3985
4031
  this.lastKnownModifiedCode = modifiedCode;
3986
4032
  didImmediate = true;
3987
4033
  }
4034
+ if (hasContentChange) this.preserveNativeDiffDecorationsOnStaleAppend = (originalCode === prevO || originalTailAppend) && (modifiedCode === prevM || modifiedTailAppend);
3988
4035
  if (originalCode !== this.lastKnownOriginalCode || modifiedCode !== this.lastKnownModifiedCode) {
3989
4036
  this.pendingDiffUpdate = {
3990
4037
  original: originalCode,
@@ -4001,8 +4048,10 @@ var DiffEditorManager = class DiffEditorManager {
4001
4048
  }
4002
4049
  const prev = this.lastKnownOriginalCode ?? this.originalModel.getValue();
4003
4050
  if (prev === newCode) return;
4051
+ const tailAppend = newCode.startsWith(prev) && prev.length < newCode.length;
4004
4052
  this.markDiffStreamingActivity();
4005
- if (newCode.startsWith(prev) && prev.length < newCode.length) this.appendOriginal(newCode.slice(prev.length), codeLanguage);
4053
+ this.preserveNativeDiffDecorationsOnStaleAppend = tailAppend;
4054
+ if (tailAppend) this.appendOriginal(newCode.slice(prev.length), codeLanguage);
4006
4055
  else {
4007
4056
  this.flushOriginalAppendBufferSync();
4008
4057
  this.applyMinimalEditToModel(this.originalModel, prev, newCode);
@@ -4017,8 +4066,10 @@ var DiffEditorManager = class DiffEditorManager {
4017
4066
  }
4018
4067
  const prev = this.lastKnownModifiedCode ?? this.modifiedModel.getValue();
4019
4068
  if (prev === newCode) return;
4069
+ const tailAppend = newCode.startsWith(prev) && prev.length < newCode.length;
4020
4070
  this.markDiffStreamingActivity();
4021
- if (newCode.startsWith(prev) && prev.length < newCode.length) this.appendModified(newCode.slice(prev.length), codeLanguage);
4071
+ this.preserveNativeDiffDecorationsOnStaleAppend = tailAppend;
4072
+ if (tailAppend) this.appendModified(newCode.slice(prev.length), codeLanguage);
4022
4073
  else {
4023
4074
  this.flushModifiedAppendBufferSync();
4024
4075
  const prevAfterFlush = this.modifiedModel.getValue();
@@ -4042,6 +4093,7 @@ var DiffEditorManager = class DiffEditorManager {
4042
4093
  appendOriginal(appendText, codeLanguage) {
4043
4094
  if (!this.diffEditorView || !this.originalModel || !appendText) return;
4044
4095
  this.markDiffStreamingActivity();
4096
+ this.preserveNativeDiffDecorationsOnStaleAppend = true;
4045
4097
  if (codeLanguage) {
4046
4098
  const lang = processedLanguage(codeLanguage);
4047
4099
  if (lang && this.originalModel.getLanguageId() !== lang) monaco_shim_exports.editor.setModelLanguage(this.originalModel, lang);
@@ -4052,6 +4104,7 @@ var DiffEditorManager = class DiffEditorManager {
4052
4104
  appendModified(appendText, codeLanguage) {
4053
4105
  if (!this.diffEditorView || !this.modifiedModel || !appendText) return;
4054
4106
  this.markDiffStreamingActivity();
4107
+ this.preserveNativeDiffDecorationsOnStaleAppend = true;
4055
4108
  if (codeLanguage) {
4056
4109
  const lang = processedLanguage(codeLanguage);
4057
4110
  if (lang && this.modifiedModel.getLanguageId() !== lang) monaco_shim_exports.editor.setModelLanguage(this.modifiedModel, lang);
@@ -4068,9 +4121,10 @@ var DiffEditorManager = class DiffEditorManager {
4068
4121
  if (this.modifiedModel && this.modifiedModel.getLanguageId() !== language) monaco_shim_exports.editor.setModelLanguage(this.modifiedModel, language);
4069
4122
  }
4070
4123
  async setDiffModels(models, options = {}) {
4071
- var _this$originalModel2, _this$modifiedModel5, _this$diffEditorView$5, _this$diffEditorView$6, _this$diffEditorView$7, _this$diffEditorView$8;
4124
+ var _this$originalModel2, _this$modifiedModel5, _this$diffEditorView$6, _this$diffEditorView$7, _this$diffEditorView$8, _this$diffEditorView$9;
4072
4125
  if (!this.diffEditorView) return;
4073
4126
  const transitionRequestId = ++this.diffModelTransitionRequestId;
4127
+ this.preserveNativeDiffDecorationsOnStaleAppend = false;
4074
4128
  this.disposePendingPreparedDiffViewModel();
4075
4129
  const nextOriginal = models.original;
4076
4130
  const nextModified = models.modified;
@@ -4121,6 +4175,7 @@ var DiffEditorManager = class DiffEditorManager {
4121
4175
  this.pendingDiffUpdate = null;
4122
4176
  this.flushOriginalAppendBufferSync();
4123
4177
  this.flushModifiedAppendBufferSync();
4178
+ this.preserveNativeDiffDecorationsOnStaleAppend = false;
4124
4179
  const currentOriginal = this.originalModel;
4125
4180
  const currentModified = this.modifiedModel;
4126
4181
  const shouldRestorePersistedUnchangedState = preserveViewState && !sameContent;
@@ -4130,8 +4185,8 @@ var DiffEditorManager = class DiffEditorManager {
4130
4185
  this.queuePendingDiffScrollRestore(preservedScrollPosition, shouldRestorePersistedUnchangedState ? 2 : 0);
4131
4186
  if (shouldRestorePersistedUnchangedState) this.capturePersistedDiffUnchangedState();
4132
4187
  const applyModelSwap = () => {
4133
- var _this$diffEditorView35;
4134
- (_this$diffEditorView35 = this.diffEditorView) === null || _this$diffEditorView35 === void 0 || _this$diffEditorView35.setModel(nextModelTarget);
4188
+ var _this$diffEditorView32;
4189
+ (_this$diffEditorView32 = this.diffEditorView) === null || _this$diffEditorView32 === void 0 || _this$diffEditorView32.setModel(nextModelTarget);
4135
4190
  };
4136
4191
  if (preserveViewState) this.withLockedDiffScrollPosition(applyModelSwap);
4137
4192
  else applyModelSwap();
@@ -4146,8 +4201,8 @@ var DiffEditorManager = class DiffEditorManager {
4146
4201
  this.lastKnownModifiedLineCount = nextModified.getLineCount();
4147
4202
  this.lastKnownModifiedDirty = false;
4148
4203
  this._hasScrollBar = false;
4149
- 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;
4150
- 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;
4204
+ 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;
4205
+ 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;
4151
4206
  this.cachedComputedHeightDiff = this.computedHeight();
4152
4207
  this.diffHunkLineChanges = this.getEffectiveLineChanges();
4153
4208
  this.hideDiffHunkActions();
@@ -4174,19 +4229,9 @@ var DiffEditorManager = class DiffEditorManager {
4174
4229
  }
4175
4230
  cleanup() {
4176
4231
  this.diffModelTransitionRequestId += 1;
4232
+ this.preserveNativeDiffDecorationsOnStaleAppend = false;
4177
4233
  this.disposePendingPreparedDiffViewModel();
4178
- this.rafScheduler.cancel("diff");
4179
- this.pendingDiffUpdate = null;
4180
- this.rafScheduler.cancel("appendDiff");
4181
- this.appendBufferDiffScheduled = false;
4182
- this.appendBufferOriginalDiff.length = 0;
4183
- this.appendBufferModifiedDiff.length = 0;
4184
- if (this.appendFlushThrottleTimerDiff != null) {
4185
- clearTimeout(this.appendFlushThrottleTimerDiff);
4186
- this.appendFlushThrottleTimerDiff = null;
4187
- }
4188
- this.rafScheduler.cancel("content-size-change-diff");
4189
- this.rafScheduler.cancel("sync-last-known-modified");
4234
+ this.clearAsyncWork();
4190
4235
  this.disposeDiffHunkInteractions();
4191
4236
  this.disposeDiffUnchangedRegionEnhancements();
4192
4237
  this.disposeDiffPresentationTracking();
@@ -4217,18 +4262,6 @@ var DiffEditorManager = class DiffEditorManager {
4217
4262
  this.lastContainer.innerHTML = "";
4218
4263
  this.lastContainer = null;
4219
4264
  }
4220
- if (this.revealDebounceIdDiff != null) {
4221
- clearTimeout(this.revealDebounceIdDiff);
4222
- this.revealDebounceIdDiff = null;
4223
- }
4224
- if (this.revealIdleTimerIdDiff != null) {
4225
- clearTimeout(this.revealIdleTimerIdDiff);
4226
- this.revealIdleTimerIdDiff = null;
4227
- }
4228
- if (this.diffScrollWatcherSuppressionTimer != null) {
4229
- clearTimeout(this.diffScrollWatcherSuppressionTimer);
4230
- this.diffScrollWatcherSuppressionTimer = null;
4231
- }
4232
4265
  this.revealTicketDiff = 0;
4233
4266
  this.lastRevealLineDiff = null;
4234
4267
  this.diffPersistedUnchangedModelState = null;
@@ -4236,23 +4269,13 @@ var DiffEditorManager = class DiffEditorManager {
4236
4269
  this.pendingDiffScrollRestoreBudget = 0;
4237
4270
  this.diffHideUnchangedRegionsResolved = null;
4238
4271
  this.diffHideUnchangedRegionsDeferred = false;
4239
- this.clearPendingDiffThemeSync();
4240
4272
  }
4241
4273
  safeClean() {
4242
4274
  this.diffModelTransitionRequestId += 1;
4275
+ this.preserveNativeDiffDecorationsOnStaleAppend = false;
4243
4276
  this.disposePendingPreparedDiffViewModel();
4244
- this.rafScheduler.cancel("diff");
4245
- this.pendingDiffUpdate = null;
4246
- this.rafScheduler.cancel("appendDiff");
4247
- this.appendBufferDiffScheduled = false;
4248
- this.appendBufferOriginalDiff.length = 0;
4249
- this.appendBufferModifiedDiff.length = 0;
4250
- if (this.appendFlushThrottleTimerDiff != null) {
4251
- clearTimeout(this.appendFlushThrottleTimerDiff);
4252
- this.appendFlushThrottleTimerDiff = null;
4253
- }
4277
+ this.clearAsyncWork();
4254
4278
  this.hideDiffHunkActions();
4255
- this.cancelScheduledHideDiffHunkActions();
4256
4279
  this.disposeDiffUnchangedRegionEnhancements();
4257
4280
  this.disposeDiffPresentationTracking();
4258
4281
  if (this.diffScrollWatcher) {
@@ -4266,25 +4289,10 @@ var DiffEditorManager = class DiffEditorManager {
4266
4289
  this.diffHeightManager.dispose();
4267
4290
  this.diffHeightManager = null;
4268
4291
  }
4269
- if (this.revealDebounceIdDiff != null) {
4270
- clearTimeout(this.revealDebounceIdDiff);
4271
- this.revealDebounceIdDiff = null;
4272
- }
4273
- if (this.revealIdleTimerIdDiff != null) {
4274
- clearTimeout(this.revealIdleTimerIdDiff);
4275
- this.revealIdleTimerIdDiff = null;
4276
- }
4277
- if (this.diffScrollWatcherSuppressionTimer != null) {
4278
- clearTimeout(this.diffScrollWatcherSuppressionTimer);
4279
- this.diffScrollWatcherSuppressionTimer = null;
4280
- }
4281
4292
  this.revealTicketDiff = 0;
4282
4293
  this.lastRevealLineDiff = null;
4283
4294
  this.diffPersistedUnchangedModelState = null;
4284
4295
  this.diffHideUnchangedRegionsDeferred = false;
4285
- this.clearPendingDiffThemeSync();
4286
- this.rafScheduler.cancel("content-size-change-diff");
4287
- this.rafScheduler.cancel("sync-last-known-modified");
4288
4296
  }
4289
4297
  syncLastKnownModified() {
4290
4298
  if (!this.diffEditorView || !this.lastKnownModifiedDirty) return;
@@ -4323,15 +4331,19 @@ var DiffEditorManager = class DiffEditorManager {
4323
4331
  if (this.lastKnownOriginalCode == null) this.lastKnownOriginalCode = o.getValue();
4324
4332
  if (this.lastKnownModifiedCode == null) this.lastKnownModifiedCode = m.getValue();
4325
4333
  const prevO = this.lastKnownOriginalCode;
4334
+ const originalTailAppend = prevO !== original && original.startsWith(prevO) && prevO.length < original.length;
4326
4335
  if (prevO !== original) {
4327
- if (original.startsWith(prevO) && prevO.length < original.length) this.appendToModel(o, original.slice(prevO.length));
4336
+ if (originalTailAppend) this.appendToModel(o, original.slice(prevO.length));
4328
4337
  else this.applyMinimalEditToModel(o, prevO, original);
4329
4338
  this.lastKnownOriginalCode = original;
4330
4339
  }
4331
4340
  const prevM = m.getValue();
4332
4341
  const prevMLineCount = m.getLineCount();
4342
+ const modifiedTailAppend = prevM !== modified && modified.startsWith(prevM) && prevM.length < modified.length;
4343
+ const hasContentChange = prevO !== original || prevM !== modified;
4344
+ if (hasContentChange) this.preserveNativeDiffDecorationsOnStaleAppend = (prevO === original || originalTailAppend) && (prevM === modified || modifiedTailAppend);
4333
4345
  if (prevM !== modified) {
4334
- if (modified.startsWith(prevM) && prevM.length < modified.length) this.appendToModel(m, modified.slice(prevM.length));
4346
+ if (modifiedTailAppend) this.appendToModel(m, modified.slice(prevM.length));
4335
4347
  else this.applyMinimalEditToModel(m, prevM, modified);
4336
4348
  this.lastKnownModifiedCode = modified;
4337
4349
  const newMLineCount = m.getLineCount();
@@ -4356,6 +4368,7 @@ var DiffEditorManager = class DiffEditorManager {
4356
4368
  const text = this.appendBufferModifiedDiff.join("");
4357
4369
  this.appendBufferModifiedDiff.length = 0;
4358
4370
  if (!text) return;
4371
+ this.preserveNativeDiffDecorationsOnStaleAppend = true;
4359
4372
  this.appendToModel(this.modifiedModel, text);
4360
4373
  }
4361
4374
  async flushAppendBufferDiff() {
@@ -4366,7 +4379,10 @@ var DiffEditorManager = class DiffEditorManager {
4366
4379
  if (this.originalModel && this.appendBufferOriginalDiff.length > 0) {
4367
4380
  const oText = this.appendBufferOriginalDiff.join("");
4368
4381
  this.appendBufferOriginalDiff.length = 0;
4369
- if (oText) this.appendToModel(this.originalModel, oText);
4382
+ if (oText) {
4383
+ this.preserveNativeDiffDecorationsOnStaleAppend = true;
4384
+ this.appendToModel(this.originalModel, oText);
4385
+ }
4370
4386
  }
4371
4387
  const me = this.diffEditorView.getModifiedEditor();
4372
4388
  const model = me.getModel();
@@ -4415,6 +4431,7 @@ var DiffEditorManager = class DiffEditorManager {
4415
4431
  });
4416
4432
  const lastColumn$1 = model.getLineMaxColumn(prevLine);
4417
4433
  const range$1 = new monaco_shim_exports.Range(prevLine, lastColumn$1, prevLine, lastColumn$1);
4434
+ this.preserveNativeDiffDecorationsOnStaleAppend = true;
4418
4435
  model.applyEdits([{
4419
4436
  range: range$1,
4420
4437
  text: part,
@@ -4453,6 +4470,7 @@ var DiffEditorManager = class DiffEditorManager {
4453
4470
  prevLine = model.getLineCount();
4454
4471
  const lastColumn = model.getLineMaxColumn(prevLine);
4455
4472
  const range = new monaco_shim_exports.Range(prevLine, lastColumn, prevLine, lastColumn);
4473
+ this.preserveNativeDiffDecorationsOnStaleAppend = true;
4456
4474
  model.applyEdits([{
4457
4475
  range,
4458
4476
  text,
@@ -4469,9 +4487,8 @@ var DiffEditorManager = class DiffEditorManager {
4469
4487
  else this.maybeScrollDiffToBottom(newLine, prevLine);
4470
4488
  if (suppressedByFlush) watcherApi.setSuppressed(false);
4471
4489
  try {
4472
- var _this$diffEditorView36, _this$diffEditorView37, _this$diffEditorView38;
4473
- this.shouldAutoScrollDiff = true;
4474
- 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;
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;
4475
4492
  } catch {}
4476
4493
  }
4477
4494
  applyMinimalEditToModel(model, prev, next) {
@@ -4519,6 +4536,9 @@ var EditorManager = class {
4519
4536
  lastKnownCode = null;
4520
4537
  pendingUpdate = null;
4521
4538
  _hasScrollBar = false;
4539
+ updateThrottleMs = 50;
4540
+ lastUpdateFlushTime = 0;
4541
+ updateThrottleTimer = null;
4522
4542
  shouldAutoScroll = true;
4523
4543
  scrollWatcher = null;
4524
4544
  scrollWatcherSuppressionTimer = null;
@@ -4528,6 +4548,7 @@ var EditorManager = class {
4528
4548
  cachedComputedHeight = null;
4529
4549
  cachedLineCount = null;
4530
4550
  lastKnownCodeDirty = false;
4551
+ programmaticContentChangeDepth = 0;
4531
4552
  debug = false;
4532
4553
  measureViewport() {
4533
4554
  var _this$editorView$getL, _this$editorView, _this$editorView$getS, _this$editorView2, _this$editorView$getS2, _this$editorView3;
@@ -4560,7 +4581,7 @@ var EditorManager = class {
4560
4581
  revealStrategyOption;
4561
4582
  revealBatchOnIdleMsOption;
4562
4583
  scrollWatcherSuppressionMs = 500;
4563
- constructor(options, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, revealDebounceMsOption) {
4584
+ constructor(options, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, revealDebounceMsOption, updateThrottleMsOption) {
4564
4585
  this.options = options;
4565
4586
  this.maxHeightValue = maxHeightValue;
4566
4587
  this.maxHeightCSS = maxHeightCSS;
@@ -4569,6 +4590,47 @@ var EditorManager = class {
4569
4590
  this.autoScrollThresholdPx = autoScrollThresholdPx;
4570
4591
  this.autoScrollThresholdLines = autoScrollThresholdLines;
4571
4592
  this.revealDebounceMsOption = revealDebounceMsOption;
4593
+ this.updateThrottleMsOption = updateThrottleMsOption;
4594
+ this.updateThrottleMs = this.updateThrottleMsOption ?? this.options.updateThrottleMs ?? 50;
4595
+ }
4596
+ cancelRafs() {
4597
+ this.rafScheduler.cancel("update");
4598
+ this.rafScheduler.cancel("sync-last-known");
4599
+ this.rafScheduler.cancel("content-size-change");
4600
+ this.rafScheduler.cancel("maybe-scroll");
4601
+ this.rafScheduler.cancel("reveal");
4602
+ this.rafScheduler.cancel("immediate-reveal");
4603
+ this.rafScheduler.cancel("maybe-resume");
4604
+ this.rafScheduler.cancel("append");
4605
+ }
4606
+ clearRevealTimers() {
4607
+ if (this.revealDebounceId != null) {
4608
+ clearTimeout(this.revealDebounceId);
4609
+ this.revealDebounceId = null;
4610
+ }
4611
+ if (this.revealIdleTimerId != null) {
4612
+ clearTimeout(this.revealIdleTimerId);
4613
+ this.revealIdleTimerId = null;
4614
+ }
4615
+ }
4616
+ resetAppendState() {
4617
+ this.appendBufferScheduled = false;
4618
+ this.appendBuffer.length = 0;
4619
+ }
4620
+ clearAsyncWork() {
4621
+ this.cancelRafs();
4622
+ this.pendingUpdate = null;
4623
+ this.lastKnownCodeDirty = false;
4624
+ this.resetAppendState();
4625
+ this.clearRevealTimers();
4626
+ if (this.scrollWatcherSuppressionTimer != null) {
4627
+ clearTimeout(this.scrollWatcherSuppressionTimer);
4628
+ this.scrollWatcherSuppressionTimer = null;
4629
+ }
4630
+ if (this.updateThrottleTimer != null) {
4631
+ clearTimeout(this.updateThrottleTimer);
4632
+ this.updateThrottleTimer = null;
4633
+ }
4572
4634
  }
4573
4635
  initDebugFlag() {
4574
4636
  if (typeof window !== "undefined" && window.__STREAM_MONACO_DEBUG__ !== void 0) {
@@ -4585,6 +4647,14 @@ var EditorManager = class {
4585
4647
  if (!this.debug) return;
4586
4648
  log("EditorManager", ...args);
4587
4649
  }
4650
+ runAsProgrammaticContentChange(fn) {
4651
+ this.programmaticContentChangeDepth += 1;
4652
+ try {
4653
+ return fn();
4654
+ } finally {
4655
+ this.programmaticContentChangeDepth -= 1;
4656
+ }
4657
+ }
4588
4658
  hasVerticalScrollbar() {
4589
4659
  if (!this.editorView) return false;
4590
4660
  if (this._hasScrollBar) return true;
@@ -4811,6 +4881,7 @@ var EditorManager = class {
4811
4881
  });
4812
4882
  });
4813
4883
  this.editorView.onDidChangeModelContent(() => {
4884
+ if (this.programmaticContentChangeDepth > 0) return;
4814
4885
  this.lastKnownCodeDirty = true;
4815
4886
  this.rafScheduler.schedule("sync-last-known", () => this.syncLastKnownCode());
4816
4887
  });
@@ -4905,7 +4976,24 @@ var EditorManager = class {
4905
4976
  code: newCode,
4906
4977
  lang: codeLanguage
4907
4978
  };
4908
- this.rafScheduler.schedule("update", () => this.flushPendingUpdate());
4979
+ this.rafScheduler.schedule("update", () => {
4980
+ if (!this.updateThrottleMs) {
4981
+ this.flushPendingUpdate();
4982
+ return;
4983
+ }
4984
+ const now = Date.now();
4985
+ const since = now - this.lastUpdateFlushTime;
4986
+ if (since >= this.updateThrottleMs) {
4987
+ this.flushPendingUpdate();
4988
+ return;
4989
+ }
4990
+ if (this.updateThrottleTimer != null) return;
4991
+ const wait = this.updateThrottleMs - since;
4992
+ this.updateThrottleTimer = setTimeout(() => {
4993
+ this.updateThrottleTimer = null;
4994
+ this.rafScheduler.schedule("update", () => this.flushPendingUpdate());
4995
+ }, wait);
4996
+ });
4909
4997
  }
4910
4998
  flushPendingUpdate() {
4911
4999
  if (!this.pendingUpdate || !this.editorView) return;
@@ -4913,12 +5001,15 @@ var EditorManager = class {
4913
5001
  if (!model) return;
4914
5002
  const { code: newCode, lang: codeLanguage } = this.pendingUpdate;
4915
5003
  this.pendingUpdate = null;
5004
+ this.lastUpdateFlushTime = Date.now();
4916
5005
  const processedCodeLanguage = processedLanguage(codeLanguage);
4917
5006
  const languageId = model.getLanguageId();
4918
5007
  if (languageId !== processedCodeLanguage) {
4919
5008
  if (processedCodeLanguage) monaco_shim_exports.editor.setModelLanguage(model, processedCodeLanguage);
4920
5009
  const prevLineCount$1 = model.getLineCount();
4921
- model.setValue(newCode);
5010
+ this.runAsProgrammaticContentChange(() => {
5011
+ model.setValue(newCode);
5012
+ });
4922
5013
  this.lastKnownCode = newCode;
4923
5014
  const newLineCount$1 = model.getLineCount();
4924
5015
  this.cachedLineCount = newLineCount$1;
@@ -4931,8 +5022,21 @@ var EditorManager = class {
4931
5022
  }
4932
5023
  return;
4933
5024
  }
4934
- const buffered = this.appendBuffer.length > 0 ? this.appendBuffer.join("") : "";
4935
- const prevCode = this.appendBuffer.length > 0 ? this.editorView.getValue() + buffered : this.lastKnownCode ?? this.editorView.getValue();
5025
+ let prevCode;
5026
+ if (this.appendBuffer.length > 0) {
5027
+ this.resetAppendState();
5028
+ this.rafScheduler.cancel("append");
5029
+ try {
5030
+ prevCode = model.getValue();
5031
+ this.lastKnownCode = prevCode;
5032
+ } catch {
5033
+ prevCode = this.lastKnownCode ?? "";
5034
+ }
5035
+ } else if (this.lastKnownCode != null) prevCode = this.lastKnownCode;
5036
+ else {
5037
+ prevCode = this.editorView.getValue();
5038
+ this.lastKnownCode = prevCode;
5039
+ }
4936
5040
  if (prevCode === newCode) return;
4937
5041
  if (newCode.startsWith(prevCode) && prevCode.length < newCode.length) {
4938
5042
  const suffix = newCode.slice(prevCode.length);
@@ -4976,7 +5080,9 @@ var EditorManager = class {
4976
5080
  const changeRatio = maxLen > 0 ? Math.abs(next.length - prev.length) / maxLen : 0;
4977
5081
  if (prev.length + next.length > maxChars || changeRatio > ratio) {
4978
5082
  const prevLineCount = model.getLineCount();
4979
- model.setValue(next);
5083
+ this.runAsProgrammaticContentChange(() => {
5084
+ model.setValue(next);
5085
+ });
4980
5086
  this.lastKnownCode = next;
4981
5087
  const newLineCount = model.getLineCount();
4982
5088
  this.cachedLineCount = newLineCount;
@@ -4995,8 +5101,10 @@ var EditorManager = class {
4995
5101
  text: replaceText,
4996
5102
  forceMoveMarkers: true
4997
5103
  }];
4998
- if (isReadOnly) model.applyEdits(edit);
4999
- else this.editorView.executeEdits("minimal-replace", edit);
5104
+ this.runAsProgrammaticContentChange(() => {
5105
+ if (isReadOnly) model.applyEdits(edit);
5106
+ else this.editorView.executeEdits("minimal-replace", edit);
5107
+ });
5000
5108
  }
5001
5109
  flushAppendBuffer() {
5002
5110
  if (!this.editorView) return;
@@ -5013,19 +5121,20 @@ var EditorManager = class {
5013
5121
  const lastColumn = model.getLineMaxColumn(lastLine);
5014
5122
  const range = new monaco_shim_exports.Range(lastLine, lastColumn, lastLine, lastColumn);
5015
5123
  const isReadOnly = this.editorView.getOption(monaco_shim_exports.editor.EditorOption.readOnly);
5016
- if (isReadOnly) model.applyEdits([{
5017
- range,
5018
- text,
5019
- forceMoveMarkers: true
5020
- }]);
5021
- else this.editorView.executeEdits("append", [{
5022
- range,
5023
- text,
5024
- forceMoveMarkers: true
5025
- }]);
5026
- try {
5027
- this.lastKnownCode = model.getValue();
5028
- } catch {}
5124
+ this.runAsProgrammaticContentChange(() => {
5125
+ if (isReadOnly) model.applyEdits([{
5126
+ range,
5127
+ text,
5128
+ forceMoveMarkers: true
5129
+ }]);
5130
+ else this.editorView.executeEdits("append", [{
5131
+ range,
5132
+ text,
5133
+ forceMoveMarkers: true
5134
+ }]);
5135
+ });
5136
+ if (this.lastKnownCode != null) this.lastKnownCode = this.lastKnownCode + text;
5137
+ else this.lastKnownCode = model.getValue();
5029
5138
  const newLineCount = model.getLineCount();
5030
5139
  if (lastLine !== newLineCount) {
5031
5140
  this.cachedLineCount = newLineCount;
@@ -5050,30 +5159,19 @@ var EditorManager = class {
5050
5159
  getEditorView() {
5051
5160
  return this.editorView;
5052
5161
  }
5053
- cleanup() {
5054
- this.rafScheduler.cancel("update");
5055
- this.rafScheduler.cancel("sync-last-known");
5056
- this.rafScheduler.cancel("content-size-change");
5057
- this.rafScheduler.cancel("maybe-scroll");
5058
- this.rafScheduler.cancel("reveal");
5059
- this.rafScheduler.cancel("immediate-reveal");
5060
- this.rafScheduler.cancel("maybe-resume");
5061
- this.pendingUpdate = null;
5062
- this.rafScheduler.cancel("append");
5063
- this.appendBufferScheduled = false;
5064
- this.appendBuffer.length = 0;
5065
- if (this.revealDebounceId != null) {
5066
- clearTimeout(this.revealDebounceId);
5067
- this.revealDebounceId = null;
5068
- }
5069
- if (this.revealIdleTimerId != null) {
5070
- clearTimeout(this.revealIdleTimerId);
5071
- this.revealIdleTimerId = null;
5072
- }
5073
- if (this.scrollWatcherSuppressionTimer != null) {
5074
- clearTimeout(this.scrollWatcherSuppressionTimer);
5075
- this.scrollWatcherSuppressionTimer = null;
5162
+ setUpdateThrottleMs(ms) {
5163
+ this.updateThrottleMs = ms;
5164
+ if (!this.updateThrottleMs && this.updateThrottleTimer != null) {
5165
+ clearTimeout(this.updateThrottleTimer);
5166
+ this.updateThrottleTimer = null;
5167
+ this.rafScheduler.schedule("update", () => this.flushPendingUpdate());
5076
5168
  }
5169
+ }
5170
+ getUpdateThrottleMs() {
5171
+ return this.updateThrottleMs;
5172
+ }
5173
+ cleanup() {
5174
+ this.clearAsyncWork();
5077
5175
  if (this.editorView) {
5078
5176
  this.editorView.dispose();
5079
5177
  this.editorView = null;
@@ -5094,31 +5192,13 @@ var EditorManager = class {
5094
5192
  }
5095
5193
  }
5096
5194
  safeClean() {
5097
- this.rafScheduler.cancel("update");
5098
- this.pendingUpdate = null;
5099
- this.rafScheduler.cancel("sync-last-known");
5195
+ this.clearAsyncWork();
5100
5196
  if (this.scrollWatcher) {
5101
5197
  try {
5102
5198
  this.scrollWatcher.dispose();
5103
5199
  } catch {}
5104
5200
  this.scrollWatcher = null;
5105
5201
  }
5106
- if (this.revealDebounceId != null) {
5107
- clearTimeout(this.revealDebounceId);
5108
- this.revealDebounceId = null;
5109
- }
5110
- if (this.revealIdleTimerId != null) {
5111
- clearTimeout(this.revealIdleTimerId);
5112
- this.revealIdleTimerId = null;
5113
- }
5114
- if (this.scrollWatcherSuppressionTimer != null) {
5115
- clearTimeout(this.scrollWatcherSuppressionTimer);
5116
- this.scrollWatcherSuppressionTimer = null;
5117
- }
5118
- this.rafScheduler.cancel("maybe-scroll");
5119
- this.rafScheduler.cancel("reveal");
5120
- this.rafScheduler.cancel("immediate-reveal");
5121
- this.rafScheduler.cancel("maybe-resume");
5122
5202
  this._hasScrollBar = false;
5123
5203
  this.shouldAutoScroll = !!this.autoScrollInitial;
5124
5204
  this.lastScrollTop = 0;
@@ -5657,7 +5737,7 @@ function useMonaco(monacoOptions = {}) {
5657
5737
  }
5658
5738
  const initialThemeName = monacoOptions.theme ?? requestedThemeName ?? globalRequestedThemeName ?? currentTheme.value;
5659
5739
  await ensureThemeRegistered(initialThemeName);
5660
- editorMgr = new EditorManager(monacoOptions, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, monacoOptions.revealDebounceMs);
5740
+ editorMgr = new EditorManager(monacoOptions, maxHeightValue, maxHeightCSS, autoScrollOnUpdate, autoScrollInitial, autoScrollThresholdPx, autoScrollThresholdLines, monacoOptions.revealDebounceMs, updateThrottleMs);
5661
5741
  editorView = await editorMgr.createEditor(container, code, language, initialThemeName);
5662
5742
  if (pendingUpdate && editorMgr) {
5663
5743
  const { code: queuedCode, lang: queuedLang } = pendingUpdate;
@@ -5699,6 +5779,23 @@ function useMonaco(monacoOptions = {}) {
5699
5779
  modifiedModel = models.modified;
5700
5780
  return diffEditorView;
5701
5781
  }
5782
+ function clearFallbackAsyncWork() {
5783
+ rafScheduler.cancel("update");
5784
+ rafScheduler.cancel("append");
5785
+ rafScheduler.cancel("reveal");
5786
+ pendingUpdate = null;
5787
+ appendBufferScheduled = false;
5788
+ appendBuffer.length = 0;
5789
+ if (revealDebounceId != null) {
5790
+ clearTimeout(revealDebounceId);
5791
+ revealDebounceId = null;
5792
+ }
5793
+ if (updateThrottleTimer != null) {
5794
+ clearTimeout(updateThrottleTimer);
5795
+ updateThrottleTimer = null;
5796
+ }
5797
+ lastFlushTime = 0;
5798
+ }
5702
5799
  function cleanupEditor() {
5703
5800
  if (editorMgr) {
5704
5801
  editorMgr.cleanup();
@@ -5708,11 +5805,7 @@ function useMonaco(monacoOptions = {}) {
5708
5805
  diffMgr.cleanup();
5709
5806
  diffMgr = null;
5710
5807
  }
5711
- rafScheduler.cancel("update");
5712
- pendingUpdate = null;
5713
- rafScheduler.cancel("append");
5714
- appendBufferScheduled = false;
5715
- appendBuffer.length = 0;
5808
+ clearFallbackAsyncWork();
5716
5809
  if (!editorMgr && editorView) {
5717
5810
  editorView.dispose();
5718
5811
  editorView = null;
@@ -5726,10 +5819,6 @@ function useMonaco(monacoOptions = {}) {
5726
5819
  themeWatcher();
5727
5820
  themeWatcher = null;
5728
5821
  }
5729
- if (updateThrottleTimer != null) {
5730
- clearTimeout(updateThrottleTimer);
5731
- updateThrottleTimer = null;
5732
- }
5733
5822
  diffEditorView = null;
5734
5823
  originalModel = null;
5735
5824
  modifiedModel = null;
@@ -5795,13 +5884,17 @@ function useMonaco(monacoOptions = {}) {
5795
5884
  pendingUpdate = null;
5796
5885
  const processedCodeLanguage = processedLanguage(codeLanguage);
5797
5886
  let prevCode = null;
5798
- if (appendBuffer.length > 0) try {
5799
- prevCode = model.getValue();
5800
- lastKnownCode = prevCode;
5801
- } catch {
5802
- prevCode = "";
5803
- }
5804
- else {
5887
+ if (appendBuffer.length > 0) {
5888
+ appendBuffer.length = 0;
5889
+ appendBufferScheduled = false;
5890
+ rafScheduler.cancel("append");
5891
+ try {
5892
+ prevCode = model.getValue();
5893
+ lastKnownCode = prevCode;
5894
+ } catch {
5895
+ prevCode = lastKnownCode ?? "";
5896
+ }
5897
+ } else {
5805
5898
  prevCode = lastKnownCode;
5806
5899
  if (prevCode == null) try {
5807
5900
  prevCode = model.getValue();
@@ -5918,9 +6011,10 @@ function useMonaco(monacoOptions = {}) {
5918
6011
  }
5919
6012
  function setUpdateThrottleMs(ms) {
5920
6013
  updateThrottleMs = ms;
6014
+ editorMgr === null || editorMgr === void 0 || editorMgr.setUpdateThrottleMs(ms);
5921
6015
  }
5922
6016
  function getUpdateThrottleMs() {
5923
- return updateThrottleMs;
6017
+ return (editorMgr === null || editorMgr === void 0 ? void 0 : editorMgr.getUpdateThrottleMs()) ?? updateThrottleMs;
5924
6018
  }
5925
6019
  function updateDiff(originalCode, modifiedCode, codeLanguage) {
5926
6020
  if (diffMgr) diffMgr.updateDiff(originalCode, modifiedCode, codeLanguage);
@@ -5952,8 +6046,7 @@ function useMonaco(monacoOptions = {}) {
5952
6046
  createDiffEditor,
5953
6047
  cleanupEditor,
5954
6048
  safeClean() {
5955
- rafScheduler.cancel("update");
5956
- pendingUpdate = null;
6049
+ clearFallbackAsyncWork();
5957
6050
  if (editorMgr) try {
5958
6051
  editorMgr.safeClean();
5959
6052
  } catch {}