Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Even more generic header printing in prettier_server

Kirill Bulatove8409a0108f7
diff --git a/crates/prettier/src/prettier_server.js b/crates/prettier/src/prettier_server.js
index 27259143342..02c21811e2a 100644
--- a/crates/prettier/src/prettier_server.js
+++ b/crates/prettier/src/prettier_server.js
@@ -44,6 +44,7 @@ async function handleBuffer(prettier) {
}
const headerSeparator = "\r\n";
+const contentLengthHeaderName = 'Content-Length';
async function* readStdin() {
let buffer = Buffer.alloc(0);
@@ -64,7 +65,6 @@ async function* readStdin() {
}
try {
- let contentLengthHeaderName = 'Content-Length';
let headersLength = null;
let messageLength = null;
main_loop: while (true) {
@@ -165,7 +165,7 @@ function sendResponse(response) {
jsonrpc: "2.0",
...response
});
- let headers = `Content-Length: ${Buffer.byteLength(responsePayloadString)}${headerSeparator}${headerSeparator}`;
+ let headers = `${contentLengthHeaderName}: ${Buffer.byteLength(responsePayloadString)}${headerSeparator}${headerSeparator}`;
let dataToSend = headers + responsePayloadString;
process.stdout.write(dataToSend);
}