Should format error in comments and doc panel (#18761)

This commit is contained in:
fisker Cheung authored and GitHub committed 2026-01-27 18:07:35 +08:00
1 parent f58d550470
commit 657ef1e119
1 file changed
+21 -13
+21 -13
View File
@@ -170,23 +170,31 @@ async function handleFormatMessage(message) {
}
if (!isDocExplorer && message.debug.doc) {
try {
response.debug.doc = await prettier.__debug.formatDoc(
await prettier.__debug.printToDoc(message.code, options),
{ plugins },
);
} catch {
response.debug.doc = "";
if (formatResult.error) {
response.debug.doc = formatResult.formatted;
} else {
try {
response.debug.doc = await prettier.__debug.formatDoc(
await prettier.__debug.printToDoc(message.code, options),
{ plugins },
);
} catch {
response.debug.doc = "";
}
}
}
if (!isDocExplorer && message.debug.comments) {
response.debug.comments = (
await formatCode(JSON.stringify(formatResult.comments || []), {
parser: "json",
plugins,
})
).formatted;
if (formatResult.error) {
response.debug.comments = formatResult.formatted;
} else {
response.debug.comments = (
await formatCode(JSON.stringify(formatResult.comments || []), {
parser: "json",
plugins,
})
).formatted;
}
}
if (!isDocExplorer && message.debug.reformat) {