@runminton/pi-tidy-tools 0.2.1 → 0.2.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/README.md +4 -0
- package/README.zh-CN.md +4 -0
- package/package.json +1 -1
- package/tidy-tools.ts +17 -1
package/README.md
CHANGED
|
@@ -91,6 +91,10 @@ If a shortcut still does nothing on your machine, check:
|
|
|
91
91
|
|
|
92
92
|
## Changelog
|
|
93
93
|
|
|
94
|
+
### 0.2.2
|
|
95
|
+
|
|
96
|
+
- Cached collapsed bash output by terminal width to reduce repeated rendering work during TUI redraws with many tool calls
|
|
97
|
+
|
|
94
98
|
### 0.2.1
|
|
95
99
|
|
|
96
100
|
- Added per-block fullscreen clicking for bash/edit/write, toggling between compact and full rendering
|
package/README.zh-CN.md
CHANGED
package/package.json
CHANGED
package/tidy-tools.ts
CHANGED
|
@@ -133,6 +133,9 @@ class LimitedLinesText implements Component {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
class CollapsedBashOutput implements Component {
|
|
136
|
+
private cachedWidth?: number;
|
|
137
|
+
private cachedLines?: string[];
|
|
138
|
+
|
|
136
139
|
// 首行预览 + 计数后缀合并为 1 行,后缀常显。预览放不下时截断并加省略标记。
|
|
137
140
|
constructor(
|
|
138
141
|
private readonly preview: string,
|
|
@@ -141,6 +144,16 @@ class CollapsedBashOutput implements Component {
|
|
|
141
144
|
) {}
|
|
142
145
|
|
|
143
146
|
render(width: number): string[] {
|
|
147
|
+
if (this.cachedLines !== undefined && this.cachedWidth === width) {
|
|
148
|
+
return this.cachedLines;
|
|
149
|
+
}
|
|
150
|
+
const lines = this.renderUncached(width);
|
|
151
|
+
this.cachedWidth = width;
|
|
152
|
+
this.cachedLines = lines;
|
|
153
|
+
return lines;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private renderUncached(width: number): string[] {
|
|
144
157
|
if (!this.suffix) {
|
|
145
158
|
return truncateRows(
|
|
146
159
|
wrapTextWithAnsi(this.preview, Math.max(1, width)),
|
|
@@ -169,7 +182,10 @@ class CollapsedBashOutput implements Component {
|
|
|
169
182
|
return [visibleWidth(row) > width ? sliceByColumn(row, 0, width, true) : row];
|
|
170
183
|
}
|
|
171
184
|
|
|
172
|
-
invalidate(): void {
|
|
185
|
+
invalidate(): void {
|
|
186
|
+
this.cachedWidth = undefined;
|
|
187
|
+
this.cachedLines = undefined;
|
|
188
|
+
}
|
|
173
189
|
}
|
|
174
190
|
|
|
175
191
|
class CollapsedToolShell extends Box {
|