@pi-archimedes/diff 0.2.0 → 0.3.1
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/package.json +1 -1
- package/src/index.ts +5 -11
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -201,12 +201,12 @@ export function registerDiffTools(
|
|
|
201
201
|
const key = `wd:${themeCacheKey(theme)}:${w}:${d.summary}:${d.diff?.lines?.length ?? 0}:${d.language ?? ""}`;
|
|
202
202
|
if (ctx.state._wdk !== key) {
|
|
203
203
|
ctx.state._wdk = key;
|
|
204
|
-
ctx.state._wdt =
|
|
204
|
+
ctx.state._wdt = `${" " + d.summary}\n${theme.fg("muted", " rendering diff…")}`;
|
|
205
205
|
const dc = resolveDiffColors(theme);
|
|
206
206
|
renderSplit(d.diff, d.language, MAX_RENDER_LINES, dc)
|
|
207
207
|
.then((rendered: string) => {
|
|
208
208
|
if (ctx.state._wdk !== key) return;
|
|
209
|
-
ctx.state._wdt =
|
|
209
|
+
ctx.state._wdt = `${" " + d.summary}\n${rendered}`;
|
|
210
210
|
ctx.invalidate();
|
|
211
211
|
})
|
|
212
212
|
.catch(() => {
|
|
@@ -359,7 +359,7 @@ export function registerDiffTools(
|
|
|
359
359
|
if (ctx.state._pk !== pk) return;
|
|
360
360
|
const remainder = operations.length - maxShown;
|
|
361
361
|
const suffix = remainder > 0 ? `\n${theme.fg("muted", `… ${remainder} more edit blocks`)}` : "";
|
|
362
|
-
ctx.state._pt = `${hdr}\n${operations.length} edits ${summary}\n\n${sections.join("\n\n")}${suffix}`;
|
|
362
|
+
ctx.state._pt = `${hdr}\n${`${operations.length} edits ${summary}`}\n\n${sections.join("\n\n")}${suffix}`;
|
|
363
363
|
ctx.invalidate();
|
|
364
364
|
})
|
|
365
365
|
.catch(() => {
|
|
@@ -387,18 +387,12 @@ export function registerDiffTools(
|
|
|
387
387
|
if (result.details?._type === "editInfo") {
|
|
388
388
|
const { summary: s, editLine } = result.details;
|
|
389
389
|
const loc = editLine > 0 ? ` ${theme.fg("muted", `at line ${editLine}`)}` : "";
|
|
390
|
-
|
|
391
|
-
const vis = content.replace(Ansi.ANSI_RE, "").length;
|
|
392
|
-
const pad = Math.max(0, (process.stdout.columns ?? 200) - vis);
|
|
393
|
-
text.setText(`${content}${" ".repeat(pad)}`);
|
|
390
|
+
text.setText(` ${s}${loc}`);
|
|
394
391
|
return text;
|
|
395
392
|
}
|
|
396
393
|
if (result.details?._type === "multiEditInfo") {
|
|
397
394
|
const { summary: s, editCount, diffLineCount } = result.details;
|
|
398
|
-
|
|
399
|
-
const vis = content.replace(Ansi.ANSI_RE, "").length;
|
|
400
|
-
const pad = Math.max(0, (process.stdout.columns ?? 200) - vis);
|
|
401
|
-
text.setText(`${content}${" ".repeat(pad)}`);
|
|
395
|
+
text.setText(` ${editCount} edits ${s}${typeof diffLineCount === "number" ? ` ${theme.fg("muted", `(${diffLineCount} diff lines)`)}` : ""}`);
|
|
402
396
|
return text;
|
|
403
397
|
}
|
|
404
398
|
text.setText(` ${theme.fg("dim", String(result?.content?.[0]?.text ?? "edited").slice(0, 120))}`);
|