opencode-miniterm 1.0.6 → 1.0.8
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/render.ts +17 -3
- package/test/render.test.ts +5 -0
package/package.json
CHANGED
package/src/render.ts
CHANGED
|
@@ -43,8 +43,12 @@ export function render(state: State, details = false): void {
|
|
|
43
43
|
if (!part.text.trim()) continue;
|
|
44
44
|
|
|
45
45
|
if (part.title === "thinking") {
|
|
46
|
+
const doc = parse(part.text.trimStart(), gfm);
|
|
47
|
+
let partText = ansi.stripAnsiCodes(renderToConsole(doc));
|
|
48
|
+
|
|
46
49
|
// Show max 10 thinking lines
|
|
47
|
-
|
|
50
|
+
partText = details ? partText : lastThinkingLines(partText);
|
|
51
|
+
|
|
48
52
|
output += "<ocmt-thinking>\n";
|
|
49
53
|
output += `💭 ${partText}\n\n`;
|
|
50
54
|
output += "</ocmt-thinking>\n";
|
|
@@ -221,19 +225,27 @@ export function wrapText(text: string, width: number): string[] {
|
|
|
221
225
|
}
|
|
222
226
|
};
|
|
223
227
|
|
|
228
|
+
let atLineStart = true;
|
|
229
|
+
let lineIndent = "";
|
|
224
230
|
while (i < text.length) {
|
|
225
231
|
const char = text[i];
|
|
226
232
|
|
|
227
233
|
if (char === "\n") {
|
|
228
234
|
pushLine();
|
|
235
|
+
atLineStart = true;
|
|
236
|
+
lineIndent = "";
|
|
229
237
|
i++;
|
|
230
238
|
} else if (char === "\r") {
|
|
231
239
|
i++;
|
|
232
240
|
} else if (char === " " || char === "\t") {
|
|
241
|
+
if (atLineStart) {
|
|
242
|
+
lineIndent += char;
|
|
243
|
+
}
|
|
233
244
|
i++;
|
|
234
245
|
} else {
|
|
235
|
-
let word =
|
|
236
|
-
let wordVisibleLength =
|
|
246
|
+
let word = lineIndent;
|
|
247
|
+
let wordVisibleLength = lineIndent.length;
|
|
248
|
+
atLineStart = false;
|
|
237
249
|
|
|
238
250
|
while (i < text.length) {
|
|
239
251
|
const char = text[i];
|
|
@@ -256,6 +268,8 @@ export function wrapText(text: string, width: number): string[] {
|
|
|
256
268
|
}
|
|
257
269
|
|
|
258
270
|
addWord(word, wordVisibleLength);
|
|
271
|
+
atLineStart = false;
|
|
272
|
+
lineIndent = "";
|
|
259
273
|
}
|
|
260
274
|
}
|
|
261
275
|
|
package/test/render.test.ts
CHANGED
|
@@ -344,6 +344,11 @@ describe("wrapText", () => {
|
|
|
344
344
|
const result = wrapText("line1\n\nline3", 20);
|
|
345
345
|
expect(result).toEqual([" line1", " ", " line3"]);
|
|
346
346
|
});
|
|
347
|
+
|
|
348
|
+
it("should preserve indents", () => {
|
|
349
|
+
const result = wrapText("line1\n line2 extra\n line3", 20);
|
|
350
|
+
expect(result).toEqual([" line1", " line2 extra", " line3"]);
|
|
351
|
+
});
|
|
347
352
|
});
|
|
348
353
|
|
|
349
354
|
describe("ANSI codes", () => {
|