fix(lsp): sanitize expanded generic output
(cherry picked from commit 1260d0633a5fb533c492f272ee500fec60c46e22)
This commit is contained in:
@@ -582,7 +582,7 @@ function renderGeneric(text: string, lines: string[], expanded: boolean, theme:
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const isLast = i === lines.length - 1;
|
||||
const branch = isLast ? theme.tree.last : theme.tree.branch;
|
||||
output += `\n ${theme.fg("dim", branch)} ${lines[i]}`;
|
||||
output += `\n ${theme.fg("dim", branch)} ${truncateToWidth(replaceTabs(lines[i]), TRUNCATE_LENGTHS.CONTENT)}`;
|
||||
}
|
||||
return output.split("\n");
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
sortAndValidateTextEdits,
|
||||
} from "@oh-my-pi/pi-coding-agent/lsp/edits";
|
||||
import { renderCall, renderResult } from "@oh-my-pi/pi-coding-agent/lsp/render";
|
||||
import { renderResult as renderLocalResult } from "../../src/lsp/render";
|
||||
import {
|
||||
type CodeAction,
|
||||
type CreateFile,
|
||||
@@ -1354,6 +1355,22 @@ describe("lsp regressions", () => {
|
||||
expect(resultText.replace(/\s+/g, " ")).toContain("too many arguments in call");
|
||||
});
|
||||
|
||||
it("sanitizes expanded generic error output (#7041)", async () => {
|
||||
const theme = await getThemeByName("dark");
|
||||
expect(theme).toBeDefined();
|
||||
const result = renderLocalResult(
|
||||
{
|
||||
content: [{ type: "text", text: `Error:\nserver\tstderr ${"x".repeat(200)}` }],
|
||||
},
|
||||
{ expanded: true, isPartial: false },
|
||||
theme!,
|
||||
);
|
||||
|
||||
const lines = sanitizeText(result.render(300).join("\n")).split("\n");
|
||||
expect(lines.join("\n")).not.toContain("\t");
|
||||
expect(lines.join("\n")).not.toContain("x".repeat(100));
|
||||
});
|
||||
|
||||
for (const dynamicRegistration of [false, true]) {
|
||||
it(`reports pull diagnostics advertised through ${dynamicRegistration ? "dynamic registration" : "server capabilities"}`, async () => {
|
||||
const tempDir = TempDir.createSync("@omp-lsp-pull-diags-");
|
||||
|
||||
Reference in New Issue
Block a user