@pi-archimedes/diff 0.2.0 → 0.3.0

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.
Files changed (2) hide show
  1. package/package.json +5 -11
  2. package/src/index.ts +5 -11
package/package.json CHANGED
@@ -1,14 +1,10 @@
1
1
  {
2
2
  "name": "@pi-archimedes/diff",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
- "keywords": [
6
- "pi-package"
7
- ],
5
+ "keywords": ["pi-package"],
8
6
  "description": "Shiki-powered diff rendering for pi-archimedes",
9
- "files": [
10
- "src"
11
- ],
7
+ "files": ["src"],
12
8
  "main": "./src/index.ts",
13
9
  "exports": {
14
10
  ".": "./src/index.ts"
@@ -27,8 +23,6 @@
27
23
  "typescript": "^6.0.0"
28
24
  },
29
25
  "pi": {
30
- "extensions": [
31
- "./src/index.ts"
32
- ]
26
+ "extensions": ["./src/index.ts"]
33
27
  }
34
- }
28
+ }
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 = ` ${d.summary}\n${theme.fg("muted", " rendering diff…")}`;
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 = ` ${d.summary}\n${rendered}`;
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
- const content = ` ${s}${loc}`;
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
- const content = ` ${editCount} edits ${s}${typeof diffLineCount === "number" ? ` ${theme.fg("muted", `(${diffLineCount} diff lines)`)}` : ""}`;
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))}`);