pi-fabric 0.61.2 → 0.61.3

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.
@@ -681,9 +681,9 @@ var fileHighlightRange = (entry, from, to, invalidate) => {
681
681
  entry.waiters.push({ to: clampedTo, invalidate });
682
682
  scheduleFileHighlight(entry);
683
683
  }
684
- if (entry.lines.length < to) return null;
684
+ if (entry.lines.length < clampedTo) return null;
685
685
  const out = [];
686
- for (let index = from; index < to; index++) {
686
+ for (let index = from; index < Math.min(to, total); index++) {
687
687
  out.push({ raw: entry.sourceLines[index] ?? "", ansi: entry.lines[index] ?? "" });
688
688
  }
689
689
  return out;
@@ -3225,20 +3225,26 @@ var highlightRemovedDiffLines = (parsed, filePath, language, cwd, invalidate) =>
3225
3225
  while (end < parsed.length && parsed[end]) end++;
3226
3226
  const block = parsed.slice(start, end);
3227
3227
  const removed = [];
3228
- let minContext = Infinity;
3228
+ const contextBefore = [];
3229
3229
  for (let offset = 0; offset < block.length; offset++) {
3230
3230
  const line = block[offset];
3231
3231
  const n = Number.parseInt(line.lineNumber.trim(), 10);
3232
- if (!Number.isFinite(n) || n <= 0) return null;
3232
+ if (!Number.isFinite(n) || n <= 0) continue;
3233
3233
  if (line.kind === "-") removed.push({ row: start + offset, n, content: expandTabs(line.content) });
3234
- else if (line.kind === " ") minContext = Math.min(minContext, n);
3234
+ else if (line.kind === " " && removed.length === 0) contextBefore.push({ n, content: expandTabs(line.content) });
3235
3235
  }
3236
3236
  if (removed.length === 0) return null;
3237
3237
  for (let index = 1; index < removed.length; index++) {
3238
3238
  if (removed[index].n !== removed[index - 1].n + 1) return null;
3239
3239
  }
3240
3240
  const firstRemoved = removed[0].n;
3241
- const anchor = Math.min(firstRemoved, minContext === Infinity ? firstRemoved : minContext);
3241
+ for (let index = 1; index < contextBefore.length; index++) {
3242
+ if (contextBefore[index].n !== contextBefore[index - 1].n + 1) return null;
3243
+ }
3244
+ if (contextBefore.length > 0 && contextBefore[contextBefore.length - 1].n !== firstRemoved - 1) {
3245
+ return null;
3246
+ }
3247
+ const anchor = contextBefore.length > 0 ? contextBefore[0].n : firstRemoved;
3242
3248
  const absolute = resolve(cwd, filePath);
3243
3249
  let stat;
3244
3250
  try {
@@ -3258,12 +3264,14 @@ var highlightRemovedDiffLines = (parsed, filePath, language, cwd, invalidate) =>
3258
3264
  for (const line of block) {
3259
3265
  if (line.kind !== " ") continue;
3260
3266
  const n = Number.parseInt(line.lineNumber.trim(), 10);
3267
+ if (!Number.isFinite(n)) continue;
3261
3268
  if (fileLines[n - 1] !== expandTabs(line.content)) return null;
3262
3269
  }
3263
3270
  const prefixCount = Math.max(0, Math.min(anchor - 1, DIFF_REMOVED_CONTEXT_LINES));
3264
3271
  const prefix = fileLines.slice(anchor - 1 - prefixCount, anchor - 1);
3265
3272
  const removedContents = removed.map((row) => row.content);
3266
- const virtual = [...prefix, ...removedContents];
3273
+ const contextContents = contextBefore.map((context) => context.content);
3274
+ const virtual = [...prefix, ...contextContents, ...removedContents];
3267
3275
  const cacheKey = `removed\0${language}\0${absolute}\0${hashSourceText(virtual.join("\n"))}`;
3268
3276
  const covered = highlightSourceLines(
3269
3277
  cacheKey,
@@ -3276,7 +3284,7 @@ var highlightRemovedDiffLines = (parsed, filePath, language, cwd, invalidate) =>
3276
3284
  if (!covered) return null;
3277
3285
  const out = /* @__PURE__ */ new Map();
3278
3286
  for (let index = 0; index < removed.length; index++) {
3279
- const entry = covered[index];
3287
+ const entry = covered[contextContents.length + index];
3280
3288
  if (entry && entry.raw === removed[index].content) out.set(removed[index].row, entry.ansi);
3281
3289
  }
3282
3290
  return out;
@@ -4980,4 +4988,4 @@ export {
4980
4988
  isActiveStatus,
4981
4989
  orderAgentsByCreation
4982
4990
  };
4983
- //# sourceMappingURL=chunk-ZQMNKN4L.js.map
4991
+ //# sourceMappingURL=chunk-DVOJW7LJ.js.map