Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 2 additions & 24 deletions src/jsonlTextViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,20 +274,9 @@ export class JsonlTextViewProvider implements vscode.TextDocumentContentProvider
: '';
const header = ` [#${rec.index}] ${tokenStr} `.trimEnd();

const bodyLines: string[] = [];
let bodyLines: string[] = [];
if (rec.data && typeof rec.data === 'object') {
const entries = Object.entries(rec.data).slice(0, 15);
for (const [key, value] of entries) {
if (value !== null && typeof value === 'object') {
bodyLines.push(this.padLine(` ${key}:`, contentWidth));
for (const line of this.prettyValueLines(value, contentWidth - 4)) {
bodyLines.push(this.padLine(' ' + line.trimEnd(), contentWidth));
}
} else {
const line = ` ${key}: ${this.formatValueOneLine(value)}`;
bodyLines.push(this.padLine(this.truncateAtWord(line, contentWidth), contentWidth));
}
}
bodyLines = this.prettyValueLines(rec.data, contentWidth);
} else {
bodyLines.push(this.padLine(this.truncateAtWord(' ' + rec.raw, contentWidth), contentWidth));
}
Expand Down Expand Up @@ -318,17 +307,6 @@ export class JsonlTextViewProvider implements vscode.TextDocumentContentProvider
}
}

/** Format a value for single-line display. */
private formatValueOneLine(value: unknown): string {
if (value === null) return 'null';
if (typeof value !== 'object') return String(value);
try {
return JSON.stringify(value);
} catch {
return String(value);
}
}

/** Pretty-printed lines for an object value; each line fits within maxWidth (wrap at word boundaries). */
private prettyValueLines(value: unknown, maxWidth: number): string[] {
const raw = this.prettyPrintJson(value);
Expand Down