@cascadetui/core 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -153,7 +153,7 @@ import {
153
153
  white,
154
154
  wrapWithDelegates,
155
155
  yellow
156
- } from "./index-r7vqrd61.js";
156
+ } from "./index-2pvbxs43.js";
157
157
  // src/text-buffer-view.ts
158
158
  class TextBufferView {
159
159
  lib;
@@ -2764,6 +2764,10 @@ class TextBufferRenderable extends Renderable {
2764
2764
  _scrollX = 0;
2765
2765
  _scrollY = 0;
2766
2766
  _truncate = false;
2767
+ _measureCallCount = 0;
2768
+ _lastMeasureReset = 0;
2769
+ static MEASURE_RESET_INTERVAL_MS = 1000;
2770
+ static MAX_MEASURE_CALLS_PER_INTERVAL = 100;
2767
2771
  textBuffer;
2768
2772
  textBufferView;
2769
2773
  _textBufferSyntaxStyle;
@@ -3041,6 +3045,19 @@ class TextBufferRenderable extends Renderable {
3041
3045
  }
3042
3046
  setupMeasureFunc() {
3043
3047
  const measureFunc = (width, widthMode, height, heightMode) => {
3048
+ const now = Date.now();
3049
+ if (now - this._lastMeasureReset > TextBufferRenderable.MEASURE_RESET_INTERVAL_MS) {
3050
+ this._measureCallCount = 0;
3051
+ this._lastMeasureReset = now;
3052
+ }
3053
+ this._measureCallCount++;
3054
+ if (this._measureCallCount > TextBufferRenderable.MAX_MEASURE_CALLS_PER_INTERVAL) {
3055
+ console.warn(`[Cascade] Measure loop detected on ${this.id}, returning cached dimensions`);
3056
+ return {
3057
+ width: Math.max(1, this.width),
3058
+ height: Math.max(1, this.height)
3059
+ };
3060
+ }
3044
3061
  let effectiveWidth;
3045
3062
  if (widthMode === MeasureMode.Undefined || isNaN(width)) {
3046
3063
  effectiveWidth = 0;
@@ -12425,5 +12442,5 @@ export {
12425
12442
  ASCIIFont
12426
12443
  };
12427
12444
 
12428
- //# debugId=FC3249AEF487030064756E2164756E21
12445
+ //# debugId=D5FCF66CD1AA657064756E2164756E21
12429
12446
  //# sourceMappingURL=index.js.map