@saifymatteo/pi-cell-actions 0.1.2 → 0.1.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.
- package/CHANGELOG.md +6 -0
- package/package.json +1 -1
- package/src/cells.ts +28 -4
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.1.3] - 2026-11-30
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- A code block whose first or last line wraps in the transcript gets its copy and run menu again; long one-line commands at some terminal widths fell back to the surrounding paragraph's text copy.
|
|
10
|
+
|
|
5
11
|
## [0.1.2] - 2026-11-27
|
|
6
12
|
|
|
7
13
|
### Changed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saifymatteo/pi-cell-actions",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"description": "Hover a transcript cell for a ⋯ menu: copy messages, code, tables (Markdown/TSV/CSV) and tool calls; run shell blocks",
|
|
6
6
|
"engines": {
|
package/src/cells.ts
CHANGED
|
@@ -98,6 +98,24 @@ function isFenceBorder(text: string, lang: string): boolean {
|
|
|
98
98
|
return t.startsWith("```") || t.startsWith("~~~") || /─{3,}/.test(t) || (lang !== "" && t === lang);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
/**
|
|
102
|
+
* First row at or after `from` where `needle` starts, and the row where it ends, matching
|
|
103
|
+
* across row breaks with whitespace removed: renderers wrap long code lines at any column.
|
|
104
|
+
*/
|
|
105
|
+
function findAcrossRows(rows: string[], needle: string, from: number): { start: number; end: number } | undefined {
|
|
106
|
+
const target = needle.replace(/\s/g, "");
|
|
107
|
+
if (!target) return undefined;
|
|
108
|
+
let joined = "";
|
|
109
|
+
const rowAt: number[] = [];
|
|
110
|
+
for (let i = from; i < rows.length; i++) {
|
|
111
|
+
const text = rows[i].replace(/\s/g, "");
|
|
112
|
+
joined += text;
|
|
113
|
+
for (let k = 0; k < text.length; k++) rowAt.push(i);
|
|
114
|
+
}
|
|
115
|
+
const at = joined.indexOf(target);
|
|
116
|
+
return at === -1 ? undefined : { start: rowAt[at], end: rowAt[at + target.length - 1] };
|
|
117
|
+
}
|
|
118
|
+
|
|
101
119
|
/**
|
|
102
120
|
* Map source blocks to the rows a renderer drew them on, by content: renderers
|
|
103
121
|
* differ (stock fences, shaded blocks, pi-codeblock-borders rules and gutters),
|
|
@@ -126,10 +144,16 @@ export function locateBlocks(rows: string[], blocks: SourceBlock[]): LocatedBloc
|
|
|
126
144
|
const lastIndex = codeLines.findLastIndex((line) => line.trim() !== "");
|
|
127
145
|
const head = codeLines[firstIndex].trim().slice(0, 40);
|
|
128
146
|
const tail = codeLines[lastIndex].trim().slice(-30);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
147
|
+
let start = rows.findIndex((row, i) => i >= cursor && row.includes(head));
|
|
148
|
+
let end = start === -1 ? -1 : rows.findIndex((row, i) => i >= start + (lastIndex - firstIndex) && row.includes(tail));
|
|
149
|
+
if (end === -1) {
|
|
150
|
+
// A wrap split the head or tail across rows; match without whitespace instead.
|
|
151
|
+
const first = findAcrossRows(rows, head, cursor);
|
|
152
|
+
const last = first && findAcrossRows(rows, tail, first.start);
|
|
153
|
+
if (!first || !last) continue;
|
|
154
|
+
start = first.start;
|
|
155
|
+
end = Math.max(last.end, first.end);
|
|
156
|
+
}
|
|
133
157
|
const top = start > 0 && isFenceBorder(rows[start - 1], block.lang) ? start - 1 : start;
|
|
134
158
|
const bottom = end + 1 < rows.length && isFenceBorder(rows[end + 1], block.lang) ? end + 1 : end;
|
|
135
159
|
located.push({ ...block, top, bottom });
|