@giovannijecha/jecode 0.3.1 → 0.3.2
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/dist/tui/components/tool.js +3 -49
- package/dist/ui/theme.js +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { hasColor, row } from "../../ui/render.js";
|
|
3
3
|
const OUTPUT_ROWS = 8;
|
|
4
4
|
const LIVE_OUTPUT_ROWS = 6;
|
|
5
|
-
const DIFF_ROWS = 12;
|
|
6
5
|
export function renderTool(block, width, pal, context = {}) {
|
|
7
6
|
const shown = visibleDetails(block);
|
|
8
7
|
const right = liveLabel(block, context);
|
|
@@ -31,54 +30,9 @@ function visibleDetails(block) {
|
|
|
31
30
|
: `… ${hidden} earlier lines · ctrl+o expand`;
|
|
32
31
|
return [{ kind: "gap", text: note }, ...all.slice(-limit)];
|
|
33
32
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
function diffWindow(all) {
|
|
38
|
-
if (all.length <= DIFF_ROWS)
|
|
39
|
-
return [...all];
|
|
40
|
-
const important = all.flatMap((detail, index) => detail.kind === "keep" ? [] : [index]);
|
|
41
|
-
const chosen = new Set();
|
|
42
|
-
const budgeted = important.length <= DIFF_ROWS
|
|
43
|
-
? important
|
|
44
|
-
: [
|
|
45
|
-
...important.slice(0, Math.ceil(DIFF_ROWS / 2)),
|
|
46
|
-
...important.slice(-Math.floor(DIFF_ROWS / 2)),
|
|
47
|
-
];
|
|
48
|
-
for (const index of budgeted)
|
|
49
|
-
chosen.add(index);
|
|
50
|
-
for (let radius = 1; chosen.size < DIFF_ROWS && radius < all.length; radius++) {
|
|
51
|
-
for (const index of important) {
|
|
52
|
-
for (const candidate of [index - radius, index + radius]) {
|
|
53
|
-
if (candidate < 0 || candidate >= all.length || chosen.has(candidate))
|
|
54
|
-
continue;
|
|
55
|
-
chosen.add(candidate);
|
|
56
|
-
if (chosen.size >= DIFF_ROWS)
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
if (chosen.size >= DIFF_ROWS)
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const indexes = [...chosen].sort((left, right) => left - right);
|
|
64
|
-
const out = [];
|
|
65
|
-
let previous = -1;
|
|
66
|
-
for (const index of indexes) {
|
|
67
|
-
if (index > previous + 1) {
|
|
68
|
-
out.push({ kind: "gap", text: `… ${index - previous - 1} lines hidden · ctrl+o expand` });
|
|
69
|
-
}
|
|
70
|
-
const detail = all[index];
|
|
71
|
-
if (detail !== undefined)
|
|
72
|
-
out.push(detail);
|
|
73
|
-
previous = index;
|
|
74
|
-
}
|
|
75
|
-
if (previous < all.length - 1) {
|
|
76
|
-
out.push({
|
|
77
|
-
kind: "gap",
|
|
78
|
-
text: `… ${all.length - previous - 1} lines hidden · ctrl+o expand`,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return out;
|
|
33
|
+
// The compact transcript is an audit of what changed, not a code excerpt.
|
|
34
|
+
// Context and gap rows remain in semantic state for the explicit full view.
|
|
35
|
+
return all.filter((detail) => detail.kind === "add" || detail.kind === "del");
|
|
82
36
|
}
|
|
83
37
|
function renderDetail(detail, tone, width, pal) {
|
|
84
38
|
const lead = { text: " " };
|
package/dist/ui/theme.js
CHANGED