Add pi-tool-display (compact tool rendering, adaptive diffs) + pi-lsp-extension (LSP diagnostics/hover/definitions) — vendored from npm 0.5.0 / 1.3.0
This commit is contained in:
31
extensions/pi-tool-display/src/write-display-utils.ts
Normal file
31
extensions/pi-tool-display/src/write-display-utils.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
export interface WriteCallSummaryOptions {
|
||||
hasContent: boolean;
|
||||
hasDetailedResultHeader: boolean;
|
||||
}
|
||||
|
||||
export function splitWriteContentLines(content: string): string[] {
|
||||
if (!content) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const normalized = content.replace(/\r/g, "");
|
||||
const lines = normalized.split("\n");
|
||||
if (lines.length > 0 && lines[lines.length - 1] === "") {
|
||||
lines.pop();
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
export function countWriteContentLines(value: unknown): number {
|
||||
return typeof value === "string" ? splitWriteContentLines(value).length : 0;
|
||||
}
|
||||
|
||||
export function getWriteContentSizeBytes(value: unknown): number {
|
||||
return typeof value === "string" ? Buffer.byteLength(value, "utf8") : 0;
|
||||
}
|
||||
|
||||
export function shouldRenderWriteCallSummary(
|
||||
options: WriteCallSummaryOptions,
|
||||
): boolean {
|
||||
return options.hasContent && !options.hasDetailedResultHeader;
|
||||
}
|
||||
Reference in New Issue
Block a user